mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-29 09:44:47 +00:00
feat: self vector search
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { openaiAccountError } from '../errorCode';
|
||||
import { insertKbItem } from '@/service/pg';
|
||||
import { getVector } from '@/pages/api/openapi/plugin/vector';
|
||||
import { TrainingData } from '../models/trainingData';
|
||||
|
@@ -65,7 +65,7 @@ const AppSchema = new Schema({
|
||||
},
|
||||
searchSimilarity: {
|
||||
type: Number,
|
||||
default: 0.8
|
||||
default: 0.4
|
||||
},
|
||||
searchLimit: {
|
||||
type: Number,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { PgClient } from '@/service/pg';
|
||||
import type { ChatHistoryItemResType, ChatItemType } from '@/types/chat';
|
||||
import type { ChatHistoryItemResType } from '@/types/chat';
|
||||
import { ChatModuleEnum, TaskResponseKeyEnum } from '@/constants/chat';
|
||||
import { getVector } from '@/pages/api/openapi/plugin/vector';
|
||||
import { countModelPrice } from '@/service/events/pushBill';
|
||||
@@ -21,7 +21,7 @@ export type KBSearchResponse = {
|
||||
};
|
||||
|
||||
export async function dispatchKBSearch(props: Record<string, any>): Promise<KBSearchResponse> {
|
||||
const { kbList = [], similarity = 0.8, limit = 5, userChatInput } = props as KBSearchProps;
|
||||
const { kbList = [], similarity = 0.4, limit = 5, userChatInput } = props as KBSearchProps;
|
||||
|
||||
if (kbList.length === 0) {
|
||||
return Promise.reject("You didn't choose the knowledge base");
|
||||
@@ -32,7 +32,7 @@ export async function dispatchKBSearch(props: Record<string, any>): Promise<KBSe
|
||||
}
|
||||
|
||||
// get vector
|
||||
const vectorModel = global.vectorModels[0];
|
||||
const vectorModel = kbList[0]?.vectorModel;
|
||||
const { vectors, tokenLen } = await getVector({
|
||||
model: vectorModel.model,
|
||||
input: [userChatInput]
|
||||
|
@@ -2,7 +2,7 @@ export const getChatModel = (model?: string) => {
|
||||
return global.chatModels.find((item) => item.model === model);
|
||||
};
|
||||
export const getVectorModel = (model?: string) => {
|
||||
return global.vectorModels.find((item) => item.model === model);
|
||||
return global.vectorModels.find((item) => item.model === model) || global.vectorModels[0];
|
||||
};
|
||||
|
||||
export const getModel = (model?: string) => {
|
||||
|
Reference in New Issue
Block a user