Skip to content

Commit

Permalink
added base AI module
Browse files Browse the repository at this point in the history
  • Loading branch information
henriqueweiand committed Nov 3, 2023
1 parent 1dd6045 commit 573ed7d
Show file tree
Hide file tree
Showing 6 changed files with 258 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@nestjs/platform-express": "^9.0.0",
"@nestjs/swagger": "^7.1.14",
"@prisma/client": "^5.5.2",
"chatgpt": "5.2.5",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"reflect-metadata": "^0.1.13",
Expand Down
11 changes: 11 additions & 0 deletions src/modules/common/AI/ai-chat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Injectable } from '@nestjs/common'
import { AIChatGenerator } from './interface/ai-chat-generator'

@Injectable()
export class AIChat implements AIChatGenerator {
constructor(private aIChatGenerator: AIChatGenerator) { }

ask(question: string): Promise<string> {
return this.aIChatGenerator.ask(question)
}
}
14 changes: 14 additions & 0 deletions src/modules/common/AI/ai.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Module } from '@nestjs/common';
import { AIChatGenerator } from './interface/ai-chat-generator';
import { AIChat } from './ai-chat';

@Module({
providers: [
{
provide: AIChatGenerator,
useClass: AIChat
},
],
exports: [AIChatGenerator],
})
export class AIModule { }
1 change: 1 addition & 0 deletions src/modules/common/AI/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ai.module';
4 changes: 4 additions & 0 deletions src/modules/common/AI/interface/ai-chat-generator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export abstract class AIChatGenerator {
abstract ask(id: string): Promise<string | null>
}
Loading

0 comments on commit 573ed7d

Please sign in to comment.