Files
FastGPT/packages/service/support/wallet/usage/controller.ts
Archer 42a8184ea0 v4.6.9-alpha (#918)
Co-authored-by: Mufei <327958099@qq.com>
Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
2024-03-04 00:05:25 +08:00

57 lines
1.2 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,
tokens: 0,
amount: 0
},
{
moduleName: 'support.wallet.moduleName.qa',
model: agentModel,
tokens: 0,
amount: 0
},
{
moduleName: 'core.dataset.training.Auto mode',
model: agentModel,
tokens: 0,
amount: 0
}
]
}
],
{ session }
);
return { billId: String(_id) };
};