llm,doc
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package router
|
||||
|
||||
type RouterGroup struct {
|
||||
LLMRouter
|
||||
}
|
||||
|
||||
var RouterGroupApp = new(RouterGroup)
|
||||
@@ -0,0 +1,30 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/middleware"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/plugin/volcengine/api"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type LLMRouter struct{}
|
||||
|
||||
// InitLLMRouter 初始化LLM路由
|
||||
func (l *LLMRouter) InitLLMRouter(Router *gin.RouterGroup) {
|
||||
// LLM相关路由组,使用操作记录中间件
|
||||
llmRouter := Router.Group("llm").Use(middleware.OperationRecord())
|
||||
// LLM查询路由组,不使用操作记录中间件(用于GET请求)
|
||||
llmRouterWithoutRecord := Router.Group("llm")
|
||||
|
||||
// 获取API实例
|
||||
llmApi := api.ApiGroupApp.LLMApi
|
||||
|
||||
{
|
||||
// 需要记录操作的路由(POST请求)
|
||||
llmRouter.POST("chat", llmApi.ChatCompletion) // LLM聊天完成
|
||||
llmRouter.POST("stop", llmApi.StopGeneration) // 停止LLM生成
|
||||
}
|
||||
{
|
||||
// 不需要记录操作的路由(GET请求)
|
||||
llmRouterWithoutRecord.GET("sessions", llmApi.GetActiveSessionsCount) // 获取活跃会话数量
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user