feat(*): add RAG support
This commit is contained in:
@@ -16,7 +16,13 @@ export const getById = query({
|
||||
followUpPrompt: v.optional(v.string()),
|
||||
model: v.string(),
|
||||
followUpModel: v.optional(v.string()),
|
||||
activeChatId: v.optional(v.id('chats'))
|
||||
activeChatId: v.optional(v.id('chats')),
|
||||
ragCollectionMode: v.optional(
|
||||
v.object({
|
||||
ragDatabaseId: v.id('ragDatabases'),
|
||||
activeSince: v.number()
|
||||
})
|
||||
)
|
||||
}),
|
||||
v.null()
|
||||
),
|
||||
@@ -38,7 +44,13 @@ export const getByTelegramId = query({
|
||||
followUpPrompt: v.optional(v.string()),
|
||||
model: v.string(),
|
||||
followUpModel: v.optional(v.string()),
|
||||
activeChatId: v.optional(v.id('chats'))
|
||||
activeChatId: v.optional(v.id('chats')),
|
||||
ragCollectionMode: v.optional(
|
||||
v.object({
|
||||
ragDatabaseId: v.id('ragDatabases'),
|
||||
activeSince: v.number()
|
||||
})
|
||||
)
|
||||
}),
|
||||
v.null()
|
||||
),
|
||||
@@ -127,3 +139,41 @@ export const setActiveChat = mutation({
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
export const startRagCollectionMode = mutation({
|
||||
args: { userId: v.id('users'), ragDatabaseId: v.id('ragDatabases') },
|
||||
returns: v.null(),
|
||||
handler: async (ctx, args) => {
|
||||
await ctx.db.patch(args.userId, {
|
||||
ragCollectionMode: {
|
||||
ragDatabaseId: args.ragDatabaseId,
|
||||
activeSince: Date.now()
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
export const stopRagCollectionMode = mutation({
|
||||
args: { userId: v.id('users') },
|
||||
returns: v.null(),
|
||||
handler: async (ctx, args) => {
|
||||
await ctx.db.patch(args.userId, { ragCollectionMode: undefined });
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
export const getRagCollectionMode = query({
|
||||
args: { userId: v.id('users') },
|
||||
returns: v.union(
|
||||
v.object({
|
||||
ragDatabaseId: v.id('ragDatabases'),
|
||||
activeSince: v.number()
|
||||
}),
|
||||
v.null()
|
||||
),
|
||||
handler: async (ctx, args) => {
|
||||
const user = await ctx.db.get(args.userId);
|
||||
return user?.ragCollectionMode ?? null;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user