@ainetwork/adk-provider-memory-mongodb 0.1.2 → 0.1.4

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.
@@ -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 };
@@ -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 };
@@ -0,0 +1,7 @@
1
+ import {
2
+ IntentModel
3
+ } from "../chunk-JCE5NAY5.js";
4
+ export {
5
+ IntentModel
6
+ };
7
+ //# sourceMappingURL=intent.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -24,7 +24,7 @@ export class MongoDBSession extends MongoDBMemory implements ISessionMemory {
24
24
  }
25
25
 
26
26
  public async getSession(sessionId: string, userId?: string): Promise<SessionObject | undefined> {
27
- const chats = await this.chatModel.find({ sessionId }).sort({
27
+ const chats = await this.chatModel.find({ sessionId, userId }).sort({
28
28
  timestamp: 1,
29
29
  });
30
30
 
@@ -44,25 +44,23 @@ export class MongoDBSession extends MongoDBMemory implements ISessionMemory {
44
44
  return sessionObject;
45
45
  };
46
46
 
47
- public async createSession(userId: string, sessionId: string): Promise<void> {
47
+ public async createSession(userId: string, sessionId: string, title: string): Promise<SessionMetadata> {
48
+ const now = Date.now();
48
49
  await this.sessionModel.create({
49
50
  sessionId,
50
51
  userId,
51
- updated_at: Date.now(),
52
- created_at: Date.now(),
52
+ updated_at: now,
53
+ created_at: now,
53
54
  });
55
+
56
+ return { title, sessionId, updatedAt: now };
54
57
  };
55
58
 
56
59
  public async addChatToSession(userId: string, sessionId: string, chat: ChatObject): Promise<void> {
57
60
  const newId = randomUUID();
58
- const session = await this.sessionModel.findOne({ sessionId, userId });
59
- if (!session) {
60
- await this.createSession(userId, sessionId);
61
- } else {
62
- await this.sessionModel.updateOne({ sessionId, userId }, {
63
- updated_at: Date.now(),
64
- });
65
- }
61
+ await this.sessionModel.updateOne({ sessionId, userId }, {
62
+ updated_at: Date.now(),
63
+ });
66
64
  await this.chatModel.create({
67
65
  sessionId,
68
66
  chatId: newId,
@@ -59,6 +59,11 @@ export const ChatObjectSchema = new Schema(
59
59
  required: true,
60
60
  index: true,
61
61
  },
62
+ userId: {
63
+ type: String,
64
+ required: true,
65
+ index: true,
66
+ },
62
67
  role: {
63
68
  type: String,
64
69
  enum: Object.values(ChatRole),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ainetwork/adk-provider-memory-mongodb",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "author": "AI Network (https://ainetwork.ai)",
5
5
  "type": "module",
6
6
  "engines": {
@@ -26,7 +26,7 @@
26
26
  "clean": "rm -rf dist"
27
27
  },
28
28
  "dependencies": {
29
- "@ainetwork/adk": "^0.1.7",
29
+ "@ainetwork/adk": "^0.1.9",
30
30
  "mongoose": "^8.16.5"
31
31
  },
32
32
  "devDependencies": {
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "4098aacea7a18099aa020ef5d331cdce0d59c3f3"
39
+ "gitHead": "66a5fbc5f9a509bd412ff8dc91b002862133fbae"
40
40
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../models/chats.model.ts"],"sourcesContent":["import mongoose, { type Document, Schema } from \"mongoose\";\n\n// ChatRole enum\nexport enum ChatRole {\n\tUSER = \"USER\",\n\tSYSTEM = \"SYSTEM\",\n\tMODEL = \"MODEL\",\n}\n\n// ChatContentObject schema\nconst 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 - 개별 문서로 저장\nconst 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\t{\n\t\ttimestamps: true,\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\n// Export the model\nexport const ChatModel = mongoose.model<ChatDocument>(\"Chat\", ChatObjectSchema);\n"],"mappings":";AAAA,OAAO,YAA2B,cAAc;AAGzC,IAAK,WAAL,kBAAKA,cAAL;AACN,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AAHG,SAAAA;AAAA,GAAA;AAOZ,IAAM,0BAA0B,IAAI;AAAA,EACnC;AAAA,IACC,MAAM,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACrC,OAAO,EAAE,MAAM,CAAC,OAAO,MAAM,KAAK,GAAG,UAAU,KAAK;AAAA,EACrD;AAAA,EACA,EAAE,KAAK,MAAM;AACd;AAGA,IAAM,mBAAmB,IAAI;AAAA,EAC5B;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,OAAO,MAAM;AAAA,MACnB,SAAS,CAAC;AAAA,IACX;AAAA,EACD;AAAA,EACA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AAiBO,IAAM,YAAY,SAAS,MAAoB,QAAQ,gBAAgB;","names":["ChatRole"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../models/intentTriggeringInfos.model.ts"],"sourcesContent":["import mongoose, { type Document, Schema } from \"mongoose\";\n\nconst MessageSchema = new Schema(\n\t{\n\t\trole: {\n\t\t\ttype: String,\n\t\t\tenum: [\"system\", \"user\", \"assistant\", \"tool\", \"function\"],\n\t\t\trequired: true,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: Schema.Types.Mixed, // string 또는 object array\n\t\t\trequired: true,\n\t\t},\n\t},\n\t{ _id: false },\n);\n\nexport interface IntentTriggeringInfoDocument extends Document {\n\tcontext: {\n\t\tmessages: Array<{\n\t\t\trole: string;\n\t\t\tcontent:\n\t\t\t\t| string\n\t\t\t\t| Array<\n\t\t\t\t\t\t| { type: \"text\"; text: string }\n\t\t\t\t\t\t| { type: \"image_url\"; image_url: { url: string } }\n\t\t\t\t >;\n\t\t}>;\n\t};\n\tintent: {\n\t\tname: string;\n\t\tdescription: string;\n\t};\n}\n\nconst IntentTriggeringInfoSchema = new Schema<IntentTriggeringInfoDocument>({\n\tcontext: {\n\t\tmessages: [MessageSchema],\n\t},\n\tintent: {\n\t\tname: { type: String, required: true },\n\t\tdescription: { type: String, required: true },\n\t},\n});\n\nexport const IntentTriggeringInfoModel =\n\tmongoose.model<IntentTriggeringInfoDocument>(\n\t\t\"IntentTriggeringInfo\",\n\t\tIntentTriggeringInfoSchema,\n\t);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAgD;AAEhD,IAAM,gBAAgB,IAAI;AAAA,EACzB;AAAA,IACC,MAAM;AAAA,MACL,MAAM;AAAA,MACN,MAAM,CAAC,UAAU,QAAQ,aAAa,QAAQ,UAAU;AAAA,MACxD,UAAU;AAAA,IACX;AAAA,IACA,SAAS;AAAA,MACR,MAAM,uBAAO,MAAM;AAAA;AAAA,MACnB,UAAU;AAAA,IACX;AAAA,EACD;AAAA,EACA,EAAE,KAAK,MAAM;AACd;AAoBA,IAAM,6BAA6B,IAAI,uBAAqC;AAAA,EAC3E,SAAS;AAAA,IACR,UAAU,CAAC,aAAa;AAAA,EACzB;AAAA,EACA,QAAQ;AAAA,IACP,MAAM,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACrC,aAAa,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,EAC7C;AACD,CAAC;AAEM,IAAM,4BACZ,gBAAAA,QAAS;AAAA,EACR;AAAA,EACA;AACD;","names":["mongoose"]}
@@ -1,29 +0,0 @@
1
- import mongoose, { Document } from 'mongoose';
2
-
3
- interface IntentTriggeringInfoDocument extends Document {
4
- context: {
5
- messages: Array<{
6
- role: string;
7
- content: string | Array<{
8
- type: "text";
9
- text: string;
10
- } | {
11
- type: "image_url";
12
- image_url: {
13
- url: string;
14
- };
15
- }>;
16
- }>;
17
- };
18
- intent: {
19
- name: string;
20
- description: string;
21
- };
22
- }
23
- declare const IntentTriggeringInfoModel: mongoose.Model<IntentTriggeringInfoDocument, {}, {}, {}, mongoose.Document<unknown, {}, IntentTriggeringInfoDocument, {}> & IntentTriggeringInfoDocument & Required<{
24
- _id: unknown;
25
- }> & {
26
- __v: number;
27
- }, any>;
28
-
29
- export { type IntentTriggeringInfoDocument, IntentTriggeringInfoModel };
@@ -1,29 +0,0 @@
1
- import mongoose, { Document } from 'mongoose';
2
-
3
- interface IntentTriggeringInfoDocument extends Document {
4
- context: {
5
- messages: Array<{
6
- role: string;
7
- content: string | Array<{
8
- type: "text";
9
- text: string;
10
- } | {
11
- type: "image_url";
12
- image_url: {
13
- url: string;
14
- };
15
- }>;
16
- }>;
17
- };
18
- intent: {
19
- name: string;
20
- description: string;
21
- };
22
- }
23
- declare const IntentTriggeringInfoModel: mongoose.Model<IntentTriggeringInfoDocument, {}, {}, {}, mongoose.Document<unknown, {}, IntentTriggeringInfoDocument, {}> & IntentTriggeringInfoDocument & Required<{
24
- _id: unknown;
25
- }> & {
26
- __v: number;
27
- }, any>;
28
-
29
- export { type IntentTriggeringInfoDocument, IntentTriggeringInfoModel };
@@ -1,34 +0,0 @@
1
- // models/intentTriggeringInfos.model.ts
2
- import mongoose, { Schema } from "mongoose";
3
- var MessageSchema = new Schema(
4
- {
5
- role: {
6
- type: String,
7
- enum: ["system", "user", "assistant", "tool", "function"],
8
- required: true
9
- },
10
- content: {
11
- type: Schema.Types.Mixed,
12
- // string 또는 object array
13
- required: true
14
- }
15
- },
16
- { _id: false }
17
- );
18
- var IntentTriggeringInfoSchema = new Schema({
19
- context: {
20
- messages: [MessageSchema]
21
- },
22
- intent: {
23
- name: { type: String, required: true },
24
- description: { type: String, required: true }
25
- }
26
- });
27
- var IntentTriggeringInfoModel = mongoose.model(
28
- "IntentTriggeringInfo",
29
- IntentTriggeringInfoSchema
30
- );
31
- export {
32
- IntentTriggeringInfoModel
33
- };
34
- //# sourceMappingURL=intentTriggeringInfos.model.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../models/intentTriggeringInfos.model.ts"],"sourcesContent":["import mongoose, { type Document, Schema } from \"mongoose\";\n\nconst MessageSchema = new Schema(\n\t{\n\t\trole: {\n\t\t\ttype: String,\n\t\t\tenum: [\"system\", \"user\", \"assistant\", \"tool\", \"function\"],\n\t\t\trequired: true,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: Schema.Types.Mixed, // string 또는 object array\n\t\t\trequired: true,\n\t\t},\n\t},\n\t{ _id: false },\n);\n\nexport interface IntentTriggeringInfoDocument extends Document {\n\tcontext: {\n\t\tmessages: Array<{\n\t\t\trole: string;\n\t\t\tcontent:\n\t\t\t\t| string\n\t\t\t\t| Array<\n\t\t\t\t\t\t| { type: \"text\"; text: string }\n\t\t\t\t\t\t| { type: \"image_url\"; image_url: { url: string } }\n\t\t\t\t >;\n\t\t}>;\n\t};\n\tintent: {\n\t\tname: string;\n\t\tdescription: string;\n\t};\n}\n\nconst IntentTriggeringInfoSchema = new Schema<IntentTriggeringInfoDocument>({\n\tcontext: {\n\t\tmessages: [MessageSchema],\n\t},\n\tintent: {\n\t\tname: { type: String, required: true },\n\t\tdescription: { type: String, required: true },\n\t},\n});\n\nexport const IntentTriggeringInfoModel =\n\tmongoose.model<IntentTriggeringInfoDocument>(\n\t\t\"IntentTriggeringInfo\",\n\t\tIntentTriggeringInfoSchema,\n\t);\n"],"mappings":";AAAA,OAAO,YAA2B,cAAc;AAEhD,IAAM,gBAAgB,IAAI;AAAA,EACzB;AAAA,IACC,MAAM;AAAA,MACL,MAAM;AAAA,MACN,MAAM,CAAC,UAAU,QAAQ,aAAa,QAAQ,UAAU;AAAA,MACxD,UAAU;AAAA,IACX;AAAA,IACA,SAAS;AAAA,MACR,MAAM,OAAO,MAAM;AAAA;AAAA,MACnB,UAAU;AAAA,IACX;AAAA,EACD;AAAA,EACA,EAAE,KAAK,MAAM;AACd;AAoBA,IAAM,6BAA6B,IAAI,OAAqC;AAAA,EAC3E,SAAS;AAAA,IACR,UAAU,CAAC,aAAa;AAAA,EACzB;AAAA,EACA,QAAQ;AAAA,IACP,MAAM,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACrC,aAAa,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,EAC7C;AACD,CAAC;AAEM,IAAM,4BACZ,SAAS;AAAA,EACR;AAAA,EACA;AACD;","names":[]}