dev
This commit is contained in:
parent
13e387fa94
commit
160bb86fb0
BIN
ai_scheduler
BIN
ai_scheduler
Binary file not shown.
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
ollama:
|
||||
base_url: "http://localhost:11434"
|
||||
model: "qwen:8b"
|
||||
model: "qwen3:8b"
|
||||
timeout: 30s
|
||||
|
||||
tools:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Package docs GENERATED BY SWAG; DO NOT EDIT
|
||||
// Package docs Code generated by swaggo/swag. DO NOT EDIT
|
||||
package docs
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
|
@ -104,10 +104,6 @@ const docTemplate = `{
|
|||
"message": {
|
||||
"type": "string",
|
||||
"example": "北京今天天气怎么样?"
|
||||
},
|
||||
"model": {
|
||||
"type": "string",
|
||||
"example": "llama2"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -187,6 +183,8 @@ var SwaggerInfo = &swag.Spec{
|
|||
Description: "智能路由调度系统API文档",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
LeftDelim: "{{",
|
||||
RightDelim: "}}",
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "智能路由调度系统API文档",
|
||||
"title": "AI Scheduler API",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "API Support",
|
||||
"url": "http://www.swagger.io/support",
|
||||
"email": "support@swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
},
|
||||
"version": "1.0"
|
||||
},
|
||||
"host": "localhost:8080",
|
||||
"basePath": "/",
|
||||
"paths": {
|
||||
"/api/v1/chat": {
|
||||
"post": {
|
||||
"description": "发送消息给AI助手,支持工具调用",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"chat"
|
||||
],
|
||||
"summary": "智能聊天",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "聊天请求",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.ChatRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "聊天响应",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.ChatResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "请求错误",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "服务器错误",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/health": {
|
||||
"get": {
|
||||
"description": "检查服务是否正常运行",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"system"
|
||||
],
|
||||
"summary": "健康检查",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"handlers.ChatRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string",
|
||||
"example": "北京今天天气怎么样?"
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.ChatResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"finished": {
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"example": "北京今天天气晴朗,温度15.3°C"
|
||||
},
|
||||
"tool_calls": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/handlers.ToolCallResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.ErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"example": 400
|
||||
},
|
||||
"error": {
|
||||
"type": "string",
|
||||
"example": "Invalid request"
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"example": "请求参数错误"
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.FunctionCallResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"arguments": {},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"example": "get_weather"
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.ToolCallResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"function": {
|
||||
"$ref": "#/definitions/handlers.FunctionCallResponse"
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"example": "call_1"
|
||||
},
|
||||
"result": {},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"example": "function"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
basePath: /
|
||||
definitions:
|
||||
handlers.ChatRequest:
|
||||
properties:
|
||||
message:
|
||||
example: 北京今天天气怎么样?
|
||||
type: string
|
||||
required:
|
||||
- message
|
||||
type: object
|
||||
handlers.ChatResponse:
|
||||
properties:
|
||||
finished:
|
||||
example: true
|
||||
type: boolean
|
||||
message:
|
||||
example: 北京今天天气晴朗,温度15.3°C
|
||||
type: string
|
||||
tool_calls:
|
||||
items:
|
||||
$ref: '#/definitions/handlers.ToolCallResponse'
|
||||
type: array
|
||||
type: object
|
||||
handlers.ErrorResponse:
|
||||
properties:
|
||||
code:
|
||||
example: 400
|
||||
type: integer
|
||||
error:
|
||||
example: Invalid request
|
||||
type: string
|
||||
message:
|
||||
example: 请求参数错误
|
||||
type: string
|
||||
type: object
|
||||
handlers.FunctionCallResponse:
|
||||
properties:
|
||||
arguments: {}
|
||||
name:
|
||||
example: get_weather
|
||||
type: string
|
||||
type: object
|
||||
handlers.ToolCallResponse:
|
||||
properties:
|
||||
function:
|
||||
$ref: '#/definitions/handlers.FunctionCallResponse'
|
||||
id:
|
||||
example: call_1
|
||||
type: string
|
||||
result: {}
|
||||
type:
|
||||
example: function
|
||||
type: string
|
||||
type: object
|
||||
host: localhost:8080
|
||||
info:
|
||||
contact:
|
||||
email: support@swagger.io
|
||||
name: API Support
|
||||
url: http://www.swagger.io/support
|
||||
description: 智能路由调度系统API文档
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
termsOfService: http://swagger.io/terms/
|
||||
title: AI Scheduler API
|
||||
version: "1.0"
|
||||
paths:
|
||||
/api/v1/chat:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 发送消息给AI助手,支持工具调用
|
||||
parameters:
|
||||
- description: 聊天请求
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.ChatRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 聊天响应
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.ChatResponse'
|
||||
"400":
|
||||
description: 请求错误
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.ErrorResponse'
|
||||
"500":
|
||||
description: 服务器错误
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.ErrorResponse'
|
||||
summary: 智能聊天
|
||||
tags:
|
||||
- chat
|
||||
/health:
|
||||
get:
|
||||
description: 检查服务是否正常运行
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
summary: 健康检查
|
||||
tags:
|
||||
- system
|
||||
swagger: "2.0"
|
4
go.mod
4
go.mod
|
@ -9,7 +9,7 @@ require (
|
|||
github.com/spf13/viper v1.17.0
|
||||
github.com/swaggo/files v1.0.1
|
||||
github.com/swaggo/gin-swagger v1.6.1
|
||||
github.com/swaggo/swag v1.8.12
|
||||
github.com/swaggo/swag v1.16.6
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -57,7 +57,9 @@ require (
|
|||
golang.org/x/arch v0.8.0 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa // indirect
|
||||
golang.org/x/mod v0.23.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/sync v0.12.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
golang.org/x/tools v0.30.0 // indirect
|
||||
|
|
4
go.sum
4
go.sum
|
@ -257,8 +257,8 @@ github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE=
|
|||
github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg=
|
||||
github.com/swaggo/gin-swagger v1.6.1 h1:Ri06G4gc9N4t4k8hekMigJ9zKTFSlqj/9paAQCQs7cY=
|
||||
github.com/swaggo/gin-swagger v1.6.1/go.mod h1:LQ+hJStHakCWRiK/YNYtJOu4mR2FP+pxLnILT/qNiTw=
|
||||
github.com/swaggo/swag v1.8.12 h1:pctzkNPu0AlQP2royqX3apjKCQonAnf7KGoxeO4y64w=
|
||||
github.com/swaggo/swag v1.8.12/go.mod h1:lNfm6Gg+oAq3zRJQNEMBE66LIJKM44mxFqhEEgy2its=
|
||||
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
|
||||
github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
|
|
|
@ -22,7 +22,6 @@ func NewChatHandler(routerService types.RouterService) *ChatHandler {
|
|||
// ChatRequest HTTP聊天请求
|
||||
type ChatRequest struct {
|
||||
Message string `json:"message" binding:"required" example:"北京今天天气怎么样?"`
|
||||
Model string `json:"model,omitempty" example:"llama2"`
|
||||
}
|
||||
|
||||
// ChatResponse HTTP聊天响应
|
||||
|
@ -78,7 +77,6 @@ func (h *ChatHandler) Chat(c *gin.Context) {
|
|||
// 转换为服务层请求
|
||||
serviceReq := &types.ChatRequest{
|
||||
Message: req.Message,
|
||||
Model: req.Model,
|
||||
}
|
||||
|
||||
// 调用路由服务
|
||||
|
|
Loading…
Reference in New Issue