Skip to content

Commit

Permalink
feat(assistant): global configuration and response types
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianmusial committed Jan 8, 2024
1 parent 1feb1bf commit ca4198d
Show file tree
Hide file tree
Showing 5 changed files with 728 additions and 740 deletions.
6 changes: 4 additions & 2 deletions src/chat/chat.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export class ChatController {
) {}

@Post()
async call(@Body() payload: ChatCall): Promise<string> {
return this.chatService.call(payload);
async call(@Body() payload: ChatCall): Promise<ChatCall> {
return {
content: await this.chatService.call(payload),
};
}

@Post('/files')
Expand Down
2 changes: 1 addition & 1 deletion src/chat/chat.model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface ChatCall {
message: string;
content: string;
}
4 changes: 2 additions & 2 deletions src/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class ChatService implements OnModuleInit {
return this.aiService.provider.beta.threads.create();
}

async call({ message }: ChatCall): Promise<string> {
async call({ content }: ChatCall): Promise<string> {
const threadId = this.defaultThread.id;
return this.chatbotService.call(threadId, message);
return this.chatbotService.call(threadId, content);
}
}
5 changes: 5 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { AppModule } from './app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.setGlobalPrefix('api');
app.enableCors({
origin: '*',
credentials: true,
});
await app.listen(3000);
}
bootstrap();
Loading

0 comments on commit ca4198d

Please sign in to comment.