Commit 5be57da4 by archer

fix: v1 api

parent 057c3411
...@@ -65,10 +65,14 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex ...@@ -65,10 +65,14 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
const modelConstantsData = ChatModelMap[model.chat.chatModel]; const modelConstantsData = ChatModelMap[model.chat.chatModel];
const prompt = prompts[prompts.length - 1]; const prompt = prompts[prompts.length - 1];
const { userSystemPrompt = [], quotePrompt = [] } = await (async () => { const {
userSystemPrompt = [],
userLimitPrompt = [],
quotePrompt = []
} = await (async () => {
// 使用了知识库搜索 // 使用了知识库搜索
if (model.chat.relatedKbs?.length > 0) { if (model.chat.relatedKbs?.length > 0) {
const { userSystemPrompt, quotePrompt } = await appKbSearch({ const { quotePrompt, userSystemPrompt, userLimitPrompt } = await appKbSearch({
model, model,
userId, userId,
fixedQuote: [], fixedQuote: [],
...@@ -78,21 +82,29 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex ...@@ -78,21 +82,29 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
}); });
return { return {
userSystemPrompt: userSystemPrompt ? [userSystemPrompt] : [], userSystemPrompt,
userLimitPrompt,
quotePrompt: [quotePrompt] quotePrompt: [quotePrompt]
}; };
} }
if (model.chat.systemPrompt) { return {
return { userSystemPrompt: model.chat.systemPrompt
userSystemPrompt: [ ? [
{ {
obj: ChatRoleEnum.System, obj: ChatRoleEnum.System,
value: model.chat.systemPrompt value: model.chat.systemPrompt
} }
] ]
}; : [],
} userLimitPrompt: model.chat.limitPrompt
return {}; ? [
{
obj: ChatRoleEnum.Human,
value: model.chat.limitPrompt
}
]
: []
};
})(); })();
// search result is empty // search result is empty
...@@ -102,7 +114,13 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex ...@@ -102,7 +114,13 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
} }
// 读取对话内容 // 读取对话内容
const completePrompts = [...quotePrompt, ...prompts.slice(0, -1), ...userSystemPrompt, prompt]; const completePrompts = [
...quotePrompt,
...userSystemPrompt,
...prompts.slice(0, -1),
...userLimitPrompt,
prompt
];
// 计算温度 // 计算温度
const temperature = (modelConstantsData.maxTemperature * (model.chat.temperature / 10)).toFixed( const temperature = (modelConstantsData.maxTemperature * (model.chat.temperature / 10)).toFixed(
......
...@@ -238,6 +238,7 @@ export const V2_StreamResponse = async ({ ...@@ -238,6 +238,7 @@ export const V2_StreamResponse = async ({
} }
if (error) { if (error) {
console.log(error);
return Promise.reject(error); return Promise.reject(error);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment