perf: token params
This commit is contained in:
parent
651eb1bf6b
commit
9a0c92629b
@ -29,6 +29,11 @@ export const searchKb = async ({
|
|||||||
}[];
|
}[];
|
||||||
}> => {
|
}> => {
|
||||||
async function search(textArr: string[] = []) {
|
async function search(textArr: string[] = []) {
|
||||||
|
const limitMap: Record<ModelVectorSearchModeEnum, number> = {
|
||||||
|
[ModelVectorSearchModeEnum.hightSimilarity]: 15,
|
||||||
|
[ModelVectorSearchModeEnum.noContext]: 15,
|
||||||
|
[ModelVectorSearchModeEnum.lowSimilarity]: 20
|
||||||
|
};
|
||||||
// 获取提示词的向量
|
// 获取提示词的向量
|
||||||
const { vectors: promptVectors } = await openaiCreateEmbedding({
|
const { vectors: promptVectors } = await openaiCreateEmbedding({
|
||||||
userOpenAiKey,
|
userOpenAiKey,
|
||||||
@ -48,7 +53,7 @@ export const searchKb = async ({
|
|||||||
`vector <=> '[${promptVector}]' < ${similarity}`
|
`vector <=> '[${promptVector}]' < ${similarity}`
|
||||||
],
|
],
|
||||||
order: [{ field: 'vector', mode: `<=> '[${promptVector}]'` }],
|
order: [{ field: 'vector', mode: `<=> '[${promptVector}]'` }],
|
||||||
limit: 20
|
limit: limitMap[model.chat.searchMode]
|
||||||
}).then((res) => res.rows)
|
}).then((res) => res.rows)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -40,7 +40,7 @@ export const lafClaudChat = async ({
|
|||||||
headers: {
|
headers: {
|
||||||
Authorization: apiKey
|
Authorization: apiKey
|
||||||
},
|
},
|
||||||
timeout: stream ? 40000 : 240000,
|
timeout: stream ? 60000 : 240000,
|
||||||
responseType: stream ? 'stream' : 'json'
|
responseType: stream ? 'stream' : 'json'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@ -73,7 +73,7 @@ export const chatResponse = async ({
|
|||||||
const filterMessages = ChatContextFilter({
|
const filterMessages = ChatContextFilter({
|
||||||
model,
|
model,
|
||||||
prompts: messages,
|
prompts: messages,
|
||||||
maxTokens: Math.ceil(ChatModelMap[model].contextMaxToken * 0.9)
|
maxTokens: Math.ceil(ChatModelMap[model].contextMaxToken * 0.85)
|
||||||
});
|
});
|
||||||
|
|
||||||
const adaptMessages = adaptChatItem_openAI({ messages: filterMessages });
|
const adaptMessages = adaptChatItem_openAI({ messages: filterMessages });
|
||||||
@ -90,7 +90,7 @@ export const chatResponse = async ({
|
|||||||
stop: ['.!?。']
|
stop: ['.!?。']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
timeout: stream ? 40000 : 240000,
|
timeout: stream ? 60000 : 240000,
|
||||||
responseType: stream ? 'stream' : 'json',
|
responseType: stream ? 'stream' : 'json',
|
||||||
...axiosConfig()
|
...axiosConfig()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user