mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-21 11:43:56 +00:00

* split tokens into input and output (#3477) * split tokens into input and output * query extension & tool call & question guide * fix * perf: input and output tokens * perf: tool call if else * perf: remove code * fix: extract usage count * fix: qa usage count --------- Co-authored-by: heheer <heheer@sealos.io>
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
import { UsageSourceEnum } from '@fastgpt/global/support/wallet/usage/constants';
|
|
import { MongoUsage } from './schema';
|
|
import { ClientSession } from '../../../common/mongo';
|
|
|
|
export const createTrainingUsage = async ({
|
|
teamId,
|
|
tmbId,
|
|
appName,
|
|
billSource,
|
|
vectorModel,
|
|
agentModel,
|
|
session
|
|
}: {
|
|
teamId: string;
|
|
tmbId: string;
|
|
appName: string;
|
|
billSource: UsageSourceEnum;
|
|
vectorModel: string;
|
|
agentModel: string;
|
|
session?: ClientSession;
|
|
}) => {
|
|
const [{ _id }] = await MongoUsage.create(
|
|
[
|
|
{
|
|
teamId,
|
|
tmbId,
|
|
appName,
|
|
source: billSource,
|
|
totalPoints: 0,
|
|
list: [
|
|
{
|
|
moduleName: 'support.wallet.moduleName.index',
|
|
model: vectorModel,
|
|
amount: 0,
|
|
inputTokens: 0,
|
|
outputTokens: 0
|
|
},
|
|
{
|
|
moduleName: 'support.wallet.moduleName.qa',
|
|
model: agentModel,
|
|
amount: 0,
|
|
inputTokens: 0,
|
|
outputTokens: 0
|
|
},
|
|
{
|
|
moduleName: 'core.dataset.training.Auto mode',
|
|
model: agentModel,
|
|
amount: 0,
|
|
inputTokens: 0,
|
|
outputTokens: 0
|
|
}
|
|
]
|
|
}
|
|
],
|
|
{ session }
|
|
);
|
|
|
|
return { billId: String(_id) };
|
|
};
|