|
|
@@ -24,6 +24,7 @@ import { createBatchStream } from '~/server/util/batch-stream';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
import { OpenaiServiceTypes } from '../../interfaces/ai';
|
|
|
+import type { AiAssistantUpdateData } from '../../interfaces/ai-assistant';
|
|
|
import {
|
|
|
type AccessibleAiAssistants, type AiAssistant, AiAssistantAccessScope, AiAssistantShareScope,
|
|
|
} from '../../interfaces/ai-assistant';
|
|
|
@@ -68,6 +69,7 @@ export interface IOpenaiService {
|
|
|
// rebuildVectorStoreAll(): Promise<void>;
|
|
|
// rebuildVectorStore(page: HydratedDocument<PageDocument>): Promise<void>;
|
|
|
createAiAssistant(data: Omit<AiAssistant, 'vectorStore'>): Promise<AiAssistantDocument>;
|
|
|
+ updateAiAssistant(ownerId: string, aiAssistantId: string, data: AiAssistantUpdateData): Promise<AiAssistantDocument>;
|
|
|
getAccessibleAiAssistants(user: IUserHasId): Promise<AccessibleAiAssistants>
|
|
|
deleteAiAssistant(ownerId: string, aiAssistantId: string): Promise<AiAssistantDocument>
|
|
|
}
|
|
|
@@ -605,6 +607,17 @@ class OpenaiService implements IOpenaiService {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ async updateAiAssistant(ownerId: string, aiAssistantId: string, data: AiAssistantUpdateData): Promise<AiAssistantDocument> {
|
|
|
+ const aiAssistant = await AiAssistantModel.findOne({ owner: ownerId, _id: aiAssistantId });
|
|
|
+ if (aiAssistant == null) {
|
|
|
+ throw new Error('AiAssistant document does not exist');
|
|
|
+ }
|
|
|
+
|
|
|
+ // Implement the logic to update AiAssistant
|
|
|
+
|
|
|
+ return aiAssistant;
|
|
|
+ }
|
|
|
+
|
|
|
async deleteAiAssistant(ownerId: string, aiAssistantId: string): Promise<AiAssistantDocument> {
|
|
|
const aiAssistant = await AiAssistantModel.findOne({ owner: ownerId, _id: aiAssistantId });
|
|
|
if (aiAssistant == null) {
|