@ainetwork/adk-provider-memory-mongodb 0.1.7 → 0.2.0
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-GPOFS7ZT.js +42 -0
- package/dist/chunk-GPOFS7ZT.js.map +1 -0
- package/dist/chunk-MLPXPX2L.js +50 -0
- package/dist/chunk-MLPXPX2L.js.map +1 -0
- package/dist/index.cjs +67 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -8
- package/dist/index.d.ts +4 -8
- package/dist/index.js +55 -44
- package/dist/index.js.map +1 -1
- package/dist/models/intent.model.d.cts +2 -2
- package/dist/models/intent.model.d.ts +2 -2
- package/dist/models/messages.model.cjs +86 -0
- package/dist/models/messages.model.cjs.map +1 -0
- package/dist/models/messages.model.d.cts +75 -0
- package/dist/models/messages.model.d.ts +75 -0
- package/dist/models/messages.model.js +11 -0
- package/dist/models/{chats.model.cjs → threads.model.cjs} +19 -47
- package/dist/models/threads.model.cjs.map +1 -0
- package/dist/models/threads.model.d.cts +44 -0
- package/dist/models/threads.model.d.ts +44 -0
- package/dist/models/threads.model.js +9 -0
- package/dist/models/threads.model.js.map +1 -0
- package/implements/base.memory.ts +9 -9
- package/implements/intent.memory.ts +18 -6
- package/implements/thread.memory.ts +26 -35
- package/models/messages.model.ts +61 -0
- package/models/threads.model.ts +46 -0
- package/package.json +3 -3
- package/dist/chunk-S537KQMN.js +0 -79
- package/dist/chunk-S537KQMN.js.map +0 -1
- package/dist/models/chats.model.cjs.map +0 -1
- package/dist/models/chats.model.d.cts +0 -105
- package/dist/models/chats.model.d.ts +0 -105
- package/dist/models/chats.model.js +0 -11
- package/models/chats.model.ts +0 -99
- /package/dist/models/{chats.model.js.map → messages.model.js.map} +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ThreadType } from '@ainetwork/adk/types/memory';
|
|
2
|
+
import mongoose, { Schema, Document } from 'mongoose';
|
|
3
|
+
|
|
4
|
+
declare const ThreadObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
5
|
+
type: ThreadType;
|
|
6
|
+
threadId: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
created_at: number;
|
|
9
|
+
updated_at: number;
|
|
10
|
+
title?: string | null | undefined;
|
|
11
|
+
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
12
|
+
type: ThreadType;
|
|
13
|
+
threadId: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
created_at: number;
|
|
16
|
+
updated_at: number;
|
|
17
|
+
title?: string | null | undefined;
|
|
18
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
19
|
+
type: ThreadType;
|
|
20
|
+
threadId: string;
|
|
21
|
+
userId: string;
|
|
22
|
+
created_at: number;
|
|
23
|
+
updated_at: number;
|
|
24
|
+
title?: string | null | undefined;
|
|
25
|
+
}> & {
|
|
26
|
+
_id: mongoose.Types.ObjectId;
|
|
27
|
+
} & {
|
|
28
|
+
__v: number;
|
|
29
|
+
}>;
|
|
30
|
+
interface ThreadDocument extends Document {
|
|
31
|
+
type: ThreadType;
|
|
32
|
+
threadId: string;
|
|
33
|
+
userId: string;
|
|
34
|
+
title: string;
|
|
35
|
+
created_at: number;
|
|
36
|
+
updated_at: number;
|
|
37
|
+
}
|
|
38
|
+
declare const ThreadModel: mongoose.Model<ThreadDocument, {}, {}, {}, Document<unknown, {}, ThreadDocument, {}> & ThreadDocument & Required<{
|
|
39
|
+
_id: unknown;
|
|
40
|
+
}> & {
|
|
41
|
+
__v: number;
|
|
42
|
+
}, any>;
|
|
43
|
+
|
|
44
|
+
export { type ThreadDocument, ThreadModel, ThreadObjectSchema };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ThreadType } from '@ainetwork/adk/types/memory';
|
|
2
|
+
import mongoose, { Schema, Document } from 'mongoose';
|
|
3
|
+
|
|
4
|
+
declare const ThreadObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
5
|
+
type: ThreadType;
|
|
6
|
+
threadId: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
created_at: number;
|
|
9
|
+
updated_at: number;
|
|
10
|
+
title?: string | null | undefined;
|
|
11
|
+
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
12
|
+
type: ThreadType;
|
|
13
|
+
threadId: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
created_at: number;
|
|
16
|
+
updated_at: number;
|
|
17
|
+
title?: string | null | undefined;
|
|
18
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
19
|
+
type: ThreadType;
|
|
20
|
+
threadId: string;
|
|
21
|
+
userId: string;
|
|
22
|
+
created_at: number;
|
|
23
|
+
updated_at: number;
|
|
24
|
+
title?: string | null | undefined;
|
|
25
|
+
}> & {
|
|
26
|
+
_id: mongoose.Types.ObjectId;
|
|
27
|
+
} & {
|
|
28
|
+
__v: number;
|
|
29
|
+
}>;
|
|
30
|
+
interface ThreadDocument extends Document {
|
|
31
|
+
type: ThreadType;
|
|
32
|
+
threadId: string;
|
|
33
|
+
userId: string;
|
|
34
|
+
title: string;
|
|
35
|
+
created_at: number;
|
|
36
|
+
updated_at: number;
|
|
37
|
+
}
|
|
38
|
+
declare const ThreadModel: mongoose.Model<ThreadDocument, {}, {}, {}, Document<unknown, {}, ThreadDocument, {}> & ThreadDocument & Required<{
|
|
39
|
+
_id: unknown;
|
|
40
|
+
}> & {
|
|
41
|
+
__v: number;
|
|
42
|
+
}, any>;
|
|
43
|
+
|
|
44
|
+
export { type ThreadDocument, ThreadModel, ThreadObjectSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import { IMemory } from "node_modules/@ainetwork/adk/dist/esm/modules/memory/base.memory";
|
|
2
|
-
import mongoose
|
|
2
|
+
import mongoose from "mongoose";
|
|
3
3
|
import { loggers } from "@ainetwork/adk/utils/logger";
|
|
4
4
|
|
|
5
5
|
export class MongoDBMemory implements IMemory {
|
|
6
6
|
private _isConnected: boolean = false;
|
|
7
7
|
private _uri: string;
|
|
8
|
-
private _mongoose: Mongoose;
|
|
9
8
|
|
|
10
9
|
constructor(uri: string) {
|
|
11
10
|
this._uri = uri;
|
|
12
|
-
this._mongoose = new Mongoose();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public getInstance(): Mongoose {
|
|
16
|
-
return this._mongoose;
|
|
17
11
|
}
|
|
18
12
|
|
|
19
13
|
public async connect(): Promise<void> {
|
|
@@ -22,7 +16,13 @@ export class MongoDBMemory implements IMemory {
|
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
try {
|
|
25
|
-
await
|
|
19
|
+
await mongoose.connect(this._uri, {
|
|
20
|
+
maxPoolSize: 1,
|
|
21
|
+
serverSelectionTimeoutMS: 30000,
|
|
22
|
+
socketTimeoutMS: 45000,
|
|
23
|
+
connectTimeoutMS: 30000,
|
|
24
|
+
bufferCommands: false,
|
|
25
|
+
});
|
|
26
26
|
this._isConnected = true;
|
|
27
27
|
loggers.agent.info("MongoDB connected successfully");
|
|
28
28
|
} catch (error) {
|
|
@@ -37,7 +37,7 @@ export class MongoDBMemory implements IMemory {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
|
-
await
|
|
40
|
+
await mongoose.disconnect();
|
|
41
41
|
this._isConnected = false;
|
|
42
42
|
loggers.agent.info("MongoDB disconnected successfully");
|
|
43
43
|
} catch (error) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
1
|
import type { Intent } from "@ainetwork/adk/types/memory";
|
|
3
2
|
import { IIntentMemory } from "@ainetwork/adk/modules";
|
|
4
3
|
import { MongoDBMemory } from "./base.memory";
|
|
5
4
|
import { IntentModel } from "../models/intent.model";
|
|
5
|
+
import { Types } from "mongoose";
|
|
6
6
|
|
|
7
7
|
export class MongoDBIntent extends MongoDBMemory implements IIntentMemory {
|
|
8
8
|
public async getIntent(intentId: string): Promise<Intent | undefined> {
|
|
9
|
-
const intent = await IntentModel.findById(intentId);
|
|
9
|
+
const intent = await IntentModel.findById(new Types.ObjectId(intentId));
|
|
10
10
|
if (intent) {
|
|
11
11
|
return {
|
|
12
12
|
name: intent.name,
|
|
@@ -18,10 +18,22 @@ export class MongoDBIntent extends MongoDBMemory implements IIntentMemory {
|
|
|
18
18
|
return undefined;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
public async getIntentByName(intentName: string): Promise<Intent | undefined> {
|
|
22
|
+
const intent = await IntentModel.findOne({ name: intentName });
|
|
23
|
+
if (intent) {
|
|
24
|
+
return {
|
|
25
|
+
name: intent.name,
|
|
26
|
+
description: intent.description,
|
|
27
|
+
prompt: intent.prompt,
|
|
28
|
+
llm: intent.llm,
|
|
29
|
+
} as Intent;
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
21
34
|
public async saveIntent(intent: Intent): Promise<void> {
|
|
22
|
-
|
|
35
|
+
// ObjectId automatically generated (MongoDB automatically generates)
|
|
23
36
|
await IntentModel.create({
|
|
24
|
-
_id: newId,
|
|
25
37
|
name: intent.name,
|
|
26
38
|
description: intent.description,
|
|
27
39
|
prompt: intent.prompt,
|
|
@@ -31,7 +43,7 @@ export class MongoDBIntent extends MongoDBMemory implements IIntentMemory {
|
|
|
31
43
|
|
|
32
44
|
public async updateIntent(intentId: string, intent: Intent): Promise<void> {
|
|
33
45
|
await IntentModel.updateOne({
|
|
34
|
-
_id: intentId,
|
|
46
|
+
_id: new Types.ObjectId(intentId),
|
|
35
47
|
},{
|
|
36
48
|
name: intent.name,
|
|
37
49
|
description: intent.description,
|
|
@@ -41,7 +53,7 @@ export class MongoDBIntent extends MongoDBMemory implements IIntentMemory {
|
|
|
41
53
|
};
|
|
42
54
|
|
|
43
55
|
public async deleteIntent(intentId: string): Promise<void> {
|
|
44
|
-
await IntentModel.deleteOne({ _id: intentId });
|
|
56
|
+
await IntentModel.deleteOne({ _id: new Types.ObjectId(intentId) });
|
|
45
57
|
};
|
|
46
58
|
|
|
47
59
|
public async listIntents(): Promise<Intent[]> {
|
|
@@ -3,52 +3,40 @@ import type { MessageObject, ThreadMetadata, ThreadObject, ThreadType } from "@a
|
|
|
3
3
|
import { MessageRole } from "@ainetwork/adk/types/memory";
|
|
4
4
|
import { IThreadMemory } from "@ainetwork/adk/modules";
|
|
5
5
|
import { MongoDBMemory } from "./base.memory";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
ChatObjectSchema,
|
|
9
|
-
ThreadObjectSchema,
|
|
10
|
-
ThreadDocument
|
|
11
|
-
} from "../models/chats.model";
|
|
6
|
+
import { ThreadDocument, ThreadModel } from "../models/threads.model";
|
|
7
|
+
import { MessageDocument, MessageModel } from "../models/messages.model";
|
|
12
8
|
import { loggers } from "@ainetwork/adk/utils/logger";
|
|
13
|
-
import { Model } from "mongoose";
|
|
14
9
|
|
|
15
10
|
export class MongoDBThread extends MongoDBMemory implements IThreadMemory {
|
|
16
|
-
private chatModel: Model<ChatDocument>;
|
|
17
|
-
private threadModel: Model<ThreadDocument>;
|
|
18
|
-
|
|
19
11
|
constructor(uri: string) {
|
|
20
12
|
super(uri);
|
|
21
|
-
const _mongoose = super.getInstance();
|
|
22
|
-
this.chatModel = _mongoose.model<ChatDocument>("Chat", ChatObjectSchema);
|
|
23
|
-
this.threadModel = _mongoose.model<ThreadDocument>("Thread", ThreadObjectSchema);
|
|
24
13
|
}
|
|
25
14
|
|
|
26
15
|
public async getThread(
|
|
27
|
-
type: ThreadType,
|
|
28
16
|
userId: string,
|
|
29
17
|
threadId: string
|
|
30
18
|
): Promise<ThreadObject | undefined> {
|
|
31
|
-
const thread = await
|
|
32
|
-
const
|
|
19
|
+
const thread = await ThreadModel.findOne({ threadId, userId });
|
|
20
|
+
const messages = await MessageModel.find({ threadId, userId }).sort({
|
|
33
21
|
timestamp: 1,
|
|
34
22
|
});
|
|
35
23
|
|
|
36
24
|
if (!thread) return undefined;
|
|
37
25
|
|
|
38
|
-
loggers.agent.debug(`Found ${
|
|
26
|
+
loggers.agent.debug(`Found ${messages.length} messages for thread ${threadId}`);
|
|
39
27
|
|
|
40
28
|
const threadObject: ThreadObject = {
|
|
41
29
|
type: thread.type as ThreadType,
|
|
42
|
-
title: thread.title || "New
|
|
30
|
+
title: thread.title || "New thread",
|
|
43
31
|
messages: {}
|
|
44
32
|
};
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
threadObject.messages[
|
|
48
|
-
role:
|
|
49
|
-
content:
|
|
50
|
-
timestamp:
|
|
51
|
-
metadata:
|
|
33
|
+
messages.forEach((message: MessageDocument) => {
|
|
34
|
+
const messageId = message._id?.toString() || message.id;
|
|
35
|
+
threadObject.messages[messageId] = {
|
|
36
|
+
role: message.role as MessageRole,
|
|
37
|
+
content: message.content,
|
|
38
|
+
timestamp: message.timestamp,
|
|
39
|
+
metadata: message.metadata,
|
|
52
40
|
};
|
|
53
41
|
});
|
|
54
42
|
|
|
@@ -62,7 +50,7 @@ export class MongoDBThread extends MongoDBMemory implements IThreadMemory {
|
|
|
62
50
|
title: string,
|
|
63
51
|
): Promise<ThreadMetadata> {
|
|
64
52
|
const now = Date.now();
|
|
65
|
-
await
|
|
53
|
+
await ThreadModel.create({
|
|
66
54
|
type,
|
|
67
55
|
userId,
|
|
68
56
|
threadId,
|
|
@@ -78,39 +66,42 @@ export class MongoDBThread extends MongoDBMemory implements IThreadMemory {
|
|
|
78
66
|
userId: string,
|
|
79
67
|
threadId: string,
|
|
80
68
|
messages: MessageObject[]
|
|
81
|
-
): Promise<
|
|
82
|
-
await
|
|
69
|
+
): Promise<string[]> {
|
|
70
|
+
await ThreadModel.updateOne({ threadId, userId }, {
|
|
83
71
|
updated_at: Date.now(),
|
|
84
72
|
});
|
|
73
|
+
const messageIds: string[] = [];
|
|
85
74
|
for (const message of messages) {
|
|
86
75
|
const newId = randomUUID();
|
|
87
|
-
await
|
|
76
|
+
await MessageModel.create({
|
|
88
77
|
threadId,
|
|
89
|
-
|
|
78
|
+
messageId: newId,
|
|
90
79
|
userId,
|
|
91
80
|
role: message.role,
|
|
92
81
|
content: message.content,
|
|
93
82
|
timestamp: message.timestamp,
|
|
94
83
|
metadata: message.metadata,
|
|
95
84
|
});
|
|
85
|
+
messageIds.push(newId);
|
|
96
86
|
}
|
|
87
|
+
return messageIds;
|
|
97
88
|
};
|
|
98
89
|
|
|
99
90
|
public async deleteThread(userId: string, threadId: string): Promise<void> {
|
|
100
|
-
const
|
|
91
|
+
const messages = await MessageModel.find({ userId, threadId }).sort({
|
|
101
92
|
timestamp: 1,
|
|
102
93
|
});
|
|
103
94
|
|
|
104
|
-
|
|
105
|
-
|
|
95
|
+
messages?.forEach((message: MessageDocument) => {
|
|
96
|
+
message.deleteOne();
|
|
106
97
|
});
|
|
107
98
|
|
|
108
|
-
const thread = await
|
|
99
|
+
const thread = await ThreadModel.findOne({ userId, threadId });
|
|
109
100
|
thread?.deleteOne();
|
|
110
101
|
};
|
|
111
102
|
|
|
112
103
|
public async listThreads(userId: string): Promise<ThreadMetadata[]> {
|
|
113
|
-
const threads = await
|
|
104
|
+
const threads = await ThreadModel.find({ userId }).sort({
|
|
114
105
|
updated_at: -1,
|
|
115
106
|
});
|
|
116
107
|
const data: ThreadMetadata[] = threads.map((thread: ThreadDocument) => {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { MessageRole } from "@ainetwork/adk/types/memory";
|
|
2
|
+
import { type Document, Schema } from "mongoose";
|
|
3
|
+
import mongoose from "mongoose";
|
|
4
|
+
|
|
5
|
+
// MessageContentObject schema
|
|
6
|
+
export const MessageContentObjectSchema = new Schema(
|
|
7
|
+
{
|
|
8
|
+
type: { type: String, required: true },
|
|
9
|
+
parts: { type: [Schema.Types.Mixed], required: true },
|
|
10
|
+
},
|
|
11
|
+
{ _id: false },
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
// MessageObject schema - 개별 문서로 저장
|
|
15
|
+
export const MessageObjectSchema = new Schema(
|
|
16
|
+
{
|
|
17
|
+
threadId: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true,
|
|
20
|
+
index: true,
|
|
21
|
+
},
|
|
22
|
+
userId: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: true,
|
|
25
|
+
index: true,
|
|
26
|
+
},
|
|
27
|
+
role: {
|
|
28
|
+
type: String,
|
|
29
|
+
enum: Object.values(MessageRole),
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
content: {
|
|
33
|
+
type: MessageContentObjectSchema,
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
timestamp: {
|
|
37
|
+
type: Number,
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
metadata: {
|
|
41
|
+
type: Schema.Types.Mixed,
|
|
42
|
+
default: {},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// Message Document interface
|
|
48
|
+
export interface MessageDocument extends Document {
|
|
49
|
+
threadId: string;
|
|
50
|
+
role: MessageRole;
|
|
51
|
+
content: {
|
|
52
|
+
type: string;
|
|
53
|
+
parts: any[];
|
|
54
|
+
};
|
|
55
|
+
timestamp: number;
|
|
56
|
+
metadata?: { [key: string]: unknown };
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
updatedAt: Date;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const MessageModel = mongoose.model<MessageDocument>("Message", MessageObjectSchema);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ThreadType } from "@ainetwork/adk/types/memory";
|
|
2
|
+
import { type Document, Schema } from "mongoose";
|
|
3
|
+
import mongoose from "mongoose";
|
|
4
|
+
|
|
5
|
+
export const ThreadObjectSchema = new Schema(
|
|
6
|
+
{
|
|
7
|
+
type: {
|
|
8
|
+
type: String,
|
|
9
|
+
enum: Object.values(ThreadType),
|
|
10
|
+
required: true,
|
|
11
|
+
},
|
|
12
|
+
threadId: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
index: true,
|
|
16
|
+
},
|
|
17
|
+
userId: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true,
|
|
20
|
+
index: true,
|
|
21
|
+
},
|
|
22
|
+
title: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: false,
|
|
25
|
+
},
|
|
26
|
+
created_at: {
|
|
27
|
+
type: Number,
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
updated_at: {
|
|
31
|
+
type: Number,
|
|
32
|
+
required: true,
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export interface ThreadDocument extends Document {
|
|
38
|
+
type: ThreadType;
|
|
39
|
+
threadId: string;
|
|
40
|
+
userId: string;
|
|
41
|
+
title: string;
|
|
42
|
+
created_at: number;
|
|
43
|
+
updated_at: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const ThreadModel = mongoose.model<ThreadDocument>("Thread", ThreadObjectSchema);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainetwork/adk-provider-memory-mongodb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"author": "AI Network (https://ainetwork.ai)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"clean": "rm -rf dist"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@ainetwork/adk": "^0.1
|
|
31
|
+
"@ainetwork/adk": "^0.2.1",
|
|
32
32
|
"mongoose": "^8.16.5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "caccd8175754d166971b8bd566644b3ac6598793"
|
|
42
42
|
}
|
package/dist/chunk-S537KQMN.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// models/chats.model.ts
|
|
2
|
-
import { MessageRole, ThreadType } from "@ainetwork/adk/types/memory";
|
|
3
|
-
import { Schema } from "mongoose";
|
|
4
|
-
var ThreadObjectSchema = new Schema(
|
|
5
|
-
{
|
|
6
|
-
type: {
|
|
7
|
-
type: String,
|
|
8
|
-
enum: Object.values(ThreadType),
|
|
9
|
-
required: true
|
|
10
|
-
},
|
|
11
|
-
threadId: {
|
|
12
|
-
type: String,
|
|
13
|
-
required: true,
|
|
14
|
-
index: true
|
|
15
|
-
},
|
|
16
|
-
userId: {
|
|
17
|
-
type: String,
|
|
18
|
-
required: true,
|
|
19
|
-
index: true
|
|
20
|
-
},
|
|
21
|
-
title: {
|
|
22
|
-
type: String,
|
|
23
|
-
required: false
|
|
24
|
-
},
|
|
25
|
-
created_at: {
|
|
26
|
-
type: Number,
|
|
27
|
-
required: true
|
|
28
|
-
},
|
|
29
|
-
updated_at: {
|
|
30
|
-
type: Number,
|
|
31
|
-
required: true
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
var ChatContentObjectSchema = new Schema(
|
|
36
|
-
{
|
|
37
|
-
type: { type: String, required: true },
|
|
38
|
-
parts: { type: [Schema.Types.Mixed], required: true }
|
|
39
|
-
},
|
|
40
|
-
{ _id: false }
|
|
41
|
-
);
|
|
42
|
-
var ChatObjectSchema = new Schema(
|
|
43
|
-
{
|
|
44
|
-
threadId: {
|
|
45
|
-
type: String,
|
|
46
|
-
required: true,
|
|
47
|
-
index: true
|
|
48
|
-
},
|
|
49
|
-
userId: {
|
|
50
|
-
type: String,
|
|
51
|
-
required: true,
|
|
52
|
-
index: true
|
|
53
|
-
},
|
|
54
|
-
role: {
|
|
55
|
-
type: String,
|
|
56
|
-
enum: Object.values(MessageRole),
|
|
57
|
-
required: true
|
|
58
|
-
},
|
|
59
|
-
content: {
|
|
60
|
-
type: ChatContentObjectSchema,
|
|
61
|
-
required: true
|
|
62
|
-
},
|
|
63
|
-
timestamp: {
|
|
64
|
-
type: Number,
|
|
65
|
-
required: true
|
|
66
|
-
},
|
|
67
|
-
metadata: {
|
|
68
|
-
type: Schema.Types.Mixed,
|
|
69
|
-
default: {}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
export {
|
|
75
|
-
ThreadObjectSchema,
|
|
76
|
-
ChatContentObjectSchema,
|
|
77
|
-
ChatObjectSchema
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=chunk-S537KQMN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../models/chats.model.ts"],"sourcesContent":["import { MessageRole, ThreadType } from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\n\nexport const ThreadObjectSchema = new Schema(\n\t{\n\t\ttype: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(ThreadType),\n\t\t\trequired: true,\n\t\t},\n\t\tthreadId: {\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 ThreadDocument extends Document {\n\ttype: ThreadType;\n\tthreadId: 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\tthreadId: {\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\trole: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(MessageRole),\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\tthreadId: string;\n\trole: MessageRole;\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,SAAS,aAAa,kBAAkB;AACxC,SAAwB,cAAc;AAE/B,IAAM,qBAAqB,IAAI;AAAA,EACrC;AAAA,IACC,MAAM;AAAA,MACL,MAAM;AAAA,MACN,MAAM,OAAO,OAAO,UAAU;AAAA,MAC9B,UAAU;AAAA,IACX;AAAA,IACA,UAAU;AAAA,MACT,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;AAYO,IAAM,0BAA0B,IAAI;AAAA,EAC1C;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;AAGO,IAAM,mBAAmB,IAAI;AAAA,EACnC;AAAA,IACC,UAAU;AAAA,MACT,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,MAAM;AAAA,MACL,MAAM;AAAA,MACN,MAAM,OAAO,OAAO,WAAW;AAAA,MAC/B,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;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../models/chats.model.ts"],"sourcesContent":["import { MessageRole, ThreadType } from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\n\nexport const ThreadObjectSchema = new Schema(\n\t{\n\t\ttype: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(ThreadType),\n\t\t\trequired: true,\n\t\t},\n\t\tthreadId: {\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 ThreadDocument extends Document {\n\ttype: ThreadType;\n\tthreadId: 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\tthreadId: {\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\trole: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(MessageRole),\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\tthreadId: string;\n\trole: MessageRole;\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,oBAAwC;AACxC,sBAAsC;AAE/B,IAAM,qBAAqB,IAAI;AAAA,EACrC;AAAA,IACC,MAAM;AAAA,MACL,MAAM;AAAA,MACN,MAAM,OAAO,OAAO,wBAAU;AAAA,MAC9B,UAAU;AAAA,IACX;AAAA,IACA,UAAU;AAAA,MACT,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;AAYO,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,UAAU;AAAA,MACT,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,MAAM;AAAA,MACL,MAAM;AAAA,MACN,MAAM,OAAO,OAAO,yBAAW;AAAA,MAC/B,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":[]}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import * as mongoose from 'mongoose';
|
|
2
|
-
import { Schema, Document } from 'mongoose';
|
|
3
|
-
import { ThreadType, MessageRole } from '@ainetwork/adk/types/memory';
|
|
4
|
-
|
|
5
|
-
declare const ThreadObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
6
|
-
type: ThreadType;
|
|
7
|
-
threadId: string;
|
|
8
|
-
userId: string;
|
|
9
|
-
created_at: number;
|
|
10
|
-
updated_at: number;
|
|
11
|
-
title?: string | null | undefined;
|
|
12
|
-
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
13
|
-
type: ThreadType;
|
|
14
|
-
threadId: string;
|
|
15
|
-
userId: string;
|
|
16
|
-
created_at: number;
|
|
17
|
-
updated_at: number;
|
|
18
|
-
title?: string | null | undefined;
|
|
19
|
-
}>, {}> & mongoose.FlatRecord<{
|
|
20
|
-
type: ThreadType;
|
|
21
|
-
threadId: string;
|
|
22
|
-
userId: string;
|
|
23
|
-
created_at: number;
|
|
24
|
-
updated_at: number;
|
|
25
|
-
title?: string | null | undefined;
|
|
26
|
-
}> & {
|
|
27
|
-
_id: mongoose.Types.ObjectId;
|
|
28
|
-
} & {
|
|
29
|
-
__v: number;
|
|
30
|
-
}>;
|
|
31
|
-
interface ThreadDocument extends Document {
|
|
32
|
-
type: ThreadType;
|
|
33
|
-
threadId: 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
|
-
threadId: string;
|
|
57
|
-
userId: string;
|
|
58
|
-
role: MessageRole;
|
|
59
|
-
content: {
|
|
60
|
-
type: string;
|
|
61
|
-
parts: any[];
|
|
62
|
-
};
|
|
63
|
-
timestamp: number;
|
|
64
|
-
metadata: any;
|
|
65
|
-
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
66
|
-
threadId: string;
|
|
67
|
-
userId: string;
|
|
68
|
-
role: MessageRole;
|
|
69
|
-
content: {
|
|
70
|
-
type: string;
|
|
71
|
-
parts: any[];
|
|
72
|
-
};
|
|
73
|
-
timestamp: number;
|
|
74
|
-
metadata: any;
|
|
75
|
-
}>, {}> & mongoose.FlatRecord<{
|
|
76
|
-
threadId: string;
|
|
77
|
-
userId: string;
|
|
78
|
-
role: MessageRole;
|
|
79
|
-
content: {
|
|
80
|
-
type: string;
|
|
81
|
-
parts: any[];
|
|
82
|
-
};
|
|
83
|
-
timestamp: number;
|
|
84
|
-
metadata: any;
|
|
85
|
-
}> & {
|
|
86
|
-
_id: mongoose.Types.ObjectId;
|
|
87
|
-
} & {
|
|
88
|
-
__v: number;
|
|
89
|
-
}>;
|
|
90
|
-
interface ChatDocument extends Document {
|
|
91
|
-
threadId: string;
|
|
92
|
-
role: MessageRole;
|
|
93
|
-
content: {
|
|
94
|
-
type: string;
|
|
95
|
-
parts: any[];
|
|
96
|
-
};
|
|
97
|
-
timestamp: number;
|
|
98
|
-
metadata?: {
|
|
99
|
-
[key: string]: unknown;
|
|
100
|
-
};
|
|
101
|
-
createdAt: Date;
|
|
102
|
-
updatedAt: Date;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export { ChatContentObjectSchema, type ChatDocument, ChatObjectSchema, type ThreadDocument, ThreadObjectSchema };
|