mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-03 05:19:51 +00:00
perf: bill
This commit is contained in:
@@ -5,7 +5,6 @@ import { ChatItemType } from '@/types/chat';
|
||||
import { ChatCompletionRequestMessageRoleEnum } from 'openai';
|
||||
import { ChatRoleEnum } from '@/constants/chat';
|
||||
import type { MessageItemType } from '@/pages/api/openapi/v1/chat/completions';
|
||||
import { ChatModelMap, OpenAiChatEnum } from '@/constants/model';
|
||||
import type { AppModuleItemType } from '@/types/app';
|
||||
import type { FlowModuleItemType } from '@/types/flow';
|
||||
import type { Edge, Node } from 'reactflow';
|
||||
@@ -16,12 +15,10 @@ const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 6);
|
||||
export const adaptBill = (bill: BillSchema): UserBillType => {
|
||||
return {
|
||||
id: bill._id,
|
||||
type: bill.type,
|
||||
modelName: ChatModelMap[bill.modelName as `${OpenAiChatEnum}`]?.name || bill.modelName,
|
||||
source: bill.source,
|
||||
time: bill.time,
|
||||
textLen: bill.textLen,
|
||||
tokenLen: bill.tokenLen,
|
||||
price: formatPrice(bill.price)
|
||||
total: formatPrice(bill.total),
|
||||
appName: bill.appName
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -50,10 +50,10 @@ export const adaptChatItem_openAI = ({
|
||||
|
||||
export function countOpenAIToken({
|
||||
messages,
|
||||
model
|
||||
model = 'gpt-3.5-turbo'
|
||||
}: {
|
||||
messages: ChatItemType[];
|
||||
model: `${OpenAiChatEnum}`;
|
||||
model?: string;
|
||||
}) {
|
||||
const diffVal = model.startsWith('gpt-3.5-turbo') ? 3 : 2;
|
||||
|
||||
@@ -74,7 +74,7 @@ export const openAiSliceTextByToken = ({
|
||||
text,
|
||||
length
|
||||
}: {
|
||||
model: `${OpenAiChatEnum}`;
|
||||
model: string;
|
||||
text: string;
|
||||
length: number;
|
||||
}) => {
|
||||
|
Reference in New Issue
Block a user