@ainetwork/adk-provider-memory-mongodb 0.1.2 → 0.1.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/chunk-JCE5NAY5.js +29 -0
- package/dist/chunk-JCE5NAY5.js.map +1 -0
- package/dist/{chunk-2SB2M62A.js → chunk-SS7OXU6N.js} +31 -7
- package/dist/chunk-SS7OXU6N.js.map +1 -0
- package/dist/index.cjs +218 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -9
- package/dist/index.d.ts +31 -9
- package/dist/index.js +139 -37
- package/dist/index.js.map +1 -1
- package/dist/models/chats.model.cjs +35 -19
- package/dist/models/chats.model.cjs.map +1 -1
- package/dist/models/chats.model.d.cts +81 -7
- package/dist/models/chats.model.d.ts +81 -7
- package/dist/models/chats.model.js +9 -5
- package/dist/models/{intentTriggeringInfos.model.cjs → intent.model.cjs} +22 -28
- package/dist/models/intent.model.cjs.map +1 -0
- package/dist/models/intent.model.d.cts +15 -0
- package/dist/models/intent.model.d.ts +15 -0
- package/dist/models/intent.model.js +7 -0
- package/dist/models/intent.model.js.map +1 -0
- package/package.json +2 -2
- package/dist/chunk-2SB2M62A.js.map +0 -1
- package/dist/models/intentTriggeringInfos.model.cjs.map +0 -1
- package/dist/models/intentTriggeringInfos.model.d.cts +0 -29
- package/dist/models/intentTriggeringInfos.model.d.ts +0 -29
- package/dist/models/intentTriggeringInfos.model.js +0 -34
- package/dist/models/intentTriggeringInfos.model.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
ChatObjectSchema,
|
|
3
|
+
SessionObjectSchema
|
|
4
|
+
} from "./chunk-SS7OXU6N.js";
|
|
5
|
+
import {
|
|
6
|
+
IntentModel
|
|
7
|
+
} from "./chunk-JCE5NAY5.js";
|
|
8
|
+
|
|
9
|
+
// implements/session.memory.ts
|
|
10
|
+
import { randomUUID } from "crypto";
|
|
4
11
|
|
|
5
|
-
//
|
|
6
|
-
import {
|
|
12
|
+
// implements/base.memory.ts
|
|
13
|
+
import { Mongoose } from "mongoose";
|
|
7
14
|
import { loggers } from "@ainetwork/adk/utils/logger";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
var MongoDBMemory = class {
|
|
16
|
+
_isConnected = false;
|
|
17
|
+
_uri;
|
|
18
|
+
_mongoose;
|
|
11
19
|
constructor(uri) {
|
|
12
|
-
|
|
13
|
-
this.
|
|
20
|
+
this._uri = uri;
|
|
21
|
+
this._mongoose = new Mongoose();
|
|
14
22
|
}
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
getInstance() {
|
|
24
|
+
return this._mongoose;
|
|
25
|
+
}
|
|
26
|
+
async connect() {
|
|
27
|
+
if (this._isConnected) {
|
|
17
28
|
return;
|
|
18
29
|
}
|
|
19
30
|
try {
|
|
20
|
-
await
|
|
21
|
-
this.
|
|
31
|
+
await this._mongoose.connect(this._uri);
|
|
32
|
+
this._isConnected = true;
|
|
22
33
|
loggers.agent.info("MongoDB connected successfully");
|
|
23
34
|
} catch (error) {
|
|
24
35
|
loggers.agent.error("Failed to connect to MongoDB:", error);
|
|
@@ -30,19 +41,35 @@ var MongoDBMemory = class extends BaseMemory {
|
|
|
30
41
|
return;
|
|
31
42
|
}
|
|
32
43
|
try {
|
|
33
|
-
await
|
|
34
|
-
this.
|
|
44
|
+
await this._mongoose?.disconnect();
|
|
45
|
+
this._isConnected = false;
|
|
35
46
|
loggers.agent.info("MongoDB disconnected successfully");
|
|
36
47
|
} catch (error) {
|
|
37
48
|
loggers.agent.error("Failed to disconnect from MongoDB:", error);
|
|
38
49
|
throw error;
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
|
-
|
|
42
|
-
|
|
52
|
+
isConnected() {
|
|
53
|
+
return this._isConnected;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// implements/session.memory.ts
|
|
58
|
+
import { loggers as loggers2 } from "@ainetwork/adk/utils/logger";
|
|
59
|
+
var MongoDBSession = class extends MongoDBMemory {
|
|
60
|
+
chatModel;
|
|
61
|
+
sessionModel;
|
|
62
|
+
constructor(uri) {
|
|
63
|
+
super(uri);
|
|
64
|
+
const _mongoose = super.getInstance();
|
|
65
|
+
this.chatModel = _mongoose.model("Chat", ChatObjectSchema);
|
|
66
|
+
this.sessionModel = _mongoose.model("Session", SessionObjectSchema);
|
|
67
|
+
}
|
|
68
|
+
async getSession(sessionId, userId) {
|
|
69
|
+
const chats = await this.chatModel.find({ sessionId }).sort({
|
|
43
70
|
timestamp: 1
|
|
44
71
|
});
|
|
45
|
-
|
|
72
|
+
loggers2.agent.debug(`Found ${chats.length} chats for session ${sessionId}`);
|
|
46
73
|
const sessionObject = { chats: {} };
|
|
47
74
|
chats.forEach((chat) => {
|
|
48
75
|
const chatId = chat._id?.toString() || chat.id;
|
|
@@ -55,34 +82,109 @@ var MongoDBMemory = class extends BaseMemory {
|
|
|
55
82
|
});
|
|
56
83
|
return sessionObject;
|
|
57
84
|
}
|
|
58
|
-
async
|
|
59
|
-
|
|
60
|
-
loggers.agent.info(`Chat: ${JSON.stringify(chat)}`);
|
|
61
|
-
await ChatModel.create({
|
|
85
|
+
async createSession(userId, sessionId) {
|
|
86
|
+
await this.sessionModel.create({
|
|
62
87
|
sessionId,
|
|
88
|
+
userId,
|
|
89
|
+
updated_at: Date.now(),
|
|
90
|
+
created_at: Date.now()
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async addChatToSession(userId, sessionId, chat) {
|
|
94
|
+
const newId = randomUUID();
|
|
95
|
+
const session = await this.sessionModel.findOne({ sessionId, userId });
|
|
96
|
+
if (!session) {
|
|
97
|
+
await this.createSession(userId, sessionId);
|
|
98
|
+
} else {
|
|
99
|
+
await this.sessionModel.updateOne({ sessionId, userId }, {
|
|
100
|
+
updated_at: Date.now()
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
await this.chatModel.create({
|
|
104
|
+
sessionId,
|
|
105
|
+
chatId: newId,
|
|
106
|
+
userId,
|
|
63
107
|
role: chat.role,
|
|
64
108
|
content: chat.content,
|
|
65
109
|
timestamp: chat.timestamp,
|
|
66
110
|
metadata: chat.metadata
|
|
67
111
|
});
|
|
68
112
|
}
|
|
69
|
-
async
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
113
|
+
async deleteSession(userId, sessionId) {
|
|
114
|
+
const chats = await this.chatModel.find({ userId, sessionId }).sort({
|
|
115
|
+
timestamp: 1
|
|
116
|
+
});
|
|
117
|
+
chats?.forEach((chat) => {
|
|
118
|
+
chat.deleteOne();
|
|
119
|
+
});
|
|
120
|
+
const session = await this.sessionModel.findOne({ sessionId, userId });
|
|
121
|
+
session?.deleteOne();
|
|
122
|
+
}
|
|
123
|
+
async listSessions(userId) {
|
|
124
|
+
const sessions = await this.sessionModel.find({ userId }).sort({
|
|
125
|
+
updated_at: -1
|
|
126
|
+
});
|
|
127
|
+
const data = sessions.map((session) => {
|
|
128
|
+
return {
|
|
129
|
+
sessionId: session.sessionId,
|
|
130
|
+
title: session.title,
|
|
131
|
+
updatedAt: session.updated_at
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
return data;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// implements/intent.memory.ts
|
|
139
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
140
|
+
var MongoDBIntent = class extends MongoDBMemory {
|
|
141
|
+
async getIntent(intentId) {
|
|
142
|
+
const intent = await IntentModel.findById(intentId);
|
|
143
|
+
if (intent) {
|
|
144
|
+
return {
|
|
145
|
+
name: intent.name,
|
|
146
|
+
description: intent.description,
|
|
147
|
+
prompt: intent.prompt,
|
|
148
|
+
llm: intent.llm
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
async saveIntent(intent) {
|
|
154
|
+
const newId = randomUUID2();
|
|
155
|
+
await IntentModel.create({
|
|
156
|
+
_id: newId,
|
|
157
|
+
name: intent.name,
|
|
158
|
+
description: intent.description,
|
|
159
|
+
prompt: intent.prompt,
|
|
160
|
+
llm: intent.llm
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
async updateIntent(intentId, intent) {
|
|
164
|
+
await IntentModel.updateOne({
|
|
165
|
+
_id: intentId
|
|
166
|
+
}, {
|
|
167
|
+
name: intent.name,
|
|
168
|
+
description: intent.description,
|
|
169
|
+
prompt: intent.prompt,
|
|
170
|
+
llm: intent.llm
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
async deleteIntent(intentId) {
|
|
174
|
+
await IntentModel.deleteOne({ _id: intentId });
|
|
175
|
+
}
|
|
176
|
+
async listIntents() {
|
|
177
|
+
const intents = await IntentModel.find();
|
|
178
|
+
return intents.map((intent) => ({
|
|
179
|
+
name: intent.name,
|
|
180
|
+
description: intent.description,
|
|
181
|
+
prompt: intent.prompt,
|
|
182
|
+
llm: intent.llm
|
|
183
|
+
}));
|
|
83
184
|
}
|
|
84
185
|
};
|
|
85
186
|
export {
|
|
86
|
-
|
|
187
|
+
MongoDBIntent,
|
|
188
|
+
MongoDBSession
|
|
87
189
|
};
|
|
88
190
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { BaseMemory } from \"@ainetwork/adk/modules\";\nimport type { ChatObject, SessionObject } from \"@ainetwork/adk/types/memory\";\nimport { loggers } from \"@ainetwork/adk/utils/logger\";\nimport mongoose from \"mongoose\";\nimport {\n\ttype ChatDocument,\n\tChatModel,\n\tChatRole,\n} from \"./models/chats.model\";\n\nexport class MongoDBMemory extends BaseMemory {\n\tprivate isConnected = false;\n\n\tconstructor(uri: string) {\n\t\tsuper();\n\t\tthis.connect(uri);\n\t}\n\n\tpublic async connect(uri: string): Promise<void> {\n\t\tif (this.isConnected) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait mongoose.connect(uri);\n\t\t\tthis.isConnected = true;\n\t\t\tloggers.agent.info(\"MongoDB connected successfully\");\n\t\t} catch (error) {\n\t\t\tloggers.agent.error(\"Failed to connect to MongoDB:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic async disconnect(): Promise<void> {\n\t\tif (!this.isConnected) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait mongoose.disconnect();\n\t\t\tthis.isConnected = false;\n\t\t\tloggers.agent.info(\"MongoDB disconnected successfully\");\n\t\t} catch (error) {\n\t\t\tloggers.agent.error(\"Failed to disconnect from MongoDB:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic async getSessionHistory(sessionId: string): Promise<SessionObject> {\n\t\tconst chats = await ChatModel.find({ sessionId }).sort({\n\t\t\ttimestamp: 1,\n\t\t});\n\n\t\tloggers.agent.info(`Found ${chats.length} chats for session ${sessionId}`);\n\n\t\tconst sessionObject: SessionObject = { chats: {} };\n\t\tchats.forEach((chat: ChatDocument) => {\n\t\t\tconst chatId = chat._id?.toString() || chat.id;\n\t\t\tsessionObject.chats[chatId] = {\n\t\t\t\trole: chat.role as ChatRole,\n\t\t\t\tcontent: chat.content,\n\t\t\t\ttimestamp: chat.timestamp,\n\t\t\t\tmetadata: chat.metadata,\n\t\t\t};\n\t\t});\n\n\t\treturn sessionObject;\n\t}\n\n\tpublic async updateSessionHistory(\n\t\tsessionId: string,\n\t\tchat: ChatObject,\n\t): Promise<void> {\n\t\tloggers.agent.info(`Updating session history for session ${sessionId}`);\n\t\tloggers.agent.info(`Chat: ${JSON.stringify(chat)}`);\n\n\t\tawait ChatModel.create({\n\t\t\tsessionId,\n\t\t\trole: chat.role,\n\t\t\tcontent: chat.content,\n\t\t\ttimestamp: chat.timestamp,\n\t\t\tmetadata: chat.metadata,\n\t\t});\n\t}\n\n\tpublic async storeQueryAndIntent(\n\t\tquery: string,\n\t\tintent: string,\n\t\tsessionId: string,\n\t): Promise<void> {\n\t\t// Intent 정보를 metadata에 저장\n\t\tconst chat: ChatObject = {\n\t\t\trole: ChatRole.USER,\n\t\t\tcontent: {\n\t\t\t\ttype: \"text\",\n\t\t\t\tparts: [query],\n\t\t\t},\n\t\t\ttimestamp: Date.now(),\n\t\t\tmetadata: {\n\t\t\t\tintent,\n\t\t\t\tquery,\n\t\t\t},\n\t\t};\n\n\t\tawait this.updateSessionHistory(sessionId, chat);\n\t}\n}\n"],"mappings":";;;;;AAAA,SAAS,kBAAkB;AAE3B,SAAS,eAAe;AACxB,OAAO,cAAc;AAOd,IAAM,gBAAN,cAA4B,WAAW;AAAA,EACrC,cAAc;AAAA,EAEtB,YAAY,KAAa;AACxB,UAAM;AACN,SAAK,QAAQ,GAAG;AAAA,EACjB;AAAA,EAEA,MAAa,QAAQ,KAA4B;AAChD,QAAI,KAAK,aAAa;AACrB;AAAA,IACD;AAEA,QAAI;AACH,YAAM,SAAS,QAAQ,GAAG;AAC1B,WAAK,cAAc;AACnB,cAAQ,MAAM,KAAK,gCAAgC;AAAA,IACpD,SAAS,OAAO;AACf,cAAQ,MAAM,MAAM,iCAAiC,KAAK;AAC1D,YAAM;AAAA,IACP;AAAA,EACD;AAAA,EAEA,MAAa,aAA4B;AACxC,QAAI,CAAC,KAAK,aAAa;AACtB;AAAA,IACD;AAEA,QAAI;AACH,YAAM,SAAS,WAAW;AAC1B,WAAK,cAAc;AACnB,cAAQ,MAAM,KAAK,mCAAmC;AAAA,IACvD,SAAS,OAAO;AACf,cAAQ,MAAM,MAAM,sCAAsC,KAAK;AAC/D,YAAM;AAAA,IACP;AAAA,EACD;AAAA,EAEA,MAAa,kBAAkB,WAA2C;AACzE,UAAM,QAAQ,MAAM,UAAU,KAAK,EAAE,UAAU,CAAC,EAAE,KAAK;AAAA,MACtD,WAAW;AAAA,IACZ,CAAC;AAED,YAAQ,MAAM,KAAK,SAAS,MAAM,MAAM,sBAAsB,SAAS,EAAE;AAEzE,UAAM,gBAA+B,EAAE,OAAO,CAAC,EAAE;AACjD,UAAM,QAAQ,CAAC,SAAuB;AACrC,YAAM,SAAS,KAAK,KAAK,SAAS,KAAK,KAAK;AAC5C,oBAAc,MAAM,MAAM,IAAI;AAAA,QAC7B,MAAM,KAAK;AAAA,QACX,SAAS,KAAK;AAAA,QACd,WAAW,KAAK;AAAA,QAChB,UAAU,KAAK;AAAA,MAChB;AAAA,IACD,CAAC;AAED,WAAO;AAAA,EACR;AAAA,EAEA,MAAa,qBACZ,WACA,MACgB;AAChB,YAAQ,MAAM,KAAK,wCAAwC,SAAS,EAAE;AACtE,YAAQ,MAAM,KAAK,SAAS,KAAK,UAAU,IAAI,CAAC,EAAE;AAElD,UAAM,UAAU,OAAO;AAAA,MACtB;AAAA,MACA,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,WAAW,KAAK;AAAA,MAChB,UAAU,KAAK;AAAA,IAChB,CAAC;AAAA,EACF;AAAA,EAEA,MAAa,oBACZ,OACA,QACA,WACgB;AAEhB,UAAM,OAAmB;AAAA,MACxB;AAAA,MACA,SAAS;AAAA,QACR,MAAM;AAAA,QACN,OAAO,CAAC,KAAK;AAAA,MACd;AAAA,MACA,WAAW,KAAK,IAAI;AAAA,MACpB,UAAU;AAAA,QACT;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAEA,UAAM,KAAK,qBAAqB,WAAW,IAAI;AAAA,EAChD;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../implements/session.memory.ts","../implements/base.memory.ts","../implements/intent.memory.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { ChatObject, SessionMetadata, SessionObject } from \"@ainetwork/adk/types/memory\";\nimport { ISessionMemory } from \"@ainetwork/adk/modules\";\nimport { MongoDBMemory } from \"./base.memory\";\nimport {\n\tChatDocument,\n\tChatRole,\n ChatObjectSchema,\n SessionObjectSchema,\n SessionDocument\n} from \"../models/chats.model\";\nimport { loggers } from \"@ainetwork/adk/utils/logger\";\nimport { Model } from \"mongoose\";\n\nexport class MongoDBSession extends MongoDBMemory implements ISessionMemory {\n private chatModel: Model<ChatDocument>;\n private sessionModel: Model<SessionDocument>;\n\n constructor(uri: string) {\n super(uri);\n const _mongoose = super.getInstance();\n this.chatModel = _mongoose.model<ChatDocument>(\"Chat\", ChatObjectSchema);\n this.sessionModel = _mongoose.model<SessionDocument>(\"Session\", SessionObjectSchema);\n }\n\n public async getSession(sessionId: string, userId?: string): Promise<SessionObject | undefined> {\n\t\tconst chats = await this.chatModel.find({ sessionId }).sort({\n\t\t\ttimestamp: 1,\n\t\t});\n\n\t\tloggers.agent.debug(`Found ${chats.length} chats for session ${sessionId}`);\n\n\t\tconst sessionObject: SessionObject = { chats: {} };\n\t\tchats.forEach((chat: ChatDocument) => {\n\t\t\tconst chatId = chat._id?.toString() || chat.id;\n\t\t\tsessionObject.chats[chatId] = {\n\t\t\t\trole: chat.role as ChatRole,\n\t\t\t\tcontent: chat.content,\n\t\t\t\ttimestamp: chat.timestamp,\n\t\t\t\tmetadata: chat.metadata,\n\t\t\t};\n\t\t});\n\n\t\treturn sessionObject;\n };\n\n\tpublic async createSession(userId: string, sessionId: string): Promise<void> {\n await this.sessionModel.create({\n sessionId,\n userId,\n updated_at: Date.now(),\n created_at: Date.now(),\n });\n };\n\n\tpublic async addChatToSession(userId: string, sessionId: string, chat: ChatObject): Promise<void> {\n const newId = randomUUID();\n const session = await this.sessionModel.findOne({ sessionId, userId });\n if (!session) {\n await this.createSession(userId, sessionId);\n } else {\n await this.sessionModel.updateOne({ sessionId, userId }, {\n updated_at: Date.now(),\n });\n }\n\t\tawait this.chatModel.create({\n\t\t\tsessionId,\n chatId: newId,\n userId,\n\t\t\trole: chat.role,\n\t\t\tcontent: chat.content,\n\t\t\ttimestamp: chat.timestamp,\n\t\t\tmetadata: chat.metadata,\n\t\t});\n };\n\n\tpublic async deleteSession(userId: string, sessionId: string): Promise<void> {\n\t\tconst chats = await this.chatModel.find({ userId, sessionId }).sort({\n\t\t\ttimestamp: 1,\n\t\t});\n\n\t\tchats?.forEach((chat: ChatDocument) => {\n chat.deleteOne();\n\t\t});\n \n const session = await this.sessionModel.findOne({ sessionId, userId });\n session?.deleteOne();\n };\n\n\tpublic async listSessions(userId: string): Promise<SessionMetadata[]> {\n const sessions = await this.sessionModel.find({ userId }).sort({\n updated_at: -1,\n });\n const data: SessionMetadata[] = sessions.map((session: SessionDocument) => {\n return {\n sessionId: session.sessionId,\n title: session.title,\n updatedAt: session.updated_at\n } as SessionMetadata;\n })\n return data;\n };\n}","import { IMemory } from \"node_modules/@ainetwork/adk/dist/esm/modules/memory/base.memory\";\nimport mongoose, { Mongoose } from \"mongoose\";\nimport { loggers } from \"@ainetwork/adk/utils/logger\";\n\nexport class MongoDBMemory implements IMemory {\n private _isConnected: boolean = false;\n private _uri: string;\n private _mongoose: Mongoose;\n\n constructor(uri: string) {\n this._uri = uri;\n this._mongoose = new Mongoose();\n }\n\n public getInstance(): Mongoose {\n return this._mongoose;\n }\n\n public async connect(): Promise<void> {\n\t\tif (this._isConnected) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n await this._mongoose.connect(this._uri);\n\t\t\tthis._isConnected = true;\n\t\t\tloggers.agent.info(\"MongoDB connected successfully\");\n\t\t} catch (error) {\n\t\t\tloggers.agent.error(\"Failed to connect to MongoDB:\", error);\n\t\t\tthrow error;\n\t\t}\n }\n\n public async disconnect(): Promise<void> {\n\t\tif (!this.isConnected) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait this._mongoose?.disconnect();\n\t\t\tthis._isConnected = false;\n\t\t\tloggers.agent.info(\"MongoDB disconnected successfully\");\n\t\t} catch (error) {\n\t\t\tloggers.agent.error(\"Failed to disconnect from MongoDB:\", error);\n\t\t\tthrow error;\n\t\t}\n }\n\n public isConnected(): boolean {\n return this._isConnected;\n }\n}","import { randomUUID } from \"node:crypto\";\nimport type { Intent } from \"@ainetwork/adk/types/memory\";\nimport { IIntentMemory } from \"@ainetwork/adk/modules\";\nimport { MongoDBMemory } from \"./base.memory\";\nimport { IntentModel } from \"../models/intent.model\";\n\nexport class MongoDBIntent extends MongoDBMemory implements IIntentMemory {\n public async getIntent(intentId: string): Promise<Intent | undefined> {\n const intent = await IntentModel.findById(intentId);\n if (intent) {\n return {\n name: intent.name,\n description: intent.description,\n prompt: intent.prompt,\n llm: intent.llm,\n } as Intent;\n }\n return undefined;\n };\n\n\tpublic async saveIntent(intent: Intent): Promise<void> {\n const newId = randomUUID();\n await IntentModel.create({\n _id: newId,\n name: intent.name,\n description: intent.description,\n prompt: intent.prompt,\n llm: intent.llm,\n });\n };\n\n\tpublic async updateIntent(intentId: string, intent: Intent): Promise<void> {\n await IntentModel.updateOne({\n _id: intentId,\n },{\n name: intent.name,\n description: intent.description,\n prompt: intent.prompt,\n llm: intent.llm,\n });\n };\n\n\tpublic async deleteIntent(intentId: string): Promise<void> {\n await IntentModel.deleteOne({ _id: intentId });\n };\n\n\tpublic async listIntents(): Promise<Intent[]> {\n const intents = await IntentModel.find();\n return intents.map(intent => ({\n name: intent.name,\n description: intent.description,\n prompt: intent.prompt,\n llm: intent.llm,\n } as Intent));\n };\n}"],"mappings":";;;;;;;;;AAAA,SAAS,kBAAkB;;;ACC3B,SAAmB,gBAAgB;AACnC,SAAS,eAAe;AAEjB,IAAM,gBAAN,MAAuC;AAAA,EACpC,eAAwB;AAAA,EACxB;AAAA,EACA;AAAA,EAER,YAAY,KAAa;AACvB,SAAK,OAAO;AACZ,SAAK,YAAY,IAAI,SAAS;AAAA,EAChC;AAAA,EAEO,cAAwB;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,UAAyB;AACtC,QAAI,KAAK,cAAc;AAC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AAA,IACd,EAAY;AAAA,EACd;AACF;","names":["loggers","randomUUID","randomUUID"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,30 +15,50 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// models/chats.model.ts
|
|
31
21
|
var chats_model_exports = {};
|
|
32
22
|
__export(chats_model_exports, {
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
ChatContentObjectSchema: () => ChatContentObjectSchema,
|
|
24
|
+
ChatObjectSchema: () => ChatObjectSchema,
|
|
25
|
+
ChatRole: () => ChatRole,
|
|
26
|
+
SessionObjectSchema: () => SessionObjectSchema
|
|
35
27
|
});
|
|
36
28
|
module.exports = __toCommonJS(chats_model_exports);
|
|
37
|
-
var import_mongoose =
|
|
29
|
+
var import_mongoose = require("mongoose");
|
|
38
30
|
var ChatRole = /* @__PURE__ */ ((ChatRole2) => {
|
|
39
31
|
ChatRole2["USER"] = "USER";
|
|
40
32
|
ChatRole2["SYSTEM"] = "SYSTEM";
|
|
41
33
|
ChatRole2["MODEL"] = "MODEL";
|
|
42
34
|
return ChatRole2;
|
|
43
35
|
})(ChatRole || {});
|
|
36
|
+
var SessionObjectSchema = new import_mongoose.Schema(
|
|
37
|
+
{
|
|
38
|
+
sessionId: {
|
|
39
|
+
type: String,
|
|
40
|
+
required: true,
|
|
41
|
+
index: true
|
|
42
|
+
},
|
|
43
|
+
userId: {
|
|
44
|
+
type: String,
|
|
45
|
+
required: true,
|
|
46
|
+
index: true
|
|
47
|
+
},
|
|
48
|
+
title: {
|
|
49
|
+
type: String,
|
|
50
|
+
required: false
|
|
51
|
+
},
|
|
52
|
+
created_at: {
|
|
53
|
+
type: Number,
|
|
54
|
+
required: true
|
|
55
|
+
},
|
|
56
|
+
updated_at: {
|
|
57
|
+
type: Number,
|
|
58
|
+
required: true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
);
|
|
44
62
|
var ChatContentObjectSchema = new import_mongoose.Schema(
|
|
45
63
|
{
|
|
46
64
|
type: { type: String, required: true },
|
|
@@ -72,15 +90,13 @@ var ChatObjectSchema = new import_mongoose.Schema(
|
|
|
72
90
|
type: import_mongoose.Schema.Types.Mixed,
|
|
73
91
|
default: {}
|
|
74
92
|
}
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
timestamps: true
|
|
78
93
|
}
|
|
79
94
|
);
|
|
80
|
-
var ChatModel = import_mongoose.default.model("Chat", ChatObjectSchema);
|
|
81
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
82
96
|
0 && (module.exports = {
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
ChatContentObjectSchema,
|
|
98
|
+
ChatObjectSchema,
|
|
99
|
+
ChatRole,
|
|
100
|
+
SessionObjectSchema
|
|
85
101
|
});
|
|
86
102
|
//# sourceMappingURL=chats.model.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../models/chats.model.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../models/chats.model.ts"],"sourcesContent":["import { type Document, Schema } from \"mongoose\";\n\n// ChatRole enum\nexport enum ChatRole {\n\tUSER = \"USER\",\n\tSYSTEM = \"SYSTEM\",\n\tMODEL = \"MODEL\",\n}\n\nexport const SessionObjectSchema = new Schema(\n\t{\n\t\tsessionId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: false,\n\t\t},\n\t\tcreated_at: {\n\t\t\ttype: Number,\n\t\t\trequired: true,\n\t\t},\n\t\tupdated_at: {\n\t\t\ttype: Number,\n\t\t\trequired: true,\n\t\t}\n\t},\n);\n\nexport interface SessionDocument extends Document {\n\tsessionId: string;\n\tuserId: string;\n\ttitle?: string;\n\tcreated_at: number;\n\tupdated_at: number;\n}\n\n// ChatContentObject schema\nexport const ChatContentObjectSchema = new Schema(\n\t{\n\t\ttype: { type: String, required: true },\n\t\tparts: { type: [Schema.Types.Mixed], required: true },\n\t},\n\t{ _id: false },\n);\n\n// ChatObject schema - 개별 문서로 저장\nexport const ChatObjectSchema = new Schema(\n\t{\n\t\tsessionId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\trole: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(ChatRole),\n\t\t\trequired: true,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: ChatContentObjectSchema,\n\t\t\trequired: true,\n\t\t},\n\t\ttimestamp: {\n\t\t\ttype: Number,\n\t\t\trequired: true,\n\t\t},\n\t\tmetadata: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t\tdefault: {},\n\t\t},\n\t},\n);\n\n// Chat Document interface\nexport interface ChatDocument extends Document {\n\tsessionId: string;\n\trole: ChatRole;\n\tcontent: {\n\t\ttype: string;\n\t\tparts: any[];\n\t};\n\ttimestamp: number;\n\tmetadata?: { [key: string]: unknown };\n\tcreatedAt: Date;\n\tupdatedAt: Date;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAsC;AAG/B,IAAK,WAAL,kBAAKA,cAAL;AACN,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AAHG,SAAAA;AAAA,GAAA;AAML,IAAM,sBAAsB,IAAI;AAAA,EACtC;AAAA,IACC,WAAW;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;AAWO,IAAM,0BAA0B,IAAI;AAAA,EAC1C;AAAA,IACC,MAAM,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACrC,OAAO,EAAE,MAAM,CAAC,uBAAO,MAAM,KAAK,GAAG,UAAU,KAAK;AAAA,EACrD;AAAA,EACA,EAAE,KAAK,MAAM;AACd;AAGO,IAAM,mBAAmB,IAAI;AAAA,EACnC;AAAA,IACC,WAAW;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,MAAM;AAAA,MACL,MAAM;AAAA,MACN,MAAM,OAAO,OAAO,QAAQ;AAAA,MAC5B,UAAU;AAAA,IACX;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,UAAU;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,SAAS,CAAC;AAAA,IACX;AAAA,EACD;AACD;","names":["ChatRole"]}
|
|
@@ -1,10 +1,89 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as mongoose from 'mongoose';
|
|
2
|
+
import { Schema, Document } from 'mongoose';
|
|
2
3
|
|
|
3
4
|
declare enum ChatRole {
|
|
4
5
|
USER = "USER",
|
|
5
6
|
SYSTEM = "SYSTEM",
|
|
6
7
|
MODEL = "MODEL"
|
|
7
8
|
}
|
|
9
|
+
declare const SessionObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
10
|
+
sessionId: string;
|
|
11
|
+
userId: string;
|
|
12
|
+
created_at: number;
|
|
13
|
+
updated_at: number;
|
|
14
|
+
title?: string | null | undefined;
|
|
15
|
+
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
16
|
+
sessionId: string;
|
|
17
|
+
userId: string;
|
|
18
|
+
created_at: number;
|
|
19
|
+
updated_at: number;
|
|
20
|
+
title?: string | null | undefined;
|
|
21
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
22
|
+
sessionId: string;
|
|
23
|
+
userId: string;
|
|
24
|
+
created_at: number;
|
|
25
|
+
updated_at: number;
|
|
26
|
+
title?: string | null | undefined;
|
|
27
|
+
}> & {
|
|
28
|
+
_id: mongoose.Types.ObjectId;
|
|
29
|
+
} & {
|
|
30
|
+
__v: number;
|
|
31
|
+
}>;
|
|
32
|
+
interface SessionDocument extends Document {
|
|
33
|
+
sessionId: string;
|
|
34
|
+
userId: string;
|
|
35
|
+
title?: string;
|
|
36
|
+
created_at: number;
|
|
37
|
+
updated_at: number;
|
|
38
|
+
}
|
|
39
|
+
declare const ChatContentObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
40
|
+
_id: false;
|
|
41
|
+
}, {
|
|
42
|
+
type: string;
|
|
43
|
+
parts: any[];
|
|
44
|
+
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
45
|
+
type: string;
|
|
46
|
+
parts: any[];
|
|
47
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
48
|
+
type: string;
|
|
49
|
+
parts: any[];
|
|
50
|
+
}> & {
|
|
51
|
+
_id: mongoose.Types.ObjectId;
|
|
52
|
+
} & {
|
|
53
|
+
__v: number;
|
|
54
|
+
}>;
|
|
55
|
+
declare const ChatObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
56
|
+
sessionId: string;
|
|
57
|
+
role: ChatRole;
|
|
58
|
+
content: {
|
|
59
|
+
type: string;
|
|
60
|
+
parts: any[];
|
|
61
|
+
};
|
|
62
|
+
timestamp: number;
|
|
63
|
+
metadata: any;
|
|
64
|
+
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
65
|
+
sessionId: string;
|
|
66
|
+
role: ChatRole;
|
|
67
|
+
content: {
|
|
68
|
+
type: string;
|
|
69
|
+
parts: any[];
|
|
70
|
+
};
|
|
71
|
+
timestamp: number;
|
|
72
|
+
metadata: any;
|
|
73
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
74
|
+
sessionId: string;
|
|
75
|
+
role: ChatRole;
|
|
76
|
+
content: {
|
|
77
|
+
type: string;
|
|
78
|
+
parts: any[];
|
|
79
|
+
};
|
|
80
|
+
timestamp: number;
|
|
81
|
+
metadata: any;
|
|
82
|
+
}> & {
|
|
83
|
+
_id: mongoose.Types.ObjectId;
|
|
84
|
+
} & {
|
|
85
|
+
__v: number;
|
|
86
|
+
}>;
|
|
8
87
|
interface ChatDocument extends Document {
|
|
9
88
|
sessionId: string;
|
|
10
89
|
role: ChatRole;
|
|
@@ -19,10 +98,5 @@ interface ChatDocument extends Document {
|
|
|
19
98
|
createdAt: Date;
|
|
20
99
|
updatedAt: Date;
|
|
21
100
|
}
|
|
22
|
-
declare const ChatModel: mongoose.Model<ChatDocument, {}, {}, {}, mongoose.Document<unknown, {}, ChatDocument, {}> & ChatDocument & Required<{
|
|
23
|
-
_id: unknown;
|
|
24
|
-
}> & {
|
|
25
|
-
__v: number;
|
|
26
|
-
}, any>;
|
|
27
101
|
|
|
28
|
-
export { type ChatDocument,
|
|
102
|
+
export { ChatContentObjectSchema, type ChatDocument, ChatObjectSchema, ChatRole, type SessionDocument, SessionObjectSchema };
|
|
@@ -1,10 +1,89 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as mongoose from 'mongoose';
|
|
2
|
+
import { Schema, Document } from 'mongoose';
|
|
2
3
|
|
|
3
4
|
declare enum ChatRole {
|
|
4
5
|
USER = "USER",
|
|
5
6
|
SYSTEM = "SYSTEM",
|
|
6
7
|
MODEL = "MODEL"
|
|
7
8
|
}
|
|
9
|
+
declare const SessionObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
10
|
+
sessionId: string;
|
|
11
|
+
userId: string;
|
|
12
|
+
created_at: number;
|
|
13
|
+
updated_at: number;
|
|
14
|
+
title?: string | null | undefined;
|
|
15
|
+
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
16
|
+
sessionId: string;
|
|
17
|
+
userId: string;
|
|
18
|
+
created_at: number;
|
|
19
|
+
updated_at: number;
|
|
20
|
+
title?: string | null | undefined;
|
|
21
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
22
|
+
sessionId: string;
|
|
23
|
+
userId: string;
|
|
24
|
+
created_at: number;
|
|
25
|
+
updated_at: number;
|
|
26
|
+
title?: string | null | undefined;
|
|
27
|
+
}> & {
|
|
28
|
+
_id: mongoose.Types.ObjectId;
|
|
29
|
+
} & {
|
|
30
|
+
__v: number;
|
|
31
|
+
}>;
|
|
32
|
+
interface SessionDocument extends Document {
|
|
33
|
+
sessionId: string;
|
|
34
|
+
userId: string;
|
|
35
|
+
title?: string;
|
|
36
|
+
created_at: number;
|
|
37
|
+
updated_at: number;
|
|
38
|
+
}
|
|
39
|
+
declare const ChatContentObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
40
|
+
_id: false;
|
|
41
|
+
}, {
|
|
42
|
+
type: string;
|
|
43
|
+
parts: any[];
|
|
44
|
+
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
45
|
+
type: string;
|
|
46
|
+
parts: any[];
|
|
47
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
48
|
+
type: string;
|
|
49
|
+
parts: any[];
|
|
50
|
+
}> & {
|
|
51
|
+
_id: mongoose.Types.ObjectId;
|
|
52
|
+
} & {
|
|
53
|
+
__v: number;
|
|
54
|
+
}>;
|
|
55
|
+
declare const ChatObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
56
|
+
sessionId: string;
|
|
57
|
+
role: ChatRole;
|
|
58
|
+
content: {
|
|
59
|
+
type: string;
|
|
60
|
+
parts: any[];
|
|
61
|
+
};
|
|
62
|
+
timestamp: number;
|
|
63
|
+
metadata: any;
|
|
64
|
+
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
65
|
+
sessionId: string;
|
|
66
|
+
role: ChatRole;
|
|
67
|
+
content: {
|
|
68
|
+
type: string;
|
|
69
|
+
parts: any[];
|
|
70
|
+
};
|
|
71
|
+
timestamp: number;
|
|
72
|
+
metadata: any;
|
|
73
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
74
|
+
sessionId: string;
|
|
75
|
+
role: ChatRole;
|
|
76
|
+
content: {
|
|
77
|
+
type: string;
|
|
78
|
+
parts: any[];
|
|
79
|
+
};
|
|
80
|
+
timestamp: number;
|
|
81
|
+
metadata: any;
|
|
82
|
+
}> & {
|
|
83
|
+
_id: mongoose.Types.ObjectId;
|
|
84
|
+
} & {
|
|
85
|
+
__v: number;
|
|
86
|
+
}>;
|
|
8
87
|
interface ChatDocument extends Document {
|
|
9
88
|
sessionId: string;
|
|
10
89
|
role: ChatRole;
|
|
@@ -19,10 +98,5 @@ interface ChatDocument extends Document {
|
|
|
19
98
|
createdAt: Date;
|
|
20
99
|
updatedAt: Date;
|
|
21
100
|
}
|
|
22
|
-
declare const ChatModel: mongoose.Model<ChatDocument, {}, {}, {}, mongoose.Document<unknown, {}, ChatDocument, {}> & ChatDocument & Required<{
|
|
23
|
-
_id: unknown;
|
|
24
|
-
}> & {
|
|
25
|
-
__v: number;
|
|
26
|
-
}, any>;
|
|
27
101
|
|
|
28
|
-
export { type ChatDocument,
|
|
102
|
+
export { ChatContentObjectSchema, type ChatDocument, ChatObjectSchema, ChatRole, type SessionDocument, SessionObjectSchema };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
ChatContentObjectSchema,
|
|
3
|
+
ChatObjectSchema,
|
|
4
|
+
ChatRole,
|
|
5
|
+
SessionObjectSchema
|
|
6
|
+
} from "../chunk-SS7OXU6N.js";
|
|
5
7
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
ChatContentObjectSchema,
|
|
9
|
+
ChatObjectSchema,
|
|
10
|
+
ChatRole,
|
|
11
|
+
SessionObjectSchema
|
|
8
12
|
};
|
|
9
13
|
//# sourceMappingURL=chats.model.js.map
|
|
@@ -27,43 +27,37 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// models/
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
|
|
30
|
+
// models/intent.model.ts
|
|
31
|
+
var intent_model_exports = {};
|
|
32
|
+
__export(intent_model_exports, {
|
|
33
|
+
IntentModel: () => IntentModel
|
|
34
34
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(intent_model_exports);
|
|
36
36
|
var import_mongoose = __toESM(require("mongoose"), 1);
|
|
37
|
-
var
|
|
37
|
+
var IntentObjectSchema = new import_mongoose.Schema(
|
|
38
38
|
{
|
|
39
|
-
|
|
39
|
+
name: {
|
|
40
40
|
type: String,
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
required: true,
|
|
42
|
+
index: true
|
|
43
43
|
},
|
|
44
|
-
|
|
45
|
-
type:
|
|
46
|
-
// string 또는 object array
|
|
44
|
+
description: {
|
|
45
|
+
type: String,
|
|
47
46
|
required: true
|
|
47
|
+
},
|
|
48
|
+
prompt: {
|
|
49
|
+
type: String,
|
|
50
|
+
required: false
|
|
51
|
+
},
|
|
52
|
+
llm: {
|
|
53
|
+
type: String,
|
|
54
|
+
required: false
|
|
48
55
|
}
|
|
49
|
-
},
|
|
50
|
-
{ _id: false }
|
|
51
|
-
);
|
|
52
|
-
var IntentTriggeringInfoSchema = new import_mongoose.Schema({
|
|
53
|
-
context: {
|
|
54
|
-
messages: [MessageSchema]
|
|
55
|
-
},
|
|
56
|
-
intent: {
|
|
57
|
-
name: { type: String, required: true },
|
|
58
|
-
description: { type: String, required: true }
|
|
59
56
|
}
|
|
60
|
-
});
|
|
61
|
-
var IntentTriggeringInfoModel = import_mongoose.default.model(
|
|
62
|
-
"IntentTriggeringInfo",
|
|
63
|
-
IntentTriggeringInfoSchema
|
|
64
57
|
);
|
|
58
|
+
var IntentModel = import_mongoose.default.model("Intent", IntentObjectSchema);
|
|
65
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
66
60
|
0 && (module.exports = {
|
|
67
|
-
|
|
61
|
+
IntentModel
|
|
68
62
|
});
|
|
69
|
-
//# sourceMappingURL=
|
|
63
|
+
//# sourceMappingURL=intent.model.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../models/intent.model.ts"],"sourcesContent":["import mongoose, { type Document, Schema } from \"mongoose\";\n\nconst IntentObjectSchema = new Schema(\n\t{\n\t\tname: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tprompt: {\n\t\t\ttype: String,\n\t\t\trequired: false,\n\t\t},\n\t\tllm: {\n\t\t\ttype: String,\n\t\t\trequired: false,\n\t\t},\n\t}\n);\n\nexport interface IntentDocument extends Document {\n\tname: string;\n\tdescription: string;\n\tprompt?: string;\n\tllm?: string;\n}\n\nexport const IntentModel = mongoose.model<IntentDocument>(\"Intent\", IntentObjectSchema);"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAgD;AAEhD,IAAM,qBAAqB,IAAI;AAAA,EAC9B;AAAA,IACC,MAAM;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,aAAa;AAAA,MACZ,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,KAAK;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;AASO,IAAM,cAAc,gBAAAA,QAAS,MAAsB,UAAU,kBAAkB;","names":["mongoose"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import mongoose__default, { Document } from 'mongoose';
|
|
2
|
+
|
|
3
|
+
interface IntentDocument extends Document {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
prompt?: string;
|
|
7
|
+
llm?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const IntentModel: mongoose__default.Model<IntentDocument, {}, {}, {}, mongoose__default.Document<unknown, {}, IntentDocument, {}> & IntentDocument & Required<{
|
|
10
|
+
_id: unknown;
|
|
11
|
+
}> & {
|
|
12
|
+
__v: number;
|
|
13
|
+
}, any>;
|
|
14
|
+
|
|
15
|
+
export { type IntentDocument, IntentModel };
|