增加供应商智能添加功能
This commit is contained in:
@@ -13,6 +13,7 @@ type BackendAiProvider struct {
|
||||
ApiKey string `orm:"column(api_key);size(255)" json:"api_key"`
|
||||
Models string `orm:"column(models);type(text)" json:"-"` // JSON数组存储,如 ["gpt-4o","gpt-3.5-turbo"]
|
||||
ModelsList []string `orm:"-" json:"models"` // 返回给前端的模型列表
|
||||
DefaultModel string `orm:"column(default_model);size(255)" json:"default_model"` // 默认使用的模型(从models列表中选择)
|
||||
IsDefault int8 `orm:"column(is_default);default(0)" json:"is_default"` // 0-否 1-是(租户默认模型,用于智能添加等企业级功能)
|
||||
Status int8 `orm:"column(status);default(1)" json:"status"` // 0-禁用 1-启用
|
||||
Remark string `orm:"column(remark);size(255)" json:"remark"`
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// BackendMcpServer MCP服务器配置表(真正的 MCP 协议接入配置)
|
||||
// transport 支持三种:
|
||||
// - stdio:本地进程方式(command + args + env)
|
||||
// - http :Streamable HTTP 传输(url + headers)
|
||||
// - sse :SSE 传输(url + headers)
|
||||
type BackendMcpServer struct {
|
||||
ID uint64 `orm:"column(id);pk;auto" json:"id"`
|
||||
TenantID string `orm:"column(tenant_id);size(64)" json:"tenant_id"`
|
||||
UserID uint64 `orm:"column(user_id);default(0)" json:"user_id"`
|
||||
Name string `orm:"column(name);size(100)" json:"name"`
|
||||
Transport string `orm:"column(transport);size(20)" json:"transport"` // stdio/http/sse
|
||||
Command string `orm:"column(command);size(255)" json:"command"` // stdio 命令
|
||||
Args string `orm:"column(args);type(text)" json:"args"` // stdio 参数 JSON数组
|
||||
Env string `orm:"column(env);type(text)" json:"env"` // 环境变量 JSON对象
|
||||
URL string `orm:"column(url);size(512)" json:"url"` // http/sse 地址
|
||||
Headers string `orm:"column(headers);type(text)" json:"headers"` // 请求头 JSON对象
|
||||
Description string `orm:"column(description);size(255)" json:"description"`
|
||||
Provider string `orm:"column(provider);size(50)" json:"provider"` // 提供方名称
|
||||
FromMarket string `orm:"column(from_market);size(50)" json:"from_market"` // 来源市场key
|
||||
Enabled int8 `orm:"column(enabled);default(0)" json:"enabled"` // 0-禁用 1-启用(仅启用项在会话中生效)
|
||||
Status int8 `orm:"column(status);default(0)" json:"status"` // 0-未测试 1-连接正常 2-连接失败
|
||||
LastError string `orm:"column(last_error);size(500)" json:"last_error"`
|
||||
ToolCount int `orm:"column(tool_count);default(0)" json:"tool_count"`
|
||||
Remark string `orm:"column(remark);size(255)" json:"remark"`
|
||||
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
|
||||
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
|
||||
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
|
||||
|
||||
// 非数据库字段:连接后发现的工具列表(用于前端展示)
|
||||
Tools []McpToolInfo `orm:"-" json:"tools,omitempty"`
|
||||
}
|
||||
|
||||
// McpToolInfo MCP 工具信息(用于前端展示与 LLM 工具注入)
|
||||
type McpToolInfo struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
InputSchema interface{} `json:"input_schema"`
|
||||
}
|
||||
|
||||
func (m *BackendMcpServer) TableName() string {
|
||||
return "yz_backend_mcp_server"
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// BackendMcpTool MCP工具配置表
|
||||
type BackendMcpTool struct {
|
||||
ID uint64 `orm:"column(id);pk;auto" json:"id"`
|
||||
TenantID string `orm:"column(tenant_id);size(64)" json:"tenant_id"`
|
||||
UserID uint64 `orm:"column(user_id);default(0)" json:"user_id"`
|
||||
Name string `orm:"column(name);size(100)" json:"name"`
|
||||
Type string `orm:"column(type);size(20)" json:"type"` // rest/http/other
|
||||
URL string `orm:"column(url);size(255)" json:"url"`
|
||||
Method string `orm:"column(method);size(10)" json:"method"` // GET/POST/PUT/DELETE
|
||||
Headers string `orm:"column(headers);type(text)" json:"headers"` // JSON
|
||||
Params string `orm:"column(params);type(text)" json:"params"` // JSON
|
||||
Body string `orm:"column(body);type(text)" json:"body"` // JSON
|
||||
Enabled int8 `orm:"column(enabled);default(1)" json:"enabled"` // 0-禁用 1-启用
|
||||
Remark string `orm:"column(remark);size(255)" json:"remark"`
|
||||
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
|
||||
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
|
||||
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
|
||||
}
|
||||
|
||||
func (m *BackendMcpTool) TableName() string {
|
||||
return "yz_backend_mcp_tool"
|
||||
}
|
||||
@@ -81,6 +81,8 @@ func Init(_ string) {
|
||||
new(BackendAiChatSession),
|
||||
new(BackendAiChatMessage),
|
||||
new(BackendAiChatPreset),
|
||||
new(BackendMcpTool),
|
||||
new(BackendMcpServer),
|
||||
|
||||
new(CmsArticleCategory),
|
||||
new(CmsArticle),
|
||||
|
||||
Reference in New Issue
Block a user