@fr-data-fabric/chatbot-api-nest 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fr-data-fabric/chatbot-api-nest",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "tsc -p tsconfig.json"
@@ -39,9 +39,19 @@ export abstract class GetChatCompletionUC<
39
39
  abstract getLLM(options: { model?: string }): BaseChatModel;
40
40
  abstract getPrompt(
41
41
  question: string,
42
+ contextDocuments: { content: string; id: string }[],
42
43
  documents: DocumentEntity[],
43
44
  ): Promise<BaseMessage[]>;
44
45
 
46
+ // Override to retrieve RAG context based on the user's question.
47
+ // Called before getPrompt(); returned documents are merged with any
48
+ // explicitly provided documents and passed together to getPrompt().
49
+ abstract getContextDocuments(
50
+ question: string,
51
+ conversation: ConversationEntity,
52
+ currentUser: UserEntity,
53
+ ): Promise<{ content: string; id: string }[]>;
54
+
45
55
  execute(input: GetChatCompletionInput<AvailableTools>) {
46
56
  return new Observable<StreamEvents<AvailableTools>>((observer) => {
47
57
  const model = this.getLLM({
@@ -65,7 +75,16 @@ export abstract class GetChatCompletionUC<
65
75
  });
66
76
 
67
77
  void (async () => {
68
- const prompt = await this.getPrompt(input.message, input.documents);
78
+ const contextDocuments = await this.getContextDocuments(
79
+ input.message,
80
+ input.conversation,
81
+ input.currentUser,
82
+ );
83
+ const prompt = await this.getPrompt(
84
+ input.message,
85
+ contextDocuments,
86
+ input.documents,
87
+ );
69
88
 
70
89
  const eventStream = agent.streamEvents(
71
90
  { messages: prompt },
package/src/index.ts CHANGED
@@ -1 +1,37 @@
1
1
  export * from './chatbot-api.module';
2
+
3
+ // Entities
4
+ export * from './domain/entities/ChatEntity';
5
+ export * from './domain/entities/ChatSourceEntity';
6
+ export * from './domain/entities/ChatTextContentEntity';
7
+ export * from './domain/entities/ConversationEntity';
8
+ export * from './domain/entities/DocumentEntity';
9
+ export * from './domain/entities/ToolUseEntity';
10
+ export * from './domain/entities/UserEntity';
11
+
12
+ // Interfaces & DI tokens
13
+ export * from './domain/interfaces/ChatRepository';
14
+ export * from './domain/interfaces/ConversationRepository';
15
+ export * from './domain/interfaces/LLMService';
16
+ export * from './domain/interfaces/PromptService';
17
+
18
+ // Use-case common types
19
+ export * from './domain/use-cases/_common';
20
+
21
+ // Chat use cases & types
22
+ export * from './domain/use-cases/chats/chat.types';
23
+ export * from './domain/use-cases/chats/GetChatCompletionUC';
24
+ export * from './domain/use-cases/chats/SendChatUC';
25
+
26
+ // Conversation use cases
27
+ export * from './domain/use-cases/conversations/CreateConversationUC';
28
+ export * from './domain/use-cases/conversations/DeleteConversationUC';
29
+ export * from './domain/use-cases/conversations/GenerateConversationTitleUC';
30
+ export * from './domain/use-cases/conversations/GetConversationUC';
31
+ export * from './domain/use-cases/conversations/GetConversationsUC';
32
+ export * from './domain/use-cases/conversations/UpdateConversationUC';
33
+
34
+ // Input helpers (decorators & GQL utilities)
35
+ export * from './inputs/controllers/_common/CurrentUserRest';
36
+ export * from './inputs/resolvers/_common/CurrentUserGql';
37
+ export * from './inputs/resolvers/_common/GqlPaginatedOutput';