perf: model framwork

This commit is contained in:
archer
2023-04-29 15:55:47 +08:00
parent cd9acab938
commit 78762498eb
30 changed files with 649 additions and 757 deletions

View File

@@ -1,6 +1,11 @@
import { Schema, model, models, Model as MongoModel } from 'mongoose';
import { ModelSchema as ModelType } from '@/types/mongoSchema';
import { ModelVectorSearchModeMap, ModelVectorSearchModeEnum } from '@/constants/model';
import {
ModelVectorSearchModeMap,
ModelVectorSearchModeEnum,
ChatModelMap,
ChatModelEnum
} from '@/constants/model';
const ModelSchema = new Schema({
userId: {
@@ -16,11 +21,6 @@ const ModelSchema = new Schema({
type: String,
default: '/icon/logo.png'
},
systemPrompt: {
// 系统提示词
type: String,
default: ''
},
status: {
type: String,
required: true,
@@ -30,17 +30,34 @@ const ModelSchema = new Schema({
type: Date,
default: () => new Date()
},
temperature: {
type: Number,
min: 0,
max: 10,
default: 4
},
search: {
mode: {
chat: {
useKb: {
// use knowledge base to search
type: Boolean,
default: false
},
searchMode: {
// knowledge base search mode
type: String,
enum: Object.keys(ModelVectorSearchModeMap),
default: ModelVectorSearchModeEnum.hightSimilarity
},
systemPrompt: {
// 系统提示词
type: String,
default: ''
},
temperature: {
type: Number,
min: 0,
max: 10,
default: 0
},
chatModel: {
// 聊天时使用的模型
type: String,
enum: Object.keys(ChatModelMap),
default: ChatModelEnum.GPT35
}
},
share: {
@@ -63,18 +80,6 @@ const ModelSchema = new Schema({
default: 0
}
},
service: {
chatModel: {
// 聊天时使用的模型
type: String,
required: true
},
modelName: {
// 底层模型的名称
type: String,
required: true
}
},
security: {
type: {
domain: {
@@ -100,8 +105,7 @@ const ModelSchema = new Schema({
default: -1
}
},
default: {},
required: true
default: {}
}
});