包含前端(Vue3 + VueFlow 画布)、后端(Go)、文档体系。 - 工作台画布:节点拖放、连线模式、右键菜单、AI 助手 - 后端:连接器 API、专员种子数据 - 导航:左侧导航、工坊、市场、控制台
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package api
|
|
|
|
import (
|
|
"eaisalestrain/backend/internal/config"
|
|
"eaisalestrain/backend/internal/web"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// routeItem 路由摘要(返回给前端选择器)
|
|
type routeItem struct {
|
|
ID string `json:"id"`
|
|
Provider string `json:"provider"`
|
|
Model string `json:"model"`
|
|
BaseURL string `json:"base_url"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
func toRouteItems(routes []*config.RouteConfig) []routeItem {
|
|
items := make([]routeItem, 0, len(routes))
|
|
for _, r := range routes {
|
|
items = append(items, routeItem{
|
|
ID: r.RouteID,
|
|
Provider: r.Provider,
|
|
Model: r.Model,
|
|
BaseURL: r.BaseURL,
|
|
Description: r.Description,
|
|
})
|
|
}
|
|
return items
|
|
}
|
|
|
|
// ListChatRoutes 返回可用 chat 路由列表(供前端选择器使用)
|
|
func ListChatRoutes(c *gin.Context) {
|
|
routes, err := config.GetRoutesByCategory("chat")
|
|
if err != nil {
|
|
web.Fail(c, web.NewLLMNotConfigured("路由加载失败: "+err.Error()))
|
|
return
|
|
}
|
|
web.OK(c, gin.H{"routes": toRouteItems(routes)})
|
|
}
|
|
|
|
// ListEmbedRoutes 返回可用 embedding 路由列表
|
|
func ListEmbedRoutes(c *gin.Context) {
|
|
routes, err := config.GetRoutesByCategory("embed")
|
|
if err != nil {
|
|
web.Fail(c, web.NewLLMNotConfigured("路由加载失败: "+err.Error()))
|
|
return
|
|
}
|
|
web.OK(c, gin.H{"routes": toRouteItems(routes)})
|
|
} |