feat: 摘要拆分

This commit is contained in:
archer
2023-03-26 22:09:59 +08:00
parent 888642f154
commit 3e4487ad9a
20 changed files with 397 additions and 83 deletions

View File

@@ -2,6 +2,7 @@ import { connectToDatabase, Bill, User } from '../mongo';
import { modelList, ChatModelNameEnum } from '@/constants/model';
import { encode } from 'gpt-token-utils';
import { formatPrice } from '@/utils/user';
import type { DataType } from '@/types/data';
export const pushChatBill = async ({
modelName,
@@ -59,7 +60,15 @@ export const pushChatBill = async ({
}
};
export const pushSplitDataBill = async ({ userId, text }: { userId: string; text: string }) => {
export const pushSplitDataBill = async ({
userId,
text,
type
}: {
userId: string;
text: string;
type: DataType;
}) => {
await connectToDatabase();
let billId;
@@ -83,7 +92,7 @@ export const pushSplitDataBill = async ({ userId, text }: { userId: string; text
// 插入 Bill 记录
const res = await Bill.create({
userId,
type: 'splitData',
type,
modelName: ChatModelNameEnum.GPT35,
textLen: text.length,
tokenLen: tokens.length,