package app

import (
	"git.echol.cn/loser/ai_proxy/server/global"
)

// AiProvider AI提供商配置
type AiProvider struct {
	global.GVA_MODEL
	Name       string `json:"name" gorm:"type:varchar(100);not null;uniqueIndex:idx_user_provider;comment:提供商名称"`
	Type       string `json:"type" gorm:"type:varchar(50);not null;comment:提供商类型"` // openai, claude, gemini
	BaseURL    string `json:"base_url" gorm:"type:varchar(255);not null;comment:API基础URL"`
	APIKey     string `json:"api_key" gorm:"type:varchar(255);not null;comment:API密钥"`
	Model      string `json:"model" gorm:"type:varchar(100);comment:默认模型"`
	Enabled    bool   `json:"enabled" gorm:"default:true;comment:是否启用"`
	IsDefault  bool   `json:"is_default" gorm:"default:false;comment:是否为默认提供商"`
	Priority   int    `json:"priority" gorm:"default:0;comment:优先级"`
	MaxRetries int    `json:"max_retries" gorm:"default:3;comment:最大重试次数"`
	Timeout    int    `json:"timeout" gorm:"default:60;comment:超时时间(秒)"`
	UserID     uint   `json:"user_id" gorm:"index:idx_user_provider;comment:用户ID"`
}

func (AiProvider) TableName() string {
	return "ai_providers"
}
