feat: add get chatbot conversation by id endpoint
This commit is contained in:
@@ -38,6 +38,27 @@ export class ChatbotService {
|
||||
}));
|
||||
}
|
||||
|
||||
public async getConversation(user: User, conversationId: number) {
|
||||
const conversation = await this.conversationService.findConversationById(
|
||||
conversationId,
|
||||
user,
|
||||
);
|
||||
const messages = await this.conversationService.getMessages(conversation);
|
||||
|
||||
return {
|
||||
conversationId: conversation.id,
|
||||
title: conversation.title,
|
||||
createdAt: conversation.createdAt,
|
||||
updatedAt: conversation.updatedAt,
|
||||
messages: messages.map((message) => ({
|
||||
messageId: message.id,
|
||||
role: message.role,
|
||||
content: message.content,
|
||||
createdAt: message.createdAt,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
private async getConversationMessages(
|
||||
user: User,
|
||||
message: string,
|
||||
|
||||
Reference in New Issue
Block a user