mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
feat: default message
This commit is contained in:
@@ -22,7 +22,8 @@
|
||||
"contextMaxToken": 4000,
|
||||
"quoteMaxToken": 2000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 1.5
|
||||
"price": 1.5,
|
||||
"defaultSystem": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
@@ -30,15 +31,8 @@
|
||||
"contextMaxToken": 16000,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 3
|
||||
},
|
||||
{
|
||||
"model": "ERNIE-Bot",
|
||||
"name": "文心一言",
|
||||
"contextMaxToken": 3000,
|
||||
"quoteMaxToken": 1500,
|
||||
"maxTemperature": 1,
|
||||
"price": 1.2
|
||||
"price": 3,
|
||||
"defaultSystem": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-4",
|
||||
@@ -46,7 +40,8 @@
|
||||
"contextMaxToken": 8000,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 45
|
||||
"price": 45,
|
||||
"defaultSystem": ""
|
||||
}
|
||||
],
|
||||
"QAModels": [
|
||||
|
@@ -16,6 +16,7 @@ import { countModelPrice } from '@/service/events/pushBill';
|
||||
import { ChatModelItemType } from '@/types/model';
|
||||
import { UserModelSchema } from '@/types/mongoSchema';
|
||||
import { textCensor } from '@/service/api/plugins';
|
||||
import { ChatCompletionRequestMessageRoleEnum } from 'openai';
|
||||
|
||||
export type ChatProps = {
|
||||
res: NextApiResponse;
|
||||
@@ -66,13 +67,15 @@ export const dispatchChatCompletion = async (props: Record<string, any>): Promis
|
||||
model: modelConstantsData
|
||||
});
|
||||
|
||||
await textCensor({
|
||||
text: `${systemPrompt}
|
||||
${quotePrompt}
|
||||
${limitPrompt}
|
||||
${userChatInput}
|
||||
`
|
||||
});
|
||||
if (modelConstantsData.censor) {
|
||||
await textCensor({
|
||||
text: `${systemPrompt}
|
||||
${quotePrompt}
|
||||
${limitPrompt}
|
||||
${userChatInput}
|
||||
`
|
||||
});
|
||||
}
|
||||
|
||||
const { messages, filterMessages } = getChatMessages({
|
||||
model: modelConstantsData,
|
||||
@@ -98,7 +101,17 @@ export const dispatchChatCompletion = async (props: Record<string, any>): Promis
|
||||
model,
|
||||
temperature,
|
||||
max_tokens,
|
||||
messages,
|
||||
messages: [
|
||||
...(modelConstantsData.defaultSystem
|
||||
? [
|
||||
{
|
||||
role: ChatCompletionRequestMessageRoleEnum.System,
|
||||
content: modelConstantsData.defaultSystem
|
||||
}
|
||||
]
|
||||
: []),
|
||||
...messages
|
||||
],
|
||||
// frequency_penalty: 0.5, // 越大,重复内容越少
|
||||
// presence_penalty: -0.5, // 越大,越容易出现新内容
|
||||
stream
|
||||
|
2
client/src/types/model.d.ts
vendored
2
client/src/types/model.d.ts
vendored
@@ -5,6 +5,8 @@ export type ChatModelItemType = {
|
||||
quoteMaxToken: number;
|
||||
maxTemperature: number;
|
||||
price: number;
|
||||
censor?: boolean;
|
||||
defaultSystem?: string;
|
||||
};
|
||||
export type QAModelItemType = {
|
||||
model: string;
|
||||
|
Reference in New Issue
Block a user