V4.8.17 feature (#3493)

* 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>
This commit is contained in:
Archer
2024-12-30 10:13:25 +08:00
committed by GitHub
parent da2831b948
commit 50bf7f9a3b
46 changed files with 467 additions and 230 deletions

View File

@@ -1,7 +1,7 @@
import { connectionMongo, getMongoModel, type Model } from '../../../common/mongo';
const { Schema, model, models } = connectionMongo;
const { Schema } = connectionMongo;
import { UsageSchemaType } from '@fastgpt/global/support/wallet/usage/type';
import { UsageSourceMap } from '@fastgpt/global/support/wallet/usage/constants';
import { UsageSourceEnum } from '@fastgpt/global/support/wallet/usage/constants';
import {
TeamCollectionName,
TeamMemberCollectionName
@@ -22,7 +22,7 @@ const UsageSchema = new Schema({
},
source: {
type: String,
enum: Object.keys(UsageSourceMap),
enum: Object.values(UsageSourceEnum),
required: true
},
appName: {
@@ -65,7 +65,7 @@ try {
// timer task. clear dead team
// UsageSchema.index({ teamId: 1, time: -1 }, { background: true });
UsageSchema.index({ time: 1 }, { background: true, expireAfterSeconds: 720 * 24 * 60 * 60 });
UsageSchema.index({ time: 1 }, { background: true, expireAfterSeconds: 360 * 24 * 60 * 60 });
} catch (error) {
console.log(error);
}