mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-22 08:00:53 +00:00
feat: improve agent module logic (#12226)
* feat: openclaw supports configuring multiple models * feat: change openclaw bind type * feat: change openclaw bind type * feat: improve agent module logic
This commit is contained in:
+9
-25
@@ -8,15 +8,9 @@ type AgentCreateReq struct {
|
||||
WebUIPort int `json:"webUIPort" validate:"required"`
|
||||
BridgePort int `json:"bridgePort"`
|
||||
AllowedOrigins []string `json:"allowedOrigins"`
|
||||
AgentType string `json:"agentType"`
|
||||
Provider string `json:"provider"`
|
||||
AgentType string `json:"agentType" validate:"required,oneof=openclaw copaw"`
|
||||
Model string `json:"model"`
|
||||
APIType string `json:"apiType"`
|
||||
MaxTokens int `json:"maxTokens"`
|
||||
ContextWindow int `json:"contextWindow"`
|
||||
AccountID uint `json:"accountId"`
|
||||
APIKey string `json:"apiKey"`
|
||||
BaseURL string `json:"baseURL"`
|
||||
Token string `json:"token"`
|
||||
TaskID string `json:"taskID"`
|
||||
Advanced bool `json:"advanced"`
|
||||
@@ -110,27 +104,20 @@ type AgentAccountCreateReq struct {
|
||||
APIKey string `json:"apiKey" validate:"required"`
|
||||
RememberAPIKey bool `json:"rememberApiKey"`
|
||||
BaseURL string `json:"baseURL"`
|
||||
Model string `json:"model"`
|
||||
Models []AgentAccountModel `json:"models"`
|
||||
APIType string `json:"apiType"`
|
||||
MaxTokens int `json:"maxTokens"`
|
||||
ContextWindow int `json:"contextWindow"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
type AgentAccountUpdateReq struct {
|
||||
ID uint `json:"id" validate:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
APIKey string `json:"apiKey" validate:"required"`
|
||||
RememberAPIKey bool `json:"rememberApiKey"`
|
||||
BaseURL string `json:"baseURL"`
|
||||
Model string `json:"model"`
|
||||
Models []AgentAccountModel `json:"models"`
|
||||
APIType string `json:"apiType"`
|
||||
MaxTokens int `json:"maxTokens"`
|
||||
ContextWindow int `json:"contextWindow"`
|
||||
Remark string `json:"remark"`
|
||||
SyncAgents bool `json:"syncAgents"`
|
||||
ID uint `json:"id" validate:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
APIKey string `json:"apiKey" validate:"required"`
|
||||
RememberAPIKey bool `json:"rememberApiKey"`
|
||||
BaseURL string `json:"baseURL"`
|
||||
APIType string `json:"apiType"`
|
||||
Remark string `json:"remark"`
|
||||
SyncAgents bool `json:"syncAgents"`
|
||||
}
|
||||
|
||||
type AgentAccountVerifyReq struct {
|
||||
@@ -157,11 +144,8 @@ type AgentAccountInfo struct {
|
||||
APIKey string `json:"apiKey"`
|
||||
RememberAPIKey bool `json:"rememberApiKey"`
|
||||
BaseURL string `json:"baseUrl"`
|
||||
Model string `json:"model"`
|
||||
Models []AgentAccountModel `json:"models"`
|
||||
APIType string `json:"apiType"`
|
||||
MaxTokens int `json:"maxTokens"`
|
||||
ContextWindow int `json:"contextWindow"`
|
||||
Verified bool `json:"verified"`
|
||||
Remark string `json:"remark"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
|
||||
@@ -6,11 +6,7 @@ type AgentAccount struct {
|
||||
Name string `json:"name"`
|
||||
APIKey string `json:"apiKey"`
|
||||
BaseURL string `json:"baseUrl"`
|
||||
Model string `json:"model"`
|
||||
Models string `json:"models" gorm:"type:text"`
|
||||
APIType string `json:"apiType"`
|
||||
MaxTokens int `json:"maxTokens"`
|
||||
ContextWindow int `json:"contextWindow"`
|
||||
RememberAPIKey bool `json:"rememberApiKey"`
|
||||
Verified bool `json:"verified"`
|
||||
Remark string `json:"remark"`
|
||||
|
||||
@@ -20,7 +20,6 @@ type Meta struct {
|
||||
DefaultBaseURL string
|
||||
EnvKey string
|
||||
Models []Model
|
||||
Enabled bool
|
||||
}
|
||||
|
||||
var catalog = map[string]Meta{
|
||||
@@ -30,14 +29,12 @@ var catalog = map[string]Meta{
|
||||
Sort: 10,
|
||||
DefaultBaseURL: "",
|
||||
EnvKey: "CUSTOM_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{},
|
||||
},
|
||||
"ollama": {
|
||||
Key: "ollama",
|
||||
DisplayName: "Ollama",
|
||||
Sort: 15,
|
||||
Enabled: true,
|
||||
},
|
||||
"vllm": {
|
||||
Key: "vllm",
|
||||
@@ -45,7 +42,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 20,
|
||||
DefaultBaseURL: "",
|
||||
EnvKey: "VLLM_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{},
|
||||
},
|
||||
"deepseek": {
|
||||
@@ -54,7 +50,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 25,
|
||||
DefaultBaseURL: "https://api.deepseek.com/v1",
|
||||
EnvKey: "DEEPSEEK_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "deepseek/deepseek-chat", Name: "DeepSeek Chat"},
|
||||
{ID: "deepseek/deepseek-reasoner", Name: "DeepSeek Reasoner"},
|
||||
@@ -67,7 +62,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 30,
|
||||
DefaultBaseURL: "https://coding.dashscope.aliyuncs.com/v1",
|
||||
EnvKey: "QWEN_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "bailian-coding-plan/qwen3.5-plus", Name: "Qwen3.5-Plus"},
|
||||
{ID: "bailian-coding-plan/qwen3-max", Name: "Qwen3-Max"},
|
||||
@@ -85,7 +79,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 35,
|
||||
DefaultBaseURL: "https://ark.cn-beijing.volces.com/api/coding/v3",
|
||||
EnvKey: "ARK_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "ark-coding-plan/doubao-seed-2.0-code", Name: "Doubao-Seed-2.0-Code"},
|
||||
{ID: "ark-coding-plan/doubao-seed-code", Name: "Doubao-Seed-Code"},
|
||||
@@ -101,7 +94,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 40,
|
||||
DefaultBaseURL: "https://open.bigmodel.cn/api/paas/v4",
|
||||
EnvKey: "ZAI_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "zai/glm-5", Name: "GLM-5"},
|
||||
{ID: "zai/glm-4.7", Name: "GLM-4.7"},
|
||||
@@ -115,7 +107,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 45,
|
||||
DefaultBaseURL: "https://api.minimaxi.com/anthropic",
|
||||
EnvKey: "MINIMAX_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "minimax/MiniMax-M2.5", Name: "MiniMax M2.5"},
|
||||
{ID: "minimax/MiniMax-M2.5-highspeed", Name: "MiniMax M2.5 highspeed"},
|
||||
@@ -127,7 +118,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 50,
|
||||
DefaultBaseURL: "https://api.moonshot.cn/v1",
|
||||
EnvKey: "KIMI_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "kimi/kimi-k2.5", Name: "Kimi K2.5"},
|
||||
{ID: "kimi/kimi-k2-0905-preview", Name: "Kimi K2 0905 Preview"},
|
||||
@@ -140,7 +130,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 51,
|
||||
DefaultBaseURL: "https://api.kimi.com/coding/",
|
||||
EnvKey: "KIMI_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "kimi-coding/k2p5", Name: "Kimi K2.5"},
|
||||
},
|
||||
@@ -151,7 +140,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 55,
|
||||
DefaultBaseURL: "https://api.openai.com/v1",
|
||||
EnvKey: "OPENAI_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "openai/codex-mini-latest", Name: "Codex Mini"},
|
||||
{ID: "openai/gpt-4.1", Name: "GPT-4.1"},
|
||||
@@ -167,7 +155,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 56,
|
||||
DefaultBaseURL: "https://openrouter.ai/api/v1",
|
||||
EnvKey: "OPENROUTER_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "openrouter/free", Name: "openrouter/free"},
|
||||
{ID: "openrouter/auto", Name: "openrouter/auto"},
|
||||
@@ -179,7 +166,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 60,
|
||||
DefaultBaseURL: "https://api.anthropic.com",
|
||||
EnvKey: "ANTHROPIC_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "anthropic/claude-3-haiku-20240307", Name: "Claude 3 Haiku"},
|
||||
{ID: "anthropic/claude-3-5-haiku-latest", Name: "Claude 3.5 Haiku"},
|
||||
@@ -194,7 +180,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 65,
|
||||
DefaultBaseURL: "https://generativelanguage.googleapis.com",
|
||||
EnvKey: "GEMINI_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "google/gemini-3-flash-preview", Name: "Gemini 3 Flash Preview"},
|
||||
{ID: "google/gemini-flash-latest", Name: "Gemini Flash Latest"},
|
||||
@@ -207,7 +192,6 @@ var catalog = map[string]Meta{
|
||||
Sort: 70,
|
||||
DefaultBaseURL: "https://api.moonshot.ai/v1",
|
||||
EnvKey: "MOONSHOT_API_KEY",
|
||||
Enabled: true,
|
||||
Models: []Model{
|
||||
{ID: "moonshot/kimi-k2.5", Name: "Kimi K2.5"},
|
||||
{ID: "moonshot/kimi-k2-0905-preview", Name: "Kimi K2 0905 Preview"},
|
||||
@@ -232,11 +216,6 @@ func All() map[string]Meta {
|
||||
return result
|
||||
}
|
||||
|
||||
func IsEnabled(key string) bool {
|
||||
meta, ok := catalog[strings.ToLower(strings.TrimSpace(key))]
|
||||
return ok && meta.Enabled
|
||||
}
|
||||
|
||||
func DefaultBaseURL(key string) (string, bool) {
|
||||
meta, ok := catalog[strings.ToLower(strings.TrimSpace(key))]
|
||||
if !ok || strings.TrimSpace(meta.DefaultBaseURL) == "" {
|
||||
|
||||
@@ -18,6 +18,10 @@ type VerifyRequest struct {
|
||||
Body []byte
|
||||
}
|
||||
|
||||
const (
|
||||
defaultVerifyTimeout = 30 * time.Second
|
||||
)
|
||||
|
||||
func SkipVerification(key string) bool {
|
||||
switch strings.ToLower(strings.TrimSpace(key)) {
|
||||
case "custom", "vllm", "ollama", "kimi-coding":
|
||||
@@ -42,7 +46,7 @@ func VerifyAccount(provider, baseURL, apiKey string) error {
|
||||
for key, value := range req.Headers {
|
||||
httpReq.Header.Set(key, value)
|
||||
}
|
||||
resp, err := (&http.Client{Timeout: 10 * time.Second}).Do(httpReq)
|
||||
resp, err := (&http.Client{Timeout: verifyTimeout()}).Do(httpReq)
|
||||
if err != nil {
|
||||
return buserr.WithErr("ErrAgentAccountUnavailable", err)
|
||||
}
|
||||
@@ -53,6 +57,10 @@ func VerifyAccount(provider, baseURL, apiKey string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func verifyTimeout() time.Duration {
|
||||
return defaultVerifyTimeout
|
||||
}
|
||||
|
||||
func BuildVerifyRequest(provider, baseURL, apiKey string) VerifyRequest {
|
||||
provider = strings.ToLower(strings.TrimSpace(provider))
|
||||
base := strings.TrimRight(strings.TrimSpace(baseURL), "/")
|
||||
|
||||
+78
-2461
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -57,6 +57,10 @@ type IAppService interface {
|
||||
GetAppDetailByKey(appKey, version string) (response.AppDetailSimpleDTO, error)
|
||||
}
|
||||
|
||||
type appInstallHooks struct {
|
||||
AfterCopyData func(appInstall *model.AppInstall) error
|
||||
}
|
||||
|
||||
func NewIAppService() IAppService {
|
||||
return &AppService{}
|
||||
}
|
||||
@@ -340,6 +344,10 @@ func (a AppService) GetAppDetailByID(id uint) (*response.AppDetailDTO, error) {
|
||||
}
|
||||
|
||||
func (a AppService) Install(req request.AppInstallCreate, executeScript bool) (appInstall *model.AppInstall, err error) {
|
||||
return a.installWithHooks(req, executeScript, nil)
|
||||
}
|
||||
|
||||
func (a AppService) installWithHooks(req request.AppInstallCreate, executeScript bool, hooks *appInstallHooks) (appInstall *model.AppInstall, err error) {
|
||||
if err = docker.CreateDefaultDockerNetwork(); err != nil {
|
||||
err = buserr.WithDetail("Err1PanelNetworkFailed", err.Error(), nil)
|
||||
return
|
||||
@@ -537,6 +545,11 @@ func (a AppService) Install(req request.AppInstallCreate, executeScript bool) (a
|
||||
if err = copyData(t, app, appDetail, appInstall, req); err != nil {
|
||||
return err
|
||||
}
|
||||
if hooks != nil && hooks.AfterCopyData != nil {
|
||||
if err = hooks.AfterCopyData(appInstall); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if executeScript {
|
||||
if err = runScript(t, appInstall, "init"); err != nil {
|
||||
return err
|
||||
|
||||
@@ -44,7 +44,8 @@ ErrAgentAccountUnavailable: 'Account connection unavailable: {{ .err }}'
|
||||
ErrAgentProviderNotSupported: 'Unsupported agent provider'
|
||||
ErrAgentAccountRequired: 'Select an agent account first'
|
||||
ErrAgentAccountNotVerified: 'Agent account not verified'
|
||||
ErrAgentProviderMismatch: 'Agent provider mismatch'
|
||||
ErrAgentAccountModelsRequired: 'Please configure at least one model'
|
||||
ErrAgentAccountSingleInitialModel: 'Only one initial model can be configured during account creation'
|
||||
ErrAgentModelNotInAccount: 'Model is not configured in the selected account'
|
||||
ErrAgentModelInUse: 'A bound agent is still using this model: {{ .name }}'
|
||||
ErrAgentBaseURLRequired: 'Base URL is required'
|
||||
|
||||
@@ -39,7 +39,8 @@ ErrAgentAccountUnavailable: 'Conexión de cuenta no disponible: {{ .err }}'
|
||||
ErrAgentProviderNotSupported: 'Proveedor de agente no soportado'
|
||||
ErrAgentAccountRequired: 'Elige una cuenta de agente primero'
|
||||
ErrAgentAccountNotVerified: 'Cuenta de agente no verificada'
|
||||
ErrAgentProviderMismatch: 'Proveedor de agente no coincide'
|
||||
ErrAgentAccountModelsRequired: 'Configure al menos un modelo'
|
||||
ErrAgentAccountSingleInitialModel: 'Solo se puede configurar un modelo inicial al crear la cuenta'
|
||||
ErrAgentModelNotInAccount: 'El modelo no está configurado en la cuenta seleccionada'
|
||||
ErrAgentModelInUse: 'Un agente vinculado todavía usa este modelo: {{ .name }}'
|
||||
ErrAgentBaseURLRequired: 'URL base requerida'
|
||||
|
||||
@@ -39,7 +39,8 @@ ErrAgentAccountUnavailable: 'アカウント接続不可: {{ .err }}'
|
||||
ErrAgentProviderNotSupported: 'エージェントプロバイダ非対応'
|
||||
ErrAgentAccountRequired: 'まずエージェントアカウントを選択'
|
||||
ErrAgentAccountNotVerified: 'アカウント未検証です'
|
||||
ErrAgentProviderMismatch: 'エージェントプロバイダが一致しません'
|
||||
ErrAgentAccountModelsRequired: '少なくとも 1 つのモデルを設定してください'
|
||||
ErrAgentAccountSingleInitialModel: 'アカウント作成時に設定できる初期モデルは 1 つだけです'
|
||||
ErrAgentModelNotInAccount: '選択したモデルはこのアカウントに設定されていません'
|
||||
ErrAgentModelInUse: 'このモデルはまだエージェントで使用中です: {{ .name }}'
|
||||
ErrAgentBaseURLRequired: 'ベースURLが必要です'
|
||||
|
||||
@@ -39,7 +39,8 @@ ErrAgentAccountUnavailable: '계정 연결 불가: {{ .err }}'
|
||||
ErrAgentProviderNotSupported: '지원되지 않는 에이전트 공급자'
|
||||
ErrAgentAccountRequired: '먼저 에이전트 계정을 선택하세요'
|
||||
ErrAgentAccountNotVerified: '에이전트 계정 미확인'
|
||||
ErrAgentProviderMismatch: '에이전트 공급자 불일치'
|
||||
ErrAgentAccountModelsRequired: '최소 한 개의 모델을 구성해 주세요'
|
||||
ErrAgentAccountSingleInitialModel: '계정 생성 시 초기 모델은 하나만 구성할 수 있습니다'
|
||||
ErrAgentModelNotInAccount: '선택한 모델이 현재 계정에 구성되어 있지 않습니다'
|
||||
ErrAgentModelInUse: '이 모델을 아직 사용 중인 에이전트가 있습니다: {{ .name }}'
|
||||
ErrAgentBaseURLRequired: '기본 URL 필요'
|
||||
|
||||
@@ -39,7 +39,8 @@ ErrAgentAccountUnavailable: 'Sambungan akaun tidak tersedia: {{ .err }}'
|
||||
ErrAgentProviderNotSupported: 'Penyedia ejen tidak disokong'
|
||||
ErrAgentAccountRequired: 'Pilih akaun ejen terlebih dahulu'
|
||||
ErrAgentAccountNotVerified: 'Akaun ejen belum disahkan'
|
||||
ErrAgentProviderMismatch: 'Penyedia ejen tidak sepadan'
|
||||
ErrAgentAccountModelsRequired: 'Sila konfigur sekurang-kurangnya satu model'
|
||||
ErrAgentAccountSingleInitialModel: 'Hanya satu model awal boleh dikonfigurasi semasa mencipta akaun'
|
||||
ErrAgentModelNotInAccount: 'Model tidak dikonfigurasikan dalam akaun yang dipilih'
|
||||
ErrAgentModelInUse: 'Masih ada ejen terikat yang menggunakan model ini: {{ .name }}'
|
||||
ErrAgentBaseURLRequired: 'URL asas diperlukan'
|
||||
|
||||
@@ -39,7 +39,8 @@ ErrAgentAccountUnavailable: 'Conexão da conta indisponível: {{ .err }}'
|
||||
ErrAgentProviderNotSupported: 'Provedor de agente não suportado'
|
||||
ErrAgentAccountRequired: 'Selecione uma conta de agente primeiro'
|
||||
ErrAgentAccountNotVerified: 'Conta de agente não verificada'
|
||||
ErrAgentProviderMismatch: 'Provedor de agente diferente'
|
||||
ErrAgentAccountModelsRequired: 'Configure pelo menos um modelo'
|
||||
ErrAgentAccountSingleInitialModel: 'Apenas um modelo inicial pode ser configurado ao criar a conta'
|
||||
ErrAgentModelNotInAccount: 'O modelo não está configurado na conta selecionada'
|
||||
ErrAgentModelInUse: 'Ainda há um agente vinculado usando este modelo: {{ .name }}'
|
||||
ErrAgentBaseURLRequired: 'URL base obrigatória'
|
||||
|
||||
@@ -39,7 +39,8 @@ ErrAgentAccountUnavailable: 'Связь с аккаунтом недоступн
|
||||
ErrAgentProviderNotSupported: 'Провайдер агента не поддерживается'
|
||||
ErrAgentAccountRequired: 'Выберите аккаунт агента'
|
||||
ErrAgentAccountNotVerified: 'Аккаунт не подтверждён'
|
||||
ErrAgentProviderMismatch: 'Провайдер не совпадает'
|
||||
ErrAgentAccountModelsRequired: 'Настройте хотя бы одну модель'
|
||||
ErrAgentAccountSingleInitialModel: 'При создании аккаунта можно указать только одну начальную модель'
|
||||
ErrAgentModelNotInAccount: 'Модель не настроена в выбранном аккаунте'
|
||||
ErrAgentModelInUse: 'Эта модель всё ещё используется агентом: {{ .name }}'
|
||||
ErrAgentBaseURLRequired: 'Нужен базовый URL'
|
||||
|
||||
@@ -39,7 +39,8 @@ ErrAgentAccountUnavailable: 'Hesap bağlantısı yok: {{ .err }}'
|
||||
ErrAgentProviderNotSupported: 'Ajans sağlayıcısı desteklenmiyor'
|
||||
ErrAgentAccountRequired: 'Önce bir ajans hesabı seçin'
|
||||
ErrAgentAccountNotVerified: 'Ajans hesabı doğrulanmadı'
|
||||
ErrAgentProviderMismatch: 'Ajans sağlayıcısı eşleşmiyor'
|
||||
ErrAgentAccountModelsRequired: 'Lütfen en az bir model yapılandırın'
|
||||
ErrAgentAccountSingleInitialModel: 'Hesap oluştururken yalnızca bir başlangıç modeli yapılandırılabilir'
|
||||
ErrAgentModelNotInAccount: 'Model seçilen hesapta yapılandırılmadı'
|
||||
ErrAgentModelInUse: 'Bu modeli hâlâ kullanan bağlı bir ajan var: {{ .name }}'
|
||||
ErrAgentBaseURLRequired: 'Temel URL gerekli'
|
||||
|
||||
@@ -39,7 +39,8 @@ ErrAgentAccountUnavailable: '帳號連線資訊不可用,錯誤:{{ .err }}
|
||||
ErrAgentProviderNotSupported: '暫不支援該智能體提供商,請重試'
|
||||
ErrAgentAccountRequired: '請選擇智能體帳號後重試'
|
||||
ErrAgentAccountNotVerified: '帳號未驗證通過,請重試'
|
||||
ErrAgentProviderMismatch: '帳號提供商不符,請重試'
|
||||
ErrAgentAccountModelsRequired: '請至少配置一個模型'
|
||||
ErrAgentAccountSingleInitialModel: '建立帳號時只能配置一個初始模型'
|
||||
ErrAgentModelNotInAccount: '所選模型未配置在當前帳號中,請重試'
|
||||
ErrAgentModelInUse: '仍有智能體正在使用該模型:{{ .name }}'
|
||||
ErrAgentBaseURLRequired: 'Base URL 不可為空,請重試'
|
||||
|
||||
@@ -44,7 +44,8 @@ ErrAgentAccountUnavailable: "账号连接信息不可用: {{ .err }}"
|
||||
ErrAgentProviderNotSupported: "不支持该智能体提供商"
|
||||
ErrAgentAccountRequired: "请选择智能体账号后重试"
|
||||
ErrAgentAccountNotVerified: "账号未通过验证"
|
||||
ErrAgentProviderMismatch: "账号提供商不匹配"
|
||||
ErrAgentAccountModelsRequired: "请至少配置一个模型"
|
||||
ErrAgentAccountSingleInitialModel: "创建账号时只能配置一个初始模型"
|
||||
ErrAgentModelNotInAccount: "所选模型未配置在当前账号中"
|
||||
ErrAgentModelInUse: "仍有智能体正在使用该模型: {{ .name }}"
|
||||
ErrAgentBaseURLRequired: "Base URL 不能为空"
|
||||
|
||||
@@ -11,9 +11,15 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type legacyAgentAccountModelPoolSource struct {
|
||||
model.AgentAccount
|
||||
LegacyModel string `gorm:"column:model"`
|
||||
LegacyModels string `gorm:"column:models"`
|
||||
}
|
||||
|
||||
func MigrateAgentAccountModelPool(tx *gorm.DB) error {
|
||||
var accounts []model.AgentAccount
|
||||
if err := tx.Find(&accounts).Error; err != nil {
|
||||
var accounts []legacyAgentAccountModelPoolSource
|
||||
if err := tx.Table(model.AgentAccount{}.TableName()).Find(&accounts).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
for _, account := range accounts {
|
||||
@@ -54,13 +60,14 @@ func MigrateAgentAccountModelPool(tx *gorm.DB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildMigratedAgentAccountModels(tx *gorm.DB, account *model.AgentAccount) ([]dto.AgentAccountModel, error) {
|
||||
func buildMigratedAgentAccountModels(tx *gorm.DB, account *legacyAgentAccountModelPoolSource) ([]dto.AgentAccountModel, error) {
|
||||
if account == nil {
|
||||
return nil, nil
|
||||
}
|
||||
baseAccount := account.AgentAccount
|
||||
requested := make([]dto.AgentAccountModel, 0)
|
||||
if strings.TrimSpace(account.Models) != "" {
|
||||
if err := json.Unmarshal([]byte(account.Models), &requested); err != nil {
|
||||
if strings.TrimSpace(account.LegacyModels) != "" {
|
||||
if err := json.Unmarshal([]byte(account.LegacyModels), &requested); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -83,7 +90,7 @@ func buildMigratedAgentAccountModels(tx *gorm.DB, account *model.AgentAccount) (
|
||||
seen[target] = struct{}{}
|
||||
requested = append(requested, dto.AgentAccountModel{ID: target})
|
||||
}
|
||||
appendModel(account.Model)
|
||||
appendModel(account.LegacyModel)
|
||||
if account.ID > 0 {
|
||||
var agents []model.Agent
|
||||
if err := tx.Where("account_id = ?", account.ID).Find(&agents).Error; err != nil {
|
||||
@@ -93,7 +100,7 @@ func buildMigratedAgentAccountModels(tx *gorm.DB, account *model.AgentAccount) (
|
||||
appendModel(agent.Model)
|
||||
}
|
||||
}
|
||||
models, err := service.MergeCatalogAgentAccountModelsForMigration(account, requested)
|
||||
models, err := service.MergeCatalogAgentAccountModelsForMigration(&baseAccount, requested)
|
||||
if err != nil {
|
||||
if strings.TrimSpace(err.Error()) == "model is required" {
|
||||
return nil, nil
|
||||
|
||||
@@ -243,14 +243,8 @@ export namespace AI {
|
||||
bridgePort?: number;
|
||||
allowedOrigins?: string[];
|
||||
agentType: 'openclaw' | 'copaw';
|
||||
provider?: string;
|
||||
model?: string;
|
||||
apiType?: string;
|
||||
maxTokens?: number;
|
||||
contextWindow?: number;
|
||||
accountId?: number;
|
||||
apiKey?: string;
|
||||
baseURL?: string;
|
||||
token?: string;
|
||||
taskID: string;
|
||||
advanced: boolean;
|
||||
@@ -361,8 +355,7 @@ export namespace AI {
|
||||
rememberApiKey: boolean;
|
||||
baseURL: string;
|
||||
apiType: string;
|
||||
maxTokens: number;
|
||||
contextWindow: number;
|
||||
models?: AgentAccountModel[];
|
||||
remark: string;
|
||||
}
|
||||
|
||||
@@ -373,8 +366,6 @@ export namespace AI {
|
||||
rememberApiKey: boolean;
|
||||
baseURL: string;
|
||||
apiType: string;
|
||||
maxTokens: number;
|
||||
contextWindow: number;
|
||||
remark: string;
|
||||
syncAgents: boolean;
|
||||
}
|
||||
@@ -394,11 +385,8 @@ export namespace AI {
|
||||
apiKey: string;
|
||||
rememberApiKey: boolean;
|
||||
baseUrl: string;
|
||||
model: string;
|
||||
models: AgentAccountModel[];
|
||||
apiType: string;
|
||||
maxTokens: number;
|
||||
contextWindow: number;
|
||||
verified: boolean;
|
||||
remark: string;
|
||||
createdAt: string;
|
||||
|
||||
@@ -692,8 +692,6 @@ const message = {
|
||||
accountModelsHelper: 'Configure the models this account exposes to OpenClaw for switching and settings',
|
||||
accountModelsRequired: 'Configure at least one model',
|
||||
accountModelsDuplicate: 'Duplicate models exist in the catalog',
|
||||
accountCreateHelper:
|
||||
'After creating the model account, you can continue managing its model pool. If the provider catalog already defines Models, they will be imported automatically.',
|
||||
modelPool: 'Model Pool',
|
||||
modelPoolHelper:
|
||||
'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.',
|
||||
|
||||
@@ -700,8 +700,6 @@ const message = {
|
||||
accountModelsHelper: 'Configure the models this account exposes to OpenClaw for switching and settings',
|
||||
accountModelsRequired: 'Configure at least one model',
|
||||
accountModelsDuplicate: 'Duplicate models exist in the catalog',
|
||||
accountCreateHelper:
|
||||
'After creating the model account, you can continue managing its model pool. If the provider catalog already defines Models, they will be imported automatically.',
|
||||
modelPool: 'Model Pool',
|
||||
modelPoolHelper:
|
||||
'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.',
|
||||
|
||||
@@ -693,8 +693,6 @@ const message = {
|
||||
accountModelsHelper: 'Configure the models this account exposes to OpenClaw for switching and settings',
|
||||
accountModelsRequired: 'Configure at least one model',
|
||||
accountModelsDuplicate: 'Duplicate models exist in the catalog',
|
||||
accountCreateHelper:
|
||||
'After creating the model account, you can continue managing its model pool. If the provider catalog already defines Models, they will be imported automatically.',
|
||||
modelPool: 'Model Pool',
|
||||
modelPoolHelper:
|
||||
'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.',
|
||||
|
||||
@@ -685,8 +685,6 @@ const message = {
|
||||
accountModelsHelper: 'Configure the models this account exposes to OpenClaw for switching and settings',
|
||||
accountModelsRequired: 'Configure at least one model',
|
||||
accountModelsDuplicate: 'Duplicate models exist in the catalog',
|
||||
accountCreateHelper:
|
||||
'After creating the model account, you can continue managing its model pool. If the provider catalog already defines Models, they will be imported automatically.',
|
||||
modelPool: 'Model Pool',
|
||||
modelPoolHelper:
|
||||
'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.',
|
||||
|
||||
@@ -700,8 +700,6 @@ const message = {
|
||||
accountModelsHelper: 'Configure the models this account exposes to OpenClaw for switching and settings',
|
||||
accountModelsRequired: 'Configure at least one model',
|
||||
accountModelsDuplicate: 'Duplicate models exist in the catalog',
|
||||
accountCreateHelper:
|
||||
'After creating the model account, you can continue managing its model pool. If the provider catalog already defines Models, they will be imported automatically.',
|
||||
modelPool: 'Model Pool',
|
||||
modelPoolHelper:
|
||||
'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.',
|
||||
|
||||
@@ -695,8 +695,6 @@ const message = {
|
||||
accountModelsHelper: 'Configure the models this account exposes to OpenClaw for switching and settings',
|
||||
accountModelsRequired: 'Configure at least one model',
|
||||
accountModelsDuplicate: 'Duplicate models exist in the catalog',
|
||||
accountCreateHelper:
|
||||
'After creating the model account, you can continue managing its model pool. If the provider catalog already defines Models, they will be imported automatically.',
|
||||
modelPool: 'Model Pool',
|
||||
modelPoolHelper:
|
||||
'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.',
|
||||
|
||||
@@ -692,8 +692,6 @@ const message = {
|
||||
accountModelsHelper: 'Configure the models this account exposes to OpenClaw for switching and settings',
|
||||
accountModelsRequired: 'Configure at least one model',
|
||||
accountModelsDuplicate: 'Duplicate models exist in the catalog',
|
||||
accountCreateHelper:
|
||||
'After creating the model account, you can continue managing its model pool. If the provider catalog already defines Models, they will be imported automatically.',
|
||||
modelPool: 'Model Pool',
|
||||
modelPoolHelper:
|
||||
'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.',
|
||||
|
||||
@@ -696,8 +696,6 @@ const message = {
|
||||
accountModelsHelper: 'Configure the models this account exposes to OpenClaw for switching and settings',
|
||||
accountModelsRequired: 'Configure at least one model',
|
||||
accountModelsDuplicate: 'Duplicate models exist in the catalog',
|
||||
accountCreateHelper:
|
||||
'After creating the model account, you can continue managing its model pool. If the provider catalog already defines Models, they will be imported automatically.',
|
||||
modelPool: 'Model Pool',
|
||||
modelPoolHelper:
|
||||
'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.',
|
||||
|
||||
@@ -660,7 +660,6 @@ const message = {
|
||||
accountModelsHelper: '配置該帳號可提供給 OpenClaw 使用與切換的模型列表',
|
||||
accountModelsRequired: '請至少配置一個模型',
|
||||
accountModelsDuplicate: '模型池中存在重複模型,請檢查後重試',
|
||||
accountCreateHelper: '建立模型帳號後可繼續修改模型池;如果供應商 catalog 已提供 Models,將自動匯入模型池',
|
||||
modelPool: '模型池',
|
||||
modelPoolHelper: '在此維護該模型帳號的模型池,建立智能體與 OpenClaw 模型切換都會使用這些模型',
|
||||
modelInputTypes: '輸入類型',
|
||||
|
||||
@@ -659,7 +659,6 @@ const message = {
|
||||
accountModelsHelper: '配置账号可提供给 OpenClaw 使用和切换的模型列表',
|
||||
accountModelsRequired: '请至少配置一个模型',
|
||||
accountModelsDuplicate: '模型池中存在重复模型,请检查后重试',
|
||||
accountCreateHelper: '创建模型账号后可继续修改模型池;如果供应商 catalog 已提供 Models,将自动导入模型池',
|
||||
modelPool: '模型池',
|
||||
modelPoolHelper: '在这里维护该模型账号的模型池,智能体创建和 OpenClaw 模型切换都会使用这些模型',
|
||||
modelInputTypes: '输入类型',
|
||||
|
||||
@@ -146,10 +146,6 @@ const form = reactive({
|
||||
provider: 'deepseek',
|
||||
accountId: undefined as unknown as number,
|
||||
model: '',
|
||||
apiType: 'openai-completions',
|
||||
maxTokens: 8192,
|
||||
contextWindow: 128000,
|
||||
apiKey: '',
|
||||
baseURL: '',
|
||||
token: '',
|
||||
advanced: true,
|
||||
@@ -300,7 +296,6 @@ const loadAccounts = async () => {
|
||||
handleAccountChange();
|
||||
} else {
|
||||
form.accountId = undefined as unknown as number;
|
||||
form.apiKey = '';
|
||||
form.baseURL = '';
|
||||
}
|
||||
};
|
||||
@@ -310,7 +305,6 @@ const handleProviderChange = () => {
|
||||
return;
|
||||
}
|
||||
form.model = '';
|
||||
form.apiKey = '';
|
||||
form.baseURL = '';
|
||||
form.accountId = undefined as unknown as number;
|
||||
loadAccounts();
|
||||
@@ -324,9 +318,7 @@ const handleAgentTypeChange = async () => {
|
||||
form.model = '';
|
||||
form.provider = 'deepseek';
|
||||
form.accountId = undefined as unknown as number;
|
||||
form.apiKey = '';
|
||||
form.baseURL = '';
|
||||
form.apiType = 'openai-completions';
|
||||
if (form.agentType === 'openclaw') {
|
||||
await loadSystemIP();
|
||||
allowedOriginsAutoFilled.value = true;
|
||||
@@ -349,10 +341,6 @@ const handleAccountChange = () => {
|
||||
const selected = accountOptions.value.find((item) => item.id === form.accountId);
|
||||
if (selected) {
|
||||
form.baseURL = selected.baseUrl || '';
|
||||
form.apiKey = selected.apiKey || '';
|
||||
form.apiType = selected.apiType || 'openai-completions';
|
||||
form.maxTokens = selected.maxTokens || 8192;
|
||||
form.contextWindow = selected.contextWindow || 128000;
|
||||
if (!selected.models?.some((item) => item.id === form.model)) {
|
||||
form.model = selected.models?.[0]?.id || '';
|
||||
}
|
||||
@@ -394,14 +382,8 @@ const submit = async () => {
|
||||
webUIPort: form.webUIPort,
|
||||
allowedOrigins: form.agentType === 'openclaw' ? parseAllowedOriginsInput(form.allowedOrigins) : undefined,
|
||||
agentType: form.agentType,
|
||||
provider: form.agentType === 'openclaw' ? form.provider : undefined,
|
||||
model: form.agentType === 'openclaw' ? form.model : undefined,
|
||||
apiType: form.agentType === 'openclaw' ? form.apiType : undefined,
|
||||
maxTokens: form.agentType === 'openclaw' ? form.maxTokens : undefined,
|
||||
contextWindow: form.agentType === 'openclaw' ? form.contextWindow : undefined,
|
||||
accountId: form.agentType === 'openclaw' ? form.accountId : undefined,
|
||||
apiKey: form.agentType === 'openclaw' ? form.apiKey : undefined,
|
||||
baseURL: form.agentType === 'openclaw' ? form.baseURL : undefined,
|
||||
token: form.agentType === 'openclaw' ? form.token : undefined,
|
||||
taskID: taskID,
|
||||
advanced: form.advanced,
|
||||
|
||||
@@ -26,13 +26,6 @@
|
||||
<el-form-item :label="$t('aiTools.agents.baseUrl')" prop="baseURL">
|
||||
<el-input v-model="form.baseURL" :disabled="!editableBaseURLProviders.includes(form.provider)" />
|
||||
</el-form-item>
|
||||
<el-alert
|
||||
:title="$t('aiTools.agents.accountCreateHelper')"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb-4"
|
||||
/>
|
||||
<el-form-item :label="'API ' + $t('commons.table.type')" prop="apiType">
|
||||
<el-select v-model="form.apiType">
|
||||
<el-option label="openai-completions" value="openai-completions" />
|
||||
@@ -44,12 +37,30 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="Max Tokens" prop="maxTokens">
|
||||
<el-input-number v-model="form.maxTokens" :min="1" :max="2000000" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Context Window" prop="contextWindow">
|
||||
<el-input-number v-model="form.contextWindow" :min="1" :max="2000000" />
|
||||
</el-form-item>
|
||||
<template v-if="showInitialModel">
|
||||
<el-divider content-position="left">{{ $t('aiTools.agents.accountModels') }}</el-divider>
|
||||
<el-form-item :label="$t('aiTools.model.model')" prop="initialModel.id" :rules="[Rules.requiredInput]">
|
||||
<el-input v-model="form.initialModel.id" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.table.name')" prop="initialModel.name">
|
||||
<el-input v-model="form.initialModel.name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Context Window" prop="initialModel.contextWindow">
|
||||
<el-input-number v-model="form.initialModel.contextWindow" :min="1" :max="2000000" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Max Tokens" prop="initialModel.maxTokens">
|
||||
<el-input-number v-model="form.initialModel.maxTokens" :min="1" :max="2000000" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('aiTools.agents.modelInputTypes')" prop="initialModel.input">
|
||||
<el-checkbox-group v-model="form.initialModel.input">
|
||||
<el-checkbox label="text">Text</el-checkbox>
|
||||
<el-checkbox label="image">Image</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('aiTools.agents.reasoning')" prop="initialModel.reasoning">
|
||||
<el-switch v-model="form.initialModel.reasoning" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
<el-form-item :label="$t('website.remark')" prop="remark">
|
||||
<el-input v-model="form.remark" />
|
||||
</el-form-item>
|
||||
@@ -72,6 +83,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { FormInstance } from 'element-plus';
|
||||
import { AI } from '@/api/interface/ai';
|
||||
import { Rules } from '@/global/form-rules';
|
||||
import { createAgentAccount, getAgentProviders, updateAgentAccount } from '@/api/modules/ai';
|
||||
import i18n from '@/lang';
|
||||
@@ -87,6 +99,7 @@ const providerOptions = ref<Array<{ label: string; value: string }>>([]);
|
||||
const providerBaseURL = ref<Record<string, string>>({});
|
||||
const loading = ref(false);
|
||||
const editableBaseURLProviders = ['ollama', 'custom', 'vllm', 'zai'];
|
||||
const initialModelProviders = ['custom', 'vllm', 'ollama'];
|
||||
const { isIntl } = useGlobalStore();
|
||||
|
||||
const form = reactive({
|
||||
@@ -95,10 +108,9 @@ const form = reactive({
|
||||
name: '',
|
||||
baseURL: '',
|
||||
apiType: 'openai-completions',
|
||||
maxTokens: 8192,
|
||||
contextWindow: 128000,
|
||||
apiKey: '',
|
||||
rememberApiKey: false,
|
||||
initialModel: {} as AI.AgentAccountModel,
|
||||
remark: '',
|
||||
syncAgents: false,
|
||||
});
|
||||
@@ -107,6 +119,8 @@ const headerTitle = computed(() =>
|
||||
form.id ? i18n.global.t('commons.button.edit') : i18n.global.t('commons.button.create'),
|
||||
);
|
||||
|
||||
const showInitialModel = computed(() => !form.id && initialModelProviders.includes(form.provider));
|
||||
|
||||
const rules = reactive({
|
||||
provider: [Rules.requiredSelect],
|
||||
name: [Rules.requiredInput],
|
||||
@@ -115,11 +129,59 @@ const rules = reactive({
|
||||
apiType: [Rules.requiredSelect],
|
||||
});
|
||||
|
||||
const isInitialModelProvider = (provider: string) => initialModelProviders.includes(provider);
|
||||
|
||||
const defaultContextWindowForProvider = (provider: string) => {
|
||||
if (provider === 'custom' || provider === 'vllm') {
|
||||
return 128000;
|
||||
}
|
||||
return 256000;
|
||||
};
|
||||
|
||||
const buildInitialModel = (provider: string): AI.AgentAccountModel => ({
|
||||
recordId: 0,
|
||||
id: '',
|
||||
name: '',
|
||||
contextWindow: defaultContextWindowForProvider(provider),
|
||||
maxTokens: 8192,
|
||||
reasoning: false,
|
||||
input: ['text'],
|
||||
});
|
||||
|
||||
const normalizeInitialModel = () => {
|
||||
const item = {
|
||||
recordId: 0,
|
||||
id: String(form.initialModel.id || '').trim(),
|
||||
name: String(form.initialModel.name || form.initialModel.id || '').trim(),
|
||||
contextWindow: Number(form.initialModel.contextWindow || 0) || defaultContextWindowForProvider(form.provider),
|
||||
maxTokens: Number(form.initialModel.maxTokens || 0) || 8192,
|
||||
reasoning: Boolean(form.initialModel.reasoning),
|
||||
input: Array.from(
|
||||
new Set((form.initialModel.input || []).filter((value) => value === 'text' || value === 'image')),
|
||||
),
|
||||
};
|
||||
if (item.id === '') {
|
||||
return null;
|
||||
}
|
||||
return item;
|
||||
};
|
||||
|
||||
const resetInitialModel = () => {
|
||||
form.initialModel = isInitialModelProvider(form.provider)
|
||||
? buildInitialModel(form.provider)
|
||||
: ({} as AI.AgentAccountModel);
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
await formRef.value.validate();
|
||||
const initialModel = normalizeInitialModel();
|
||||
if (showInitialModel.value && !initialModel) {
|
||||
MsgError(i18n.global.t('aiTools.agents.accountModelsRequired'));
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
if (form.id) {
|
||||
@@ -130,8 +192,6 @@ const submit = async () => {
|
||||
apiKey: form.apiKey,
|
||||
rememberApiKey: form.rememberApiKey,
|
||||
apiType: form.apiType,
|
||||
maxTokens: form.maxTokens,
|
||||
contextWindow: form.contextWindow,
|
||||
remark: form.remark,
|
||||
syncAgents: form.syncAgents,
|
||||
});
|
||||
@@ -143,8 +203,7 @@ const submit = async () => {
|
||||
apiKey: form.apiKey,
|
||||
rememberApiKey: form.rememberApiKey,
|
||||
apiType: form.apiType,
|
||||
maxTokens: form.maxTokens,
|
||||
contextWindow: form.contextWindow,
|
||||
models: initialModel ? [initialModel] : [],
|
||||
remark: form.remark,
|
||||
});
|
||||
}
|
||||
@@ -165,10 +224,9 @@ const handleClose = () => {
|
||||
form.name = '';
|
||||
form.baseURL = '';
|
||||
form.apiType = 'openai-completions';
|
||||
form.maxTokens = 8192;
|
||||
form.contextWindow = 128000;
|
||||
form.apiKey = '';
|
||||
form.rememberApiKey = false;
|
||||
form.initialModel = {} as AI.AgentAccountModel;
|
||||
form.remark = '';
|
||||
form.syncAgents = false;
|
||||
};
|
||||
@@ -181,8 +239,6 @@ interface OpenParams {
|
||||
apiKey?: string;
|
||||
rememberApiKey?: boolean;
|
||||
apiType?: string;
|
||||
maxTokens?: number;
|
||||
contextWindow?: number;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
@@ -200,8 +256,6 @@ const openDrawer = async (params?: OpenParams) => {
|
||||
form.apiKey = params.apiKey || '';
|
||||
form.rememberApiKey = params.rememberApiKey || false;
|
||||
form.apiType = params.apiType || 'openai-completions';
|
||||
form.maxTokens = params.maxTokens || 8192;
|
||||
form.contextWindow = params.contextWindow || 128000;
|
||||
form.remark = params.remark || '';
|
||||
form.syncAgents = false;
|
||||
return;
|
||||
@@ -212,8 +266,7 @@ const openDrawer = async (params?: OpenParams) => {
|
||||
form.apiKey = '';
|
||||
form.rememberApiKey = false;
|
||||
form.apiType = 'openai-completions';
|
||||
form.maxTokens = 8192;
|
||||
form.contextWindow = 128000;
|
||||
form.initialModel = {} as AI.AgentAccountModel;
|
||||
form.remark = '';
|
||||
form.syncAgents = false;
|
||||
if (params?.provider) {
|
||||
@@ -256,6 +309,9 @@ const handleProviderChange = () => {
|
||||
form.apiType = 'openai-completions';
|
||||
}
|
||||
}
|
||||
if (!form.id) {
|
||||
resetInitialModel();
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -118,8 +118,6 @@ const onEdit = (row: AI.AgentAccountItem) => {
|
||||
apiKey: row.apiKey,
|
||||
rememberApiKey: row.rememberApiKey,
|
||||
apiType: row.apiType,
|
||||
maxTokens: row.maxTokens,
|
||||
contextWindow: row.contextWindow,
|
||||
remark: row.remark,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user