ai-query对接新版freesun-agent接口的分支
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

129 lines
3.0 KiB

'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const QuotaEvent = sequelize.define('quotaEvent', {
id: {
type: DataTypes.BIGINT,
allowNull: false,
primaryKey: true,
autoIncrement: true,
field: 'id',
comment: 'Primary key',
},
userId: {
type: DataTypes.BIGINT,
allowNull: false,
field: 'user_id',
comment: 'User id',
},
docId: {
type: DataTypes.BIGINT,
allowNull: false,
field: 'doc_id',
comment: 'Document id',
},
docKind: {
type: DataTypes.STRING(16),
allowNull: true,
field: 'doc_kind',
comment: 'Document kind: bid/plan',
},
chapterKey: {
type: DataTypes.STRING(128),
allowNull: true,
field: 'chapter_key',
comment: 'Chapter key',
},
eventType: {
type: DataTypes.STRING(16),
allowNull: false,
field: 'event_type',
comment: 'Event type: create/rewrite/generate',
},
action: {
type: DataTypes.STRING(32),
allowNull: true,
field: 'action',
comment: 'Action detail',
},
source: {
type: DataTypes.STRING(32),
allowNull: false,
defaultValue: 'manual',
field: 'source',
comment: 'Event source',
},
inputTokens: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
field: 'input_tokens',
comment: 'Input tokens',
},
outputTokens: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
field: 'output_tokens',
comment: 'Output tokens',
},
embeddingTokens: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
field: 'embedding_tokens',
comment: 'Embedding tokens',
},
totalTokens: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
field: 'total_tokens',
comment: 'Total tokens',
},
tokenPerYuan: {
type: DataTypes.DECIMAL(18, 6),
allowNull: true,
field: 'token_per_yuan',
comment: 'Token-to-yuan snapshot',
},
amountYuan: {
type: DataTypes.DECIMAL(18, 6),
allowNull: false,
defaultValue: 0,
field: 'amount_yuan',
comment: 'Billed amount',
},
billingStatus: {
type: DataTypes.STRING(32),
allowNull: false,
defaultValue: 'skip',
field: 'billing_status',
comment: 'Billing status',
},
requestId: {
type: DataTypes.STRING(128),
allowNull: true,
field: 'request_id',
comment: 'External billing request id',
},
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
field: 'created_at',
comment: 'Created at',
},
}, {
tableName: 'quota_event',
comment: 'Quota and billing event table',
timestamps: false,
indexes: [],
});
dc.models.QuotaEvent = QuotaEvent;
return QuotaEvent;
};