Skip to content

Commit e367265

Browse files
authored
feat: function call prompt version (#331)
1 parent 7e0deb2 commit e367265

File tree

12 files changed

+363
-119
lines changed

12 files changed

+363
-119
lines changed

client/data/config.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,21 @@
6262
"name": "GPT35-16k",
6363
"maxToken": 16000,
6464
"price": 0
65+
},
66+
"ExtractModel": {
67+
"model": "gpt-3.5-turbo-16k",
68+
"functionCall": false,
69+
"name": "GPT35-16k",
70+
"maxToken": 16000,
71+
"price": 0,
72+
"prompt": ""
73+
},
74+
"CQModel": {
75+
"model": "gpt-3.5-turbo-16k",
76+
"functionCall": false,
77+
"name": "GPT35-16k",
78+
"maxToken": 16000,
79+
"price": 0,
80+
"prompt": ""
6581
}
6682
}

client/public/docs/versionIntro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Fast GPT V4.4.3
1+
### Fast GPT V4.4.4
22

33
1. 去除 - 限定词。目前旧应用仍生效,9/25 后全面去除,请及时替换。
44
2. 新增 - 引用模板/引用提示词设置,可以 DIY 引用内容的格式,从而更好的适配场景。

client/src/components/ChatBox/ResponseTags.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const ResponseTags = ({
5656

5757
return responseData.length === 0 ? null : (
5858
<Flex alignItems={'center'} mt={2} flexWrap={'wrap'}>
59-
{chatAccount === 1 ? (
59+
{chatAccount === 1 && (
6060
<>
6161
{quoteList.length > 0 && (
6262
<MyTooltip label="查看引用">
@@ -83,7 +83,8 @@ const ResponseTags = ({
8383
</MyTooltip>
8484
)}
8585
</>
86-
) : (
86+
)}
87+
{chatAccount > 1 && (
8788
<Tag colorSchema="blue" {...TagStyles}>
8889
多组 AI 对话
8990
</Tag>

client/src/pages/api/system/getInitData.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { readFileSync } from 'fs';
55
import {
66
type QAModelItemType,
77
type ChatModelItemType,
8-
type VectorModelItemType
8+
type VectorModelItemType,
9+
FunctionModelItemType
910
} from '@/types/model';
1011

1112
export type InitDateResponse = {
@@ -83,6 +84,22 @@ const defaultQAModel = {
8384
maxToken: 16000,
8485
price: 0
8586
};
87+
const defaultExtractModel: FunctionModelItemType = {
88+
model: 'gpt-3.5-turbo-16k',
89+
name: 'GPT35-16k',
90+
maxToken: 16000,
91+
price: 0,
92+
prompt: '',
93+
functionCall: true
94+
};
95+
const defaultCQModel: FunctionModelItemType = {
96+
model: 'gpt-3.5-turbo-16k',
97+
name: 'GPT35-16k',
98+
maxToken: 16000,
99+
price: 0,
100+
prompt: '',
101+
functionCall: true
102+
};
86103

87104
const defaultVectorModels: VectorModelItemType[] = [
88105
{
@@ -114,6 +131,8 @@ export async function getInitConfig() {
114131
global.feConfigs = res.FeConfig ? { ...defaultFeConfigs, ...res.FeConfig } : defaultFeConfigs;
115132
global.chatModels = res.ChatModels || defaultChatModels;
116133
global.qaModel = res.QAModel || defaultQAModel;
134+
global.extractModel = res.ExtractModel || defaultExtractModel;
135+
global.cqModel = res.CQModel || defaultCQModel;
117136
global.vectorModels = res.VectorModels || defaultVectorModels;
118137
} catch (error) {
119138
setDefaultData();

client/src/prompts/core/agent.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,45 @@ A2:
1414
我的文本:"""{{text}}"""`,
1515
defaultTheme: '它们可能包含多个主题内容'
1616
};
17+
18+
export const Prompt_ExtractJson = `你可以从 "对话记录" 中提取指定信息,并返回一个 JSON 对象,JSON 对象要求:
19+
1. JSON 对象仅包含字段说明中的值。
20+
2. 字段说明中的 required 决定 JSON 对象是否必须存在该字段。
21+
3. 必须存在的字段,值可以为空字符串或根据提取要求来设置,不能随机生成值。
22+
23+
提取要求:
24+
"""
25+
{{description}}
26+
"""
27+
28+
字段说明:
29+
"""
30+
{{json}}
31+
"""
32+
33+
对话记录:
34+
"""
35+
{{text}}
36+
"""
37+
`;
38+
39+
export const Prompt_CQJson = `我会给你几个问题类型,请参考额外的背景知识(可能为空)和对话内容,判断我本次的问题类型,并返回对应类型的 ID,格式为 JSON 字符串:
40+
"""
41+
'{"type":"问题类型的 ID"}'
42+
"""
43+
44+
问题类型:
45+
"""
46+
{{typeList}}
47+
"""
48+
49+
额外背景知识:
50+
"""
51+
{{systemPrompt}}
52+
"""
53+
54+
对话内容:
55+
"""
56+
{{text}}
57+
"""
58+
`;

client/src/service/events/pushBill.ts

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,44 @@ export const pushTaskBill = async ({
2020
shareId?: string;
2121
response: ChatHistoryItemResType[];
2222
}) => {
23-
const total = response.reduce((sum, item) => sum + item.price, 0);
23+
try {
24+
const total = response.reduce((sum, item) => sum + item.price, 0);
2425

25-
await Promise.allSettled([
26-
Bill.create({
27-
userId,
28-
appName,
29-
appId,
30-
total,
26+
await Promise.allSettled([
27+
Bill.create({
28+
userId,
29+
appName,
30+
appId,
31+
total,
32+
source,
33+
list: response.map((item) => ({
34+
moduleName: item.moduleName,
35+
amount: item.price || 0,
36+
model: item.model,
37+
tokenLen: item.tokens
38+
}))
39+
}),
40+
User.findByIdAndUpdate(userId, {
41+
$inc: { balance: -total }
42+
}),
43+
...(shareId
44+
? [
45+
updateShareChatBill({
46+
shareId,
47+
total
48+
})
49+
]
50+
: [])
51+
]);
52+
53+
addLog.info(`finish completions`, {
3154
source,
32-
list: response.map((item) => ({
33-
moduleType: item.moduleType,
34-
amount: item.price || 0,
35-
model: item.model,
36-
tokenLen: item.tokens
37-
}))
38-
}),
39-
User.findByIdAndUpdate(userId, {
40-
$inc: { balance: -total }
41-
}),
42-
...(shareId
43-
? [
44-
updateShareChatBill({
45-
shareId,
46-
total
47-
})
48-
]
49-
: [])
50-
]);
51-
52-
addLog.info(`finish completions`, {
53-
source,
54-
userId,
55-
price: formatPrice(total)
56-
});
55+
userId,
56+
price: formatPrice(total)
57+
});
58+
} catch (error) {
59+
addLog.error(`pushTaskBill error`, error);
60+
}
5761
};
5862

5963
export const updateShareChatBill = async ({

client/src/service/models/bill.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,7 @@ const BillSchema = new Schema({
3131
default: BillSourceEnum.fastgpt
3232
},
3333
list: {
34-
type: [
35-
{
36-
moduleName: {
37-
type: String,
38-
required: true
39-
},
40-
amount: {
41-
type: Number,
42-
required: true
43-
},
44-
model: {
45-
type: String
46-
},
47-
tokenLen: {
48-
type: Number
49-
}
50-
}
51-
],
34+
type: Array,
5235
default: []
5336
}
5437
});

0 commit comments

Comments
 (0)