@fr-data-fabric/chatbot-api-nest 0.0.1 → 0.0.3
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/dist/chatbot-api.module.d.ts +5 -5
- package/dist/chatbot-api.module.js +7 -7
- package/dist/domain/entities/ChatEntity.d.ts +3 -3
- package/dist/domain/entities/ConversationEntity.d.ts +2 -2
- package/dist/domain/interfaces/ChatRepository.d.ts +1 -1
- package/dist/domain/interfaces/ConversationRepository.d.ts +1 -1
- package/dist/domain/use-cases/_common.d.ts +1 -1
- package/dist/domain/use-cases/chats/GetChatCompletionUC.d.ts +12 -5
- package/dist/domain/use-cases/chats/GetChatCompletionUC.js +2 -1
- package/dist/domain/use-cases/chats/GetChatCompletionUC.js.map +1 -1
- package/dist/domain/use-cases/chats/SendChatUC.d.ts +12 -12
- package/dist/domain/use-cases/chats/chat.types.d.ts +1 -1
- package/dist/domain/use-cases/conversations/CreateConversationUC.d.ts +2 -2
- package/dist/domain/use-cases/conversations/DeleteConversationUC.d.ts +4 -4
- package/dist/domain/use-cases/conversations/DeleteConversationUC.js +2 -2
- package/dist/domain/use-cases/conversations/GenerateConversationTitleUC.d.ts +6 -6
- package/dist/domain/use-cases/conversations/GenerateConversationTitleUC.js +4 -4
- package/dist/domain/use-cases/conversations/GetConversationUC.d.ts +2 -2
- package/dist/domain/use-cases/conversations/GetConversationsUC.d.ts +2 -2
- package/dist/domain/use-cases/conversations/GetConversationsUC.js +1 -1
- package/dist/domain/use-cases/conversations/UpdateConversationUC.d.ts +4 -4
- package/dist/domain/use-cases/conversations/UpdateConversationUC.js +2 -2
- package/dist/index.d.ts +24 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/dist/inputs/controllers/ChatsController.d.ts +2 -2
- package/dist/inputs/controllers/ChatsController.js +1 -1
- package/dist/inputs/resolvers/ChatsResolver.d.ts +1 -1
- package/dist/inputs/resolvers/ConversationsResolver.d.ts +11 -11
- package/dist/inputs/resolvers/ConversationsResolver.js +7 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/domain/use-cases/chats/GetChatCompletionUC.ts +20 -1
- package/src/index.ts +36 -0
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fr-data-fabric/chatbot-api-nest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "tsc -p tsconfig.json"
|
|
6
|
+
"build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json"
|
|
7
7
|
},
|
|
8
8
|
"author": "PM Data Fabric",
|
|
9
9
|
"license": "Apache-2.0",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"rxjs": "^7.8.2"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@types/express": "^5.0.6"
|
|
20
|
+
"@types/express": "^5.0.6",
|
|
21
|
+
"tsc-alias": "^1.8.16"
|
|
21
22
|
},
|
|
22
23
|
"publishConfig": {
|
|
23
24
|
"access": "public"
|
|
@@ -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
|
|
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';
|