Revert "sub plan page (#885)" (#886)

This reverts commit 443ad37b6a.
This commit is contained in:
Archer
2024-02-23 17:48:15 +08:00
committed by GitHub
parent 443ad37b6a
commit fd9b6291af
246 changed files with 4281 additions and 6286 deletions

View File

@@ -1,6 +1,5 @@
import type { ChatMessageItemType } from '@fastgpt/global/core/ai/type.d';
import { getAIApi } from '../config';
import { countGptMessagesChars } from '../../chat/utils';
export const Prompt_QuestionGuide = `我不太清楚问你什么问题,请帮我生成 3 个问题引导我继续提问。问题的长度应小于20个字符按 JSON 格式返回: ["问题1", "问题2", "问题3"]`;
@@ -11,13 +10,6 @@ export async function createQuestionGuide({
messages: ChatMessageItemType[];
model: string;
}) {
const concatMessages: ChatMessageItemType[] = [
...messages,
{
role: 'user',
content: Prompt_QuestionGuide
}
];
const ai = getAIApi({
timeout: 480000
});
@@ -25,21 +17,28 @@ export async function createQuestionGuide({
model: model,
temperature: 0.1,
max_tokens: 200,
messages: concatMessages,
messages: [
...messages,
{
role: 'user',
content: Prompt_QuestionGuide
}
],
stream: false
});
const answer = data.choices?.[0]?.message?.content || '';
const inputTokens = data.usage?.prompt_tokens || 0;
const outputTokens = data.usage?.completion_tokens || 0;
const start = answer.indexOf('[');
const end = answer.lastIndexOf(']');
const charsLength = countGptMessagesChars(concatMessages);
if (start === -1 || end === -1) {
return {
result: [],
charsLength: 0
inputTokens,
outputTokens
};
}
@@ -51,12 +50,14 @@ export async function createQuestionGuide({
try {
return {
result: JSON.parse(jsonStr),
charsLength
inputTokens,
outputTokens
};
} catch (error) {
return {
result: [],
charsLength: 0
inputTokens,
outputTokens
};
}
}