docs and embedding bill

This commit is contained in:
archer
2023-06-05 18:58:38 +08:00
parent 1111f07fa7
commit 942aeeac2e
11 changed files with 66 additions and 32 deletions

View File

@@ -82,7 +82,8 @@ export async function generateVector(): Promise<any> {
const vectors = await openaiEmbedding({
input: dataItems.map((item) => item.q),
userId,
type: 'training'
type: 'training',
mustPay: true
});
// 生成结果插入到 pg

View File

@@ -1,5 +1,11 @@
import { connectToDatabase, Bill, User, ShareChat } from '../mongo';
import { ChatModelMap, OpenAiChatEnum, ChatModelType, embeddingModel } from '@/constants/model';
import {
ChatModelMap,
OpenAiChatEnum,
ChatModelType,
embeddingModel,
embeddingPrice
} from '@/constants/model';
import { BillTypeEnum } from '@/constants/user';
export const pushChatBill = async ({
@@ -145,11 +151,9 @@ export const pushGenerateVectorBill = async ({
await connectToDatabase();
try {
const unitPrice = 0.4;
// 计算价格. 至少为1
const price = 0;
// let price = unitPrice * tokenLen;
// price = price > 1 ? price : 1;
let price = embeddingPrice * tokenLen;
price = price > 1 ? price : 1;
// 插入 Bill 记录
const res = await Bill.create({

View File

@@ -28,7 +28,7 @@ const UserSchema = new Schema({
balance: {
// 平台余额,不可提现
type: Number,
default: 0.5 * PRICE_SCALE
default: 2 * PRICE_SCALE
},
inviterId: {
// 谁邀请注册的