|
@@ -74,6 +74,7 @@ const convertPathPatternsToRegExp = (pagePathPatterns: string[]): Array<string |
|
|
|
export interface IOpenaiService {
|
|
export interface IOpenaiService {
|
|
|
createThread(userId: string, type: ThreadType, aiAssistantId?: string, initialUserMessage?: string): Promise<ThreadRelationDocument>;
|
|
createThread(userId: string, type: ThreadType, aiAssistantId?: string, initialUserMessage?: string): Promise<ThreadRelationDocument>;
|
|
|
getThreadsByAiAssistantId(aiAssistantId: string): Promise<ThreadRelationDocument[]>
|
|
getThreadsByAiAssistantId(aiAssistantId: string): Promise<ThreadRelationDocument[]>
|
|
|
|
|
+ getRecentThreads(user: IUserHasId): Promise<ThreadRelationDocument[]>;
|
|
|
deleteThread(threadRelationId: string): Promise<ThreadRelationDocument>;
|
|
deleteThread(threadRelationId: string): Promise<ThreadRelationDocument>;
|
|
|
deleteExpiredThreads(limit: number, apiCallInterval: number): Promise<void>; // for CronJob
|
|
deleteExpiredThreads(limit: number, apiCallInterval: number): Promise<void>; // for CronJob
|
|
|
deleteObsoletedVectorStoreRelations(): Promise<void> // for CronJob
|
|
deleteObsoletedVectorStoreRelations(): Promise<void> // for CronJob
|
|
@@ -187,6 +188,11 @@ class OpenaiService implements IOpenaiService {
|
|
|
return threadRelations;
|
|
return threadRelations;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ async getRecentThreads(user: IUserHasId): Promise<ThreadRelationDocument[]> {
|
|
|
|
|
+ const threadRelations = await ThreadRelationModel.find({ userId: user._id });
|
|
|
|
|
+ return threadRelations;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
async deleteThread(threadRelationId: string): Promise<ThreadRelationDocument> {
|
|
async deleteThread(threadRelationId: string): Promise<ThreadRelationDocument> {
|
|
|
const threadRelation = await ThreadRelationModel.findById(threadRelationId);
|
|
const threadRelation = await ThreadRelationModel.findById(threadRelationId);
|
|
|
if (threadRelation == null) {
|
|
if (threadRelation == null) {
|