|
@@ -18,17 +18,17 @@ type Usage struct {
|
|
func AddCreditUsage(tx *ent.Tx, ctx context.Context,
|
|
func AddCreditUsage(tx *ent.Tx, ctx context.Context,
|
|
agentId string, userId string, departmentId uint64,
|
|
agentId string, userId string, departmentId uint64,
|
|
question *string, answer *string,
|
|
question *string, answer *string,
|
|
- originalData *custom_types.OriginalData, chatData *Usage) error {
|
|
|
|
|
|
+ originalData *custom_types.OriginalData, chatData *Usage, model string) error {
|
|
// 积分明细表记录使用量
|
|
// 积分明细表记录使用量
|
|
- modelName, price := GetModelPrice()
|
|
|
|
|
|
+ modelName, price := GetModelPrice(model)
|
|
number := ComputePrice(price, chatData.TotalTokens)
|
|
number := ComputePrice(price, chatData.TotalTokens)
|
|
-
|
|
|
|
|
|
+
|
|
// 记录Token使用信息
|
|
// 记录Token使用信息
|
|
usageDetailItem, err := tx.UsageDetail.Create().
|
|
usageDetailItem, err := tx.UsageDetail.Create().
|
|
- SetType(3). //1-微信 2-名片 3-智能体
|
|
|
|
- SetBotID(agentId). //智能体ID
|
|
|
|
|
|
+ SetType(3). //1-微信 2-名片 3-智能体
|
|
|
|
+ SetBotID(agentId). //智能体ID
|
|
SetReceiverID(userId). //接收者userID
|
|
SetReceiverID(userId). //接收者userID
|
|
- SetApp(8). //8-智能体
|
|
|
|
|
|
+ SetApp(8). //8-智能体
|
|
SetSessionID(0).
|
|
SetSessionID(0).
|
|
SetRequest(*question).
|
|
SetRequest(*question).
|
|
SetResponse(*answer).
|
|
SetResponse(*answer).
|