import { sequelize } from '@/modules/sequelize.ts'; import { DataTypes, Model } from 'sequelize'; export class AiAgent extends Model { declare id: string; declare type: string; declare model: string; declare baseUrl: string; declare apiKey: string; declare temperature: number; declare cache: string; declare cacheName: string; declare status: string; declare data: any; declare description: string; declare key: string; } // 获取AIAgent的属性 export type AiProperties = { id: string; type: string; model: string; baseUrl: string; apiKey?: string; temperature?: number; cache?: string; cacheName?: string; data?: any; description?: string; }; AiAgent.init( { id: { type: DataTypes.UUID, primaryKey: true, defaultValue: DataTypes.UUIDV4, }, type: { type: DataTypes.STRING, allowNull: false, }, description: { type: DataTypes.TEXT, allowNull: true, }, status: { type: DataTypes.STRING, defaultValue: 'open', }, model: { type: DataTypes.STRING, allowNull: false, }, baseUrl: { type: DataTypes.STRING, allowNull: false, }, apiKey: { type: DataTypes.STRING, allowNull: false, }, key: { type: DataTypes.STRING, allowNull: false, unique: true, }, temperature: { type: DataTypes.FLOAT, allowNull: true, }, cache: { type: DataTypes.STRING, allowNull: true, }, cacheName: { type: DataTypes.STRING, allowNull: true, }, data: { type: DataTypes.JSON, allowNull: true, defaultValue: {}, }, }, { sequelize, tableName: 'ai_agent', paranoid: true, }, ); AiAgent.sync({ alter: true, logging: false }).catch((e) => { console.error('AiAgent sync error', e); });