|
|
@@ -69,7 +69,7 @@ export interface IOpenaiService {
|
|
|
getThreadsByAiAssistantId(aiAssistantId: string): Promise<ThreadRelationDocument[]>
|
|
|
deleteThread(threadRelationId: string): Promise<ThreadRelationDocument>;
|
|
|
deleteExpiredThreads(limit: number, apiCallInterval: number): Promise<void>; // for CronJob
|
|
|
- deleteObsolatedVectorStoreRelations(): Promise<void> // for CronJob
|
|
|
+ deleteObsoletedVectorStoreRelations(): Promise<void> // for CronJob
|
|
|
deleteVectorStore(vectorStoreRelationId: string): Promise<void>;
|
|
|
getMessageData(threadId: string, lang?: Lang, options?: MessageListParams): Promise<OpenAI.Beta.Threads.Messages.MessagesPage>;
|
|
|
createVectorStoreFile(vectorStoreRelation: VectorStoreDocument, pages: PageDocument[]): Promise<void>;
|
|
|
@@ -82,7 +82,6 @@ export interface IOpenaiService {
|
|
|
createAiAssistant(data: Omit<AiAssistant, 'vectorStore'>): Promise<AiAssistantDocument>;
|
|
|
updateAiAssistant(aiAssistantId: string, data: Omit<AiAssistant, 'vectorStore'>): Promise<AiAssistantDocument>;
|
|
|
getAccessibleAiAssistants(user: IUserHasId): Promise<AccessibleAiAssistants>
|
|
|
- deleteAiAssistant(ownerId: string, aiAssistantId: string): Promise<AiAssistantDocument>
|
|
|
isLearnablePageLimitExceeded(user: IUserHasId, pagePathPatterns: string[]): Promise<boolean>;
|
|
|
}
|
|
|
class OpenaiService implements IOpenaiService {
|
|
|
@@ -387,7 +386,7 @@ class OpenaiService implements IOpenaiService {
|
|
|
}
|
|
|
|
|
|
// Deletes all VectorStore documents that are marked as deleted (isDeleted: true) and have no associated VectorStoreFileRelation documents
|
|
|
- async deleteObsolatedVectorStoreRelations(): Promise<void> {
|
|
|
+ async deleteObsoletedVectorStoreRelations(): Promise<void> {
|
|
|
const deletedVectorStoreRelations = await VectorStoreModel.find({ isDeleted: true });
|
|
|
if (deletedVectorStoreRelations.length === 0) {
|
|
|
return;
|
|
|
@@ -878,19 +877,6 @@ class OpenaiService implements IOpenaiService {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- async deleteAiAssistant(ownerId: string, aiAssistantId: string): Promise<AiAssistantDocument> {
|
|
|
- const aiAssistant = await AiAssistantModel.findOne({ owner: ownerId, _id: aiAssistantId });
|
|
|
- if (aiAssistant == null) {
|
|
|
- throw createError(404, 'AiAssistant document does not exist');
|
|
|
- }
|
|
|
-
|
|
|
- const vectorStoreRelationId = getIdStringForRef(aiAssistant.vectorStore);
|
|
|
- await this.deleteVectorStore(vectorStoreRelationId);
|
|
|
-
|
|
|
- const deletedAiAssistant = await aiAssistant.remove();
|
|
|
- return deletedAiAssistant;
|
|
|
- }
|
|
|
-
|
|
|
async isLearnablePageLimitExceeded(user: IUserHasId, pagePathPatterns: string[]): Promise<boolean> {
|
|
|
const normalizedPagePathPatterns = removeGlobPath(pagePathPatterns);
|
|
|
|