mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 03:48:24 +00:00
v4.4.5-3 (#357)
This commit is contained in:
@@ -5,6 +5,7 @@ import { ChatHistoryItemResType } from '@/types/chat';
|
||||
import { formatPrice } from '@fastgpt/common/bill/index';
|
||||
import { addLog } from '@/service/utils/tools';
|
||||
import type { CreateBillType } from '@/types/common/bill';
|
||||
import { defaultQGModel } from '@/pages/api/system/getInitData';
|
||||
|
||||
async function createBill(data: CreateBillType) {
|
||||
try {
|
||||
@@ -170,3 +171,22 @@ export const countModelPrice = ({ model, tokens }: { model: string; tokens: numb
|
||||
if (!modelData) return 0;
|
||||
return modelData.price * tokens;
|
||||
};
|
||||
|
||||
export const pushQuestionGuideBill = ({ tokens, userId }: { tokens: number; userId: string }) => {
|
||||
const qgModel = global.qgModel || defaultQGModel;
|
||||
const total = qgModel.price * tokens;
|
||||
createBill({
|
||||
userId,
|
||||
appName: '问题指引',
|
||||
total,
|
||||
source: BillSourceEnum.fastgpt,
|
||||
list: [
|
||||
{
|
||||
moduleName: '问题指引',
|
||||
amount: total,
|
||||
model: qgModel.name,
|
||||
tokenLen: tokens
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
@@ -24,7 +24,7 @@ export const dispatchAnswer = (props: Record<string, any>): AnswerResponse => {
|
||||
res,
|
||||
event: detail ? sseResponseEventEnum.answer : undefined,
|
||||
data: textAdaptGptResponse({
|
||||
text: text.replace(/\\n/g, '\n')
|
||||
text: text.replace?.(/\\n/g, '\n') || ''
|
||||
})
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user