Skip to content

Commit 8644579

Browse files
zhengkunwang223wanghe-fit2cloud
authored andcommitted
feat: Agent Model Account support custom config (#11933)
* feat: Agent Model Account support custom config * feat: Add agent gatewayControlUi config
1 parent 6c3f565 commit 8644579

24 files changed

Lines changed: 492 additions & 125 deletions

File tree

agent/app/dto/agents.go

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ type AgentCreateReq struct {
99
BridgePort int `json:"bridgePort" validate:"required"`
1010
Provider string `json:"provider" validate:"required"`
1111
Model string `json:"model" validate:"required"`
12+
APIType string `json:"apiType"`
13+
MaxTokens int `json:"maxTokens"`
14+
ContextWindow int `json:"contextWindow"`
1215
AccountID uint `json:"accountId"`
1316
APIKey string `json:"apiKey"`
1417
BaseURL string `json:"baseURL"`
@@ -28,26 +31,29 @@ type AgentCreateReq struct {
2831
}
2932

3033
type AgentItem struct {
31-
ID uint `json:"id"`
32-
Name string `json:"name"`
33-
Provider string `json:"provider"`
34-
ProviderName string `json:"providerName"`
35-
Model string `json:"model"`
36-
BaseURL string `json:"baseUrl"`
37-
APIKey string `json:"apiKey"`
38-
Token string `json:"token"`
39-
Status string `json:"status"`
40-
Message string `json:"message"`
41-
AppInstallID uint `json:"appInstallId"`
42-
AccountID uint `json:"accountId"`
43-
AppVersion string `json:"appVersion"`
44-
Container string `json:"containerName"`
45-
WebUIPort int `json:"webUIPort"`
46-
BridgePort int `json:"bridgePort"`
47-
Path string `json:"path"`
48-
ConfigPath string `json:"configPath"`
49-
Upgradable bool `json:"upgradable"`
50-
CreatedAt time.Time `json:"createdAt"`
34+
ID uint `json:"id"`
35+
Name string `json:"name"`
36+
Provider string `json:"provider"`
37+
ProviderName string `json:"providerName"`
38+
Model string `json:"model"`
39+
APIType string `json:"apiType"`
40+
MaxTokens int `json:"maxTokens"`
41+
ContextWindow int `json:"contextWindow"`
42+
BaseURL string `json:"baseUrl"`
43+
APIKey string `json:"apiKey"`
44+
Token string `json:"token"`
45+
Status string `json:"status"`
46+
Message string `json:"message"`
47+
AppInstallID uint `json:"appInstallId"`
48+
AccountID uint `json:"accountId"`
49+
AppVersion string `json:"appVersion"`
50+
Container string `json:"containerName"`
51+
WebUIPort int `json:"webUIPort"`
52+
BridgePort int `json:"bridgePort"`
53+
Path string `json:"path"`
54+
ConfigPath string `json:"configPath"`
55+
Upgradable bool `json:"upgradable"`
56+
CreatedAt time.Time `json:"createdAt"`
5157
}
5258

5359
type AgentDeleteReq struct {
@@ -67,20 +73,28 @@ type AgentModelConfigUpdateReq struct {
6773
}
6874

6975
type AgentAccountCreateReq struct {
70-
Provider string `json:"provider" validate:"required"`
71-
Name string `json:"name" validate:"required"`
72-
APIKey string `json:"apiKey" validate:"required"`
73-
BaseURL string `json:"baseURL"`
74-
Remark string `json:"remark"`
76+
Provider string `json:"provider" validate:"required"`
77+
Name string `json:"name" validate:"required"`
78+
APIKey string `json:"apiKey" validate:"required"`
79+
BaseURL string `json:"baseURL"`
80+
Model string `json:"model"`
81+
APIType string `json:"apiType"`
82+
MaxTokens int `json:"maxTokens"`
83+
ContextWindow int `json:"contextWindow"`
84+
Remark string `json:"remark"`
7585
}
7686

7787
type AgentAccountUpdateReq struct {
78-
ID uint `json:"id" validate:"required"`
79-
Name string `json:"name" validate:"required"`
80-
APIKey string `json:"apiKey" validate:"required"`
81-
BaseURL string `json:"baseURL"`
82-
Remark string `json:"remark"`
83-
SyncAgents bool `json:"syncAgents"`
88+
ID uint `json:"id" validate:"required"`
89+
Name string `json:"name" validate:"required"`
90+
APIKey string `json:"apiKey" validate:"required"`
91+
BaseURL string `json:"baseURL"`
92+
Model string `json:"model"`
93+
APIType string `json:"apiType"`
94+
MaxTokens int `json:"maxTokens"`
95+
ContextWindow int `json:"contextWindow"`
96+
Remark string `json:"remark"`
97+
SyncAgents bool `json:"syncAgents"`
8498
}
8599

86100
type AgentAccountVerifyReq struct {
@@ -100,15 +114,19 @@ type AgentAccountSearch struct {
100114
}
101115

102116
type AgentAccountInfo struct {
103-
ID uint `json:"id"`
104-
Provider string `json:"provider"`
105-
ProviderName string `json:"providerName"`
106-
Name string `json:"name"`
107-
APIKey string `json:"apiKey"`
108-
BaseURL string `json:"baseUrl"`
109-
Verified bool `json:"verified"`
110-
Remark string `json:"remark"`
111-
CreatedAt time.Time `json:"createdAt"`
117+
ID uint `json:"id"`
118+
Provider string `json:"provider"`
119+
ProviderName string `json:"providerName"`
120+
Name string `json:"name"`
121+
APIKey string `json:"apiKey"`
122+
BaseURL string `json:"baseUrl"`
123+
Model string `json:"model"`
124+
APIType string `json:"apiType"`
125+
MaxTokens int `json:"maxTokens"`
126+
ContextWindow int `json:"contextWindow"`
127+
Verified bool `json:"verified"`
128+
Remark string `json:"remark"`
129+
CreatedAt time.Time `json:"createdAt"`
112130
}
113131

114132
type ProviderModelInfo struct {

agent/app/model/agent.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ package model
22

33
type Agent struct {
44
BaseModel
5-
Name string `json:"name" gorm:"not null;unique"`
6-
Provider string `json:"provider"`
7-
Model string `json:"model"`
8-
BaseURL string `json:"baseUrl"`
9-
APIKey string `json:"apiKey"`
10-
Token string `json:"token"`
11-
Status string `json:"status"`
12-
Message string `json:"message"`
13-
AppInstallID uint `json:"appInstallId"`
14-
AccountID uint `json:"accountId"`
15-
ConfigPath string `json:"configPath"`
5+
Name string `json:"name" gorm:"not null;unique"`
6+
Provider string `json:"provider"`
7+
Model string `json:"model"`
8+
APIType string `json:"apiType"`
9+
MaxTokens int `json:"maxTokens"`
10+
ContextWindow int `json:"contextWindow"`
11+
BaseURL string `json:"baseUrl"`
12+
APIKey string `json:"apiKey"`
13+
Token string `json:"token"`
14+
Status string `json:"status"`
15+
Message string `json:"message"`
16+
AppInstallID uint `json:"appInstallId"`
17+
AccountID uint `json:"accountId"`
18+
ConfigPath string `json:"configPath"`
1619
}

agent/app/model/agent_account.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ package model
22

33
type AgentAccount struct {
44
BaseModel
5-
Provider string `json:"provider"`
6-
Name string `json:"name"`
7-
APIKey string `json:"apiKey"`
8-
BaseURL string `json:"baseUrl"`
9-
Verified bool `json:"verified"`
10-
Remark string `json:"remark"`
5+
Provider string `json:"provider"`
6+
Name string `json:"name"`
7+
APIKey string `json:"apiKey"`
8+
BaseURL string `json:"baseUrl"`
9+
Model string `json:"model"`
10+
APIType string `json:"apiType"`
11+
MaxTokens int `json:"maxTokens"`
12+
ContextWindow int `json:"contextWindow"`
13+
Verified bool `json:"verified"`
14+
Remark string `json:"remark"`
1115
}
1216

1317
func (AgentAccount) TableName() string {

agent/app/provider/catalog.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package provider
22

3-
import "strings"
3+
import (
4+
"strings"
5+
)
46

57
type Model struct {
68
ID string
@@ -21,13 +23,13 @@ var catalog = map[string]Meta{
2123
"ollama": {
2224
Key: "ollama",
2325
DisplayName: "Ollama",
24-
Sort: 1,
26+
Sort: 10,
2527
Enabled: true,
2628
},
2729
"deepseek": {
2830
Key: "deepseek",
2931
DisplayName: "DeepSeek",
30-
Sort: 2,
32+
Sort: 20,
3133
DefaultBaseURL: "https://api.deepseek.com/v1",
3234
EnvKey: "DEEPSEEK_API_KEY",
3335
Enabled: true,
@@ -37,10 +39,19 @@ var catalog = map[string]Meta{
3739
{ID: "deepseek/deepseek-r1:1.5b", Name: "DeepSeek R1 1.5B"},
3840
},
3941
},
42+
"custom": {
43+
Key: "custom",
44+
DisplayName: "Custom",
45+
Sort: 30,
46+
DefaultBaseURL: "",
47+
EnvKey: "CUSTOM_API_KEY",
48+
Enabled: true,
49+
Models: []Model{},
50+
},
4051
"openai": {
4152
Key: "openai",
4253
DisplayName: "OpenAI",
43-
Sort: 3,
54+
Sort: 40,
4455
DefaultBaseURL: "https://api.openai.com/v1",
4556
EnvKey: "OPENAI_API_KEY",
4657
Enabled: true,
@@ -56,7 +67,7 @@ var catalog = map[string]Meta{
5667
"anthropic": {
5768
Key: "anthropic",
5869
DisplayName: "Anthropic",
59-
Sort: 4,
70+
Sort: 50,
6071
DefaultBaseURL: "https://api.anthropic.com",
6172
EnvKey: "ANTHROPIC_API_KEY",
6273
Enabled: true,
@@ -71,7 +82,7 @@ var catalog = map[string]Meta{
7182
"gemini": {
7283
Key: "gemini",
7384
DisplayName: "Gemini",
74-
Sort: 5,
85+
Sort: 60,
7586
DefaultBaseURL: "https://generativelanguage.googleapis.com",
7687
EnvKey: "GEMINI_API_KEY",
7788
Enabled: true,
@@ -87,7 +98,7 @@ var catalog = map[string]Meta{
8798
"minimax": {
8899
Key: "minimax",
89100
DisplayName: "MiniMax (CN)",
90-
Sort: 6,
101+
Sort: 70,
91102
DefaultBaseURL: "https://api.minimaxi.com/anthropic",
92103
EnvKey: "MINIMAX_API_KEY",
93104
Enabled: true,
@@ -99,7 +110,7 @@ var catalog = map[string]Meta{
99110
"moonshot": {
100111
Key: "moonshot",
101112
DisplayName: "Moonshot (Global)",
102-
Sort: 7,
113+
Sort: 80,
103114
DefaultBaseURL: "https://api.moonshot.ai/v1",
104115
EnvKey: "MOONSHOT_API_KEY",
105116
Enabled: true,
@@ -112,7 +123,7 @@ var catalog = map[string]Meta{
112123
"kimi": {
113124
Key: "kimi",
114125
DisplayName: "Kimi (CN)",
115-
Sort: 8,
126+
Sort: 90,
116127
DefaultBaseURL: "https://api.moonshot.cn/v1",
117128
EnvKey: "KIMI_API_KEY",
118129
Enabled: true,
@@ -125,7 +136,7 @@ var catalog = map[string]Meta{
125136
"kimi-coding": {
126137
Key: "kimi-coding",
127138
DisplayName: "Kimi Coding",
128-
Sort: 9,
139+
Sort: 100,
129140
DefaultBaseURL: "https://api.moonshot.cn/anthropic/v1",
130141
EnvKey: "KIMI_API_KEY",
131142
Enabled: true,
@@ -136,7 +147,7 @@ var catalog = map[string]Meta{
136147
"qwen": {
137148
Key: "qwen",
138149
DisplayName: "Qwen",
139-
Sort: 10,
150+
Sort: 110,
140151
DefaultBaseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1",
141152
EnvKey: "QWEN_API_KEY",
142153
Enabled: false,

0 commit comments

Comments
 (0)