|
@@ -3,34 +3,38 @@ import { type Model, type Document, Schema } from 'mongoose';
|
|
|
|
|
|
|
|
import { getOrCreateModel } from '~/server/util/mongoose-utils';
|
|
import { getOrCreateModel } from '~/server/util/mongoose-utils';
|
|
|
|
|
|
|
|
|
|
+/*
|
|
|
|
|
+* AiAssistant Objects
|
|
|
|
|
+*/
|
|
|
const AiAssistantType = {
|
|
const AiAssistantType = {
|
|
|
KNOWLEDGE: 'knowledge',
|
|
KNOWLEDGE: 'knowledge',
|
|
|
} as const;
|
|
} as const;
|
|
|
|
|
|
|
|
-type AiAssistantType = typeof AiAssistantType[keyof typeof AiAssistantType];
|
|
|
|
|
-
|
|
|
|
|
const AiAssistantSharingScope = {
|
|
const AiAssistantSharingScope = {
|
|
|
PUBLIC: 'public',
|
|
PUBLIC: 'public',
|
|
|
ONLY_ME: 'onlyMe',
|
|
ONLY_ME: 'onlyMe',
|
|
|
USER_GROUP: 'userGroup',
|
|
USER_GROUP: 'userGroup',
|
|
|
} as const;
|
|
} as const;
|
|
|
|
|
|
|
|
-type AiAssistantSharingScope = typeof AiAssistantSharingScope[keyof typeof AiAssistantSharingScope];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
const AiAssistantLearningScope = {
|
|
const AiAssistantLearningScope = {
|
|
|
PUBLIC: 'public',
|
|
PUBLIC: 'public',
|
|
|
ONLY_ME: 'onlyMe',
|
|
ONLY_ME: 'onlyMe',
|
|
|
USER_GROUP: 'userGroup',
|
|
USER_GROUP: 'userGroup',
|
|
|
} as const;
|
|
} as const;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+/*
|
|
|
|
|
+* AiAssistant interfaces
|
|
|
|
|
+*/
|
|
|
|
|
+type AiAssistantType = typeof AiAssistantType[keyof typeof AiAssistantType];
|
|
|
|
|
+type AiAssistantSharingScope = typeof AiAssistantSharingScope[keyof typeof AiAssistantSharingScope];
|
|
|
type AiAssistantLearningScope = typeof AiAssistantLearningScope[keyof typeof AiAssistantLearningScope];
|
|
type AiAssistantLearningScope = typeof AiAssistantLearningScope[keyof typeof AiAssistantLearningScope];
|
|
|
|
|
|
|
|
interface AiAssistant {
|
|
interface AiAssistant {
|
|
|
name: string;
|
|
name: string;
|
|
|
description?: string
|
|
description?: string
|
|
|
instruction?: string
|
|
instruction?: string
|
|
|
- vectorStoreId: string
|
|
|
|
|
|
|
+ vectorStoreId: string // VectorStoreId of OpenAI Specify (https://platform.openai.com/docs/api-reference/vector-stores/object)
|
|
|
type: AiAssistantType[]
|
|
type: AiAssistantType[]
|
|
|
pages: mongoose.Types.ObjectId[]
|
|
pages: mongoose.Types.ObjectId[]
|
|
|
sharingScope: AiAssistantSharingScope
|
|
sharingScope: AiAssistantSharingScope
|
|
@@ -42,6 +46,9 @@ interface AiAssistantDocument extends AiAssistant, Document {}
|
|
|
type AiAssistantModel = Model<AiAssistantDocument>
|
|
type AiAssistantModel = Model<AiAssistantDocument>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+/*
|
|
|
|
|
+* AiAssistant Schema
|
|
|
|
|
+*/
|
|
|
const schema = new Schema<AiAssistantDocument>(
|
|
const schema = new Schema<AiAssistantDocument>(
|
|
|
{
|
|
{
|
|
|
name: {
|
|
name: {
|