diff --git a/Makefile b/Makefile index d2e2da51..49943514 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help build run test clean docker-build-app docker-build-docreader docker-build-frontend docker-build-all docker-run migrate-up migrate-down docker-restart docker-stop start-all stop-all start-ollama stop-ollama build-images build-images-app build-images-docreader build-images-frontend clean-images check-env list-containers pull-images show-platform dev-start dev-stop dev-restart dev-logs dev-status dev-app dev-frontend +.PHONY: help build run test clean docker-build-app docker-build-docreader docker-build-frontend docker-build-all docker-run migrate-up migrate-down docker-restart docker-stop start-all stop-all start-ollama stop-ollama build-images build-images-app build-images-docreader build-images-frontend clean-images check-env list-containers pull-images show-platform dev-start dev-stop dev-restart dev-logs dev-status dev-app dev-frontend docs install-swagger # Show help help: @@ -39,7 +39,8 @@ help: @echo " fmt 格式化代码" @echo " lint 代码检查" @echo " deps 安装依赖" - @echo " docs 生成 API 文档" + @echo " docs 生成 Swagger API 文档" + @echo " install-swagger 安装 swag 工具" @echo "" @echo "环境检查:" @echo " check-env 检查环境配置" @@ -194,9 +195,16 @@ migrate-goto: fi ./scripts/migrate.sh goto $(version) -# Generate API documentation +# Generate API documentation (Swagger) docs: - swag init -g $(MAIN_PATH)/main.go -o ./docs + @echo "生成 Swagger API 文档..." + swag init -g $(MAIN_PATH)/main.go -o ./docs --parseDependency --parseInternal + @echo "文档已生成到 ./docs 目录" + @echo "启动服务后访问 http://localhost:8080/swagger/index.html 查看文档" + +# Install swagger tool +install-swagger: + go install github.com/swaggo/swag/cmd/swag@latest # Format code fmt: diff --git a/cmd/server/main.go b/cmd/server/main.go index b253f359..bb751d34 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -1,5 +1,21 @@ // Package main is the main package for the WeKnora server // It contains the main function and the entry point for the server +// +// @title WeKnora API +// @version 1.0 +// @description WeKnora 知识库管理系统 API 文档 +// @termsOfService http://swagger.io/terms/ +// +// @contact.name WeKnora Github +// @contact.url https://github.com/Tencent/WeKnora +// +// @host localhost:8080 +// @BasePath /api/v1 +// +// @securityDefinitions.apikey Bearer +// @in header +// @name Authorization +// @description 输入 Bearer {token} 格式的 JWT 令牌 package main import ( diff --git a/docs/docs.go b/docs/docs.go new file mode 100644 index 00000000..dc56dac7 --- /dev/null +++ b/docs/docs.go @@ -0,0 +1,7408 @@ +// Package docs Code generated by swaggo/swag. DO NOT EDIT +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "WeKnora Github", + "url": "https://github.com/Tencent/WeKnora" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/api/v1/web-search/providers": { + "get": { + "description": "Returns the list of available web search providers from configuration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "web-search" + ], + "summary": "Get available web search providers", + "responses": { + "200": { + "description": "List of providers", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/auth/change-password": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "修改当前用户的登录密码", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "修改密码", + "parameters": [ + { + "description": "密码修改请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "new_password": { + "type": "string" + }, + "old_password": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "修改成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/login": { + "post": { + "description": "用户登录并获取访问令牌", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "用户登录", + "parameters": [ + { + "description": "登录请求参数", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.LoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.LoginResponse" + } + }, + "401": { + "description": "认证失败", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/logout": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "撤销当前访问令牌并登出", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "用户登出", + "responses": { + "200": { + "description": "登出成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/me": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前登录用户的详细信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "获取当前用户信息", + "responses": { + "200": { + "description": "用户信息", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "未授权", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/refresh": { + "post": { + "description": "使用刷新令牌获取新的访问令牌", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "刷新令牌", + "parameters": [ + { + "description": "刷新令牌", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "refreshToken": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "新令牌", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "令牌无效", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/register": { + "post": { + "description": "注册新用户账号", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "用户注册", + "parameters": [ + { + "description": "注册请求参数", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RegisterRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RegisterResponse" + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/validate": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "验证访问令牌是否有效", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "验证令牌", + "responses": { + "200": { + "description": "令牌有效", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "令牌无效", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/chunks/by-id/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "仅通过分块ID获取分块详情(不需要knowledge_id)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "通过ID获取分块", + "parameters": [ + { + "type": "string", + "description": "分块ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "分块详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "分块不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/chunks/by-id/{id}/questions": { + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除分块中生成的问题", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "删除生成的问题", + "parameters": [ + { + "type": "string", + "description": "分块ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "问题ID", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "question_id": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "分块不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/chunks/{knowledge_id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取指定知识下的所有分块列表,支持分页", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "获取知识分块列表", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "knowledge_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 1, + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "default": 10, + "description": "每页数量", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "分块列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定知识下的所有分块", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "删除知识下所有分块", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "knowledge_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/chunks/{knowledge_id}/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新指定分块的内容和属性", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "更新分块", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "knowledge_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "分块ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.UpdateChunkRequest" + } + } + ], + "responses": { + "200": { + "description": "更新后的分块", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "分块不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的分块", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "删除分块", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "knowledge_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "分块ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "分块不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/evaluation/": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据任务ID获取评估结果", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "评估" + ], + "summary": "获取评估结果", + "parameters": [ + { + "type": "string", + "description": "评估任务ID", + "name": "task_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "评估结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "对知识库进行评估测试", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "评估" + ], + "summary": "执行评估", + "parameters": [ + { + "description": "评估请求参数", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.EvaluationRequest" + } + } + ], + "responses": { + "200": { + "description": "评估任务", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/extract/relations": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "从文本中提取实体和关系", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "提取文本关系", + "parameters": [ + { + "description": "提取请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.TextRelationExtractionRequest" + } + } + ], + "responses": { + "200": { + "description": "提取结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/fabri/tag": { + "get": { + "description": "随机生成一组标签", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "生成随机标签", + "responses": { + "200": { + "description": "生成的标签", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/initialization/fabri/text": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据标签生成示例文本", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "生成示例文本", + "parameters": [ + { + "description": "生成请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.FabriTextRequest" + } + } + ], + "responses": { + "200": { + "description": "生成的文本", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/kb/{kbId}": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据知识库ID执行完整配置更新", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "初始化知识库配置", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "kbId", + "in": "path", + "required": true + }, + { + "description": "初始化请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "初始化成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/kb/{kbId}/config": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据知识库ID获取当前配置信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "获取知识库配置", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "kbId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "配置信息", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "知识库不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据知识库ID更新模型和分块配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "更新知识库配置", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "kbId", + "in": "path", + "required": true + }, + { + "description": "配置请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.KBModelConfigRequest" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "知识库不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/models/embedding/test": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "测试Embedding接口是否可用并返回向量维度", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "测试Embedding模型", + "parameters": [ + { + "description": "Embedding测试请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "测试结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/models/remote/check": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "检查远程API模型连接是否正常", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "检查远程模型", + "parameters": [ + { + "description": "模型检查请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.RemoteModelCheckRequest" + } + } + ], + "responses": { + "200": { + "description": "检查结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/models/rerank/check": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "检查Rerank模型连接和功能是否正常", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "检查Rerank模型", + "parameters": [ + { + "description": "Rerank检查请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "检查结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/multimodal/test": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "上传图片测试多模态处理功能", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "测试多模态功能", + "parameters": [ + { + "type": "file", + "description": "测试图片", + "name": "image", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "VLM模型名称", + "name": "vlm_model", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "VLM Base URL", + "name": "vlm_base_url", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "VLM API Key", + "name": "vlm_api_key", + "in": "formData" + }, + { + "type": "string", + "description": "VLM接口类型", + "name": "vlm_interface_type", + "in": "formData" + }, + { + "type": "string", + "description": "存储类型(cos/minio)", + "name": "storage_type", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "测试结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/ollama/download/tasks": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "列出所有Ollama模型下载任务", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "列出下载任务", + "responses": { + "200": { + "description": "任务列表", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/initialization/ollama/download/{taskId}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取Ollama模型下载任务的进度", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "获取下载进度", + "parameters": [ + { + "type": "string", + "description": "任务ID", + "name": "taskId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "下载进度", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "任务不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/ollama/models": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "列出已安装的Ollama模型", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "列出Ollama模型", + "responses": { + "200": { + "description": "模型列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/ollama/models/check": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "检查指定的Ollama模型是否已安装", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "检查Ollama模型状态", + "parameters": [ + { + "description": "模型名称列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "models": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + ], + "responses": { + "200": { + "description": "模型状态", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/ollama/models/download": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "异步下载指定的Ollama模型", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "下载Ollama模型", + "parameters": [ + { + "description": "模型名称", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "modelName": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "下载任务信息", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/ollama/status": { + "get": { + "description": "检查Ollama服务是否可用", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "检查Ollama服务状态", + "responses": { + "200": { + "description": "Ollama状态", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/knowledge-bases": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前租户的所有知识库", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "获取知识库列表", + "responses": { + "200": { + "description": "知识库列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "创建新的知识库", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "创建知识库", + "parameters": [ + { + "description": "知识库信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.KnowledgeBase" + } + } + ], + "responses": { + "201": { + "description": "创建的知识库", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/copy": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "将一个知识库的内容复制到另一个知识库", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "复制知识库", + "parameters": [ + { + "description": "复制请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.CopyKnowledgeBaseRequest" + } + } + ], + "responses": { + "200": { + "description": "复制成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取知识库详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "获取知识库详情", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "知识库详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "知识库不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新知识库的名称、描述和配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "更新知识库", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.UpdateKnowledgeBaseRequest" + } + } + ], + "responses": { + "200": { + "description": "更新后的知识库", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的知识库及其所有内容", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "删除知识库", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entries": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取知识库下的FAQ条目列表,支持分页和筛选", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "获取FAQ条目列表", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "标签ID筛选", + "name": "tag_id", + "in": "query" + }, + { + "type": "string", + "description": "关键词搜索", + "name": "keyword", + "in": "query" + } + ], + "responses": { + "200": { + "description": "FAQ列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "异步批量更新或插入FAQ条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "批量更新/插入FAQ条目", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "批量操作请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQBatchUpsertPayload" + } + } + ], + "responses": { + "200": { + "description": "任务ID", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "批量删除指定的FAQ条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "批量删除FAQ条目", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "要删除的FAQ ID列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "ids": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entries/export": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "将所有FAQ条目导出为CSV文件", + "consumes": [ + "application/json" + ], + "produces": [ + "text/csv" + ], + "tags": [ + "FAQ管理" + ], + "summary": "导出FAQ条目", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "CSV文件", + "schema": { + "type": "file" + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entries/fields": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "批量更新FAQ条目的多个字段(is_enabled, is_recommended, tag_id)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "批量更新FAQ字段", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "字段更新请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsBatchUpdate" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entries/tags": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "批量更新FAQ条目的标签", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "批量更新FAQ标签", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "标签更新请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entries/{entry_id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新指定的FAQ条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "更新FAQ条目", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "FAQ条目ID", + "name": "entry_id", + "in": "path", + "required": true + }, + { + "description": "FAQ条目", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryPayload" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entry": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "同步创建单个FAQ条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "创建单个FAQ条目", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "FAQ条目", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryPayload" + } + } + ], + "responses": { + "200": { + "description": "创建的FAQ条目", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/search": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "使用混合搜索在FAQ中搜索", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "搜索FAQ", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "搜索请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQSearchRequest" + } + } + ], + "responses": { + "200": { + "description": "搜索结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/hybrid-search": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "在知识库中执行向量和关键词混合搜索", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "混合搜索", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "搜索参数", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SearchParams" + } + } + ], + "responses": { + "200": { + "description": "搜索结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/knowledge": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取知识库下的知识列表,支持分页和筛选", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "获取知识列表", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "标签ID筛选", + "name": "tag_id", + "in": "query" + }, + { + "type": "string", + "description": "关键词搜索", + "name": "keyword", + "in": "query" + }, + { + "type": "string", + "description": "文件类型筛选", + "name": "file_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "知识列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/knowledge/file": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "上传文件并创建知识条目", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "从文件创建知识", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "上传的文件", + "name": "file", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "自定义文件名", + "name": "fileName", + "in": "formData" + }, + { + "type": "string", + "description": "元数据JSON", + "name": "metadata", + "in": "formData" + }, + { + "type": "boolean", + "description": "启用多模态处理", + "name": "enable_multimodel", + "in": "formData" + } + ], + "responses": { + "200": { + "description": "创建的知识", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "409": { + "description": "文件重复", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/knowledge-bases/{id}/knowledge/manual": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "手工录入Markdown格式的知识内容", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "手工创建知识", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "手工知识内容", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ManualKnowledgePayload" + } + } + ], + "responses": { + "200": { + "description": "创建的知识", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/knowledge/url": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "从指定URL抓取内容并创建知识条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "从URL创建知识", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "URL请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "enable_multimodel": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "url": { + "type": "string" + } + } + } + } + ], + "responses": { + "201": { + "description": "创建的知识", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "409": { + "description": "URL重复", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/knowledge-bases/{id}/tags": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取知识库下的所有标签及统计信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "标签管理" + ], + "summary": "获取标签列表", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "关键词搜索", + "name": "keyword", + "in": "query" + } + ], + "responses": { + "200": { + "description": "标签列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "在知识库下创建新标签", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "标签管理" + ], + "summary": "创建标签", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "标签信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "name": { + "type": "string" + }, + "sort_order": { + "type": "integer" + } + } + } + } + ], + "responses": { + "200": { + "description": "创建的标签", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/tags/{tag_id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新标签信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "标签管理" + ], + "summary": "更新标签", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "标签ID", + "name": "tag_id", + "in": "path", + "required": true + }, + { + "description": "标签更新信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新后的标签", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除标签,可使用force=true强制删除被引用的标签", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "标签管理" + ], + "summary": "删除标签", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "标签ID", + "name": "tag_id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "强制删除", + "name": "force", + "in": "query" + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/batch": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID列表批量获取知识条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "批量获取知识", + "parameters": [ + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "csv", + "description": "知识ID列表", + "name": "ids", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "知识列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/image/{id}/{chunk_id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新知识分块的图像信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "更新图像信息", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "分块ID", + "name": "chunk_id", + "in": "path", + "required": true + }, + { + "description": "图像信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "image_info": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/manual/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新手工录入的Markdown知识内容", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "更新手工知识", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "手工知识内容", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ManualKnowledgePayload" + } + } + ], + "responses": { + "200": { + "description": "更新后的知识", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/tags": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "批量更新知识条目的标签", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "批量更新知识标签", + "parameters": [ + { + "description": "标签更新请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取知识条目详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "获取知识详情", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "知识详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "知识不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新知识条目信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "更新知识", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "知识信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Knowledge" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID删除知识条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "删除知识", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/{id}/download": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "下载知识条目关联的原始文件", + "consumes": [ + "application/json" + ], + "produces": [ + "application/octet-stream" + ], + "tags": [ + "知识管理" + ], + "summary": "下载知识文件", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "文件内容", + "schema": { + "type": "file" + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/mcp-services": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前租户的所有MCP服务", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "获取MCP服务列表", + "responses": { + "200": { + "description": "MCP服务列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "创建新的MCP服务配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "创建MCP服务", + "parameters": [ + { + "description": "MCP服务配置", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPService" + } + } + ], + "responses": { + "200": { + "description": "创建的MCP服务", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/mcp-services/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取MCP服务详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "获取MCP服务详情", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "MCP服务详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "服务不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新MCP服务配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "更新MCP服务", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新字段", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新后的MCP服务", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的MCP服务", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "删除MCP服务", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/mcp-services/{id}/resources": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取MCP服务提供的资源列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "获取MCP服务资源列表", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "资源列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/mcp-services/{id}/test": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "测试MCP服务是否可以正常连接", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "测试MCP服务连接", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "测试结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/mcp-services/{id}/tools": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取MCP服务提供的工具列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "获取MCP服务工具列表", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "工具列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/messages/{session_id}/load": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "加载会话的消息历史,支持分页和时间筛选", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息" + ], + "summary": "加载消息历史", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "返回数量", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "description": "在此时间之前的消息(RFC3339Nano格式)", + "name": "before_time", + "in": "query" + } + ], + "responses": { + "200": { + "description": "消息列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/messages/{session_id}/{id}": { + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "从会话中删除指定消息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息" + ], + "summary": "删除消息", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "消息ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/models": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前租户的所有模型", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "模型管理" + ], + "summary": "获取模型列表", + "responses": { + "200": { + "description": "模型列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "创建新的模型配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "模型管理" + ], + "summary": "创建模型", + "parameters": [ + { + "description": "模型信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.CreateModelRequest" + } + } + ], + "responses": { + "201": { + "description": "创建的模型", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/models/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取模型详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "模型管理" + ], + "summary": "获取模型详情", + "parameters": [ + { + "type": "string", + "description": "模型ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "模型详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "模型不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新模型配置信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "模型管理" + ], + "summary": "更新模型", + "parameters": [ + { + "type": "string", + "description": "模型ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.UpdateModelRequest" + } + } + ], + "responses": { + "200": { + "description": "更新后的模型", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "模型不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的模型", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "模型管理" + ], + "summary": "删除模型", + "parameters": [ + { + "type": "string", + "description": "模型ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "模型不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前租户的会话列表,支持分页", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "获取会话列表", + "parameters": [ + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "会话列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "创建新的对话会话", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "创建会话", + "parameters": [ + { + "description": "会话创建请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.CreateSessionRequest" + } + } + ], + "responses": { + "201": { + "description": "创建的会话", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/search": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "在知识库中搜索(不使用LLM总结)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "问答" + ], + "summary": "知识搜索", + "parameters": [ + { + "description": "搜索请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.SearchKnowledgeRequest" + } + } + ], + "responses": { + "200": { + "description": "搜索结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取会话详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "获取会话详情", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "会话详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "会话不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新会话属性", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "更新会话", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "会话信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Session" + } + } + ], + "responses": { + "200": { + "description": "更新后的会话", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "会话不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的会话", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "删除会话", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "会话不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{session_id}/agent-qa": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "基于Agent的智能问答,支持多轮对话和SSE流式响应", + "consumes": [ + "application/json" + ], + "produces": [ + "text/event-stream" + ], + "tags": [ + "问答" + ], + "summary": "Agent问答", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "description": "问答请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.CreateKnowledgeQARequest" + } + } + ], + "responses": { + "200": { + "description": "问答结果(SSE流)", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{session_id}/continue": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "继续获取正在进行的流式响应", + "consumes": [ + "application/json" + ], + "produces": [ + "text/event-stream" + ], + "tags": [ + "问答" + ], + "summary": "继续流式响应", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "消息ID", + "name": "message_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "流式响应", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "会话或消息不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{session_id}/knowledge-qa": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "基于知识库的问答(使用LLM总结),支持SSE流式响应", + "consumes": [ + "application/json" + ], + "produces": [ + "text/event-stream" + ], + "tags": [ + "问答" + ], + "summary": "知识问答", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "description": "问答请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.CreateKnowledgeQARequest" + } + } + ], + "responses": { + "200": { + "description": "问答结果(SSE流)", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{session_id}/stop": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "停止当前正在进行的生成任务", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "问答" + ], + "summary": "停止生成", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "description": "停止请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.StopSessionRequest" + } + } + ], + "responses": { + "200": { + "description": "停止成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "会话或消息不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{session_id}/title": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据消息内容自动生成会话标题", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "生成会话标题", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "description": "生成请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.GenerateTitleRequest" + } + } + ], + "responses": { + "200": { + "description": "生成的标题", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/system/info": { + "get": { + "description": "获取系统版本、构建信息和引擎配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "系统" + ], + "summary": "获取系统信息", + "responses": { + "200": { + "description": "系统信息", + "schema": { + "$ref": "#/definitions/internal_handler.GetSystemInfoResponse" + } + } + } + } + }, + "/tenants": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前用户可访问的租户列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户列表", + "responses": { + "200": { + "description": "租户列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "创建新的租户", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "创建租户", + "parameters": [ + { + "description": "租户信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant" + } + } + ], + "responses": { + "201": { + "description": "创建的租户", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/all": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取系统中所有租户(需要跨租户访问权限)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取所有租户列表", + "responses": { + "200": { + "description": "所有租户列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "403": { + "description": "权限不足", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/kv/agent-config": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取租户的全局Agent配置(默认应用于所有会话)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户Agent配置", + "responses": { + "200": { + "description": "Agent配置", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/kv/conversation-config": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取租户的全局对话配置(默认应用于普通模式会话)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户对话配置", + "responses": { + "200": { + "description": "对话配置", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/kv/web-search-config": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取租户的网络搜索配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户网络搜索配置", + "responses": { + "200": { + "description": "网络搜索配置", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/kv/{key}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取租户级别的KV配置(支持agent-config、web-search-config、conversation-config)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户KV配置", + "parameters": [ + { + "type": "string", + "description": "配置键名", + "name": "key", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "配置值", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "不支持的键", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新租户级别的KV配置(支持agent-config、web-search-config、conversation-config)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "更新租户KV配置", + "parameters": [ + { + "type": "string", + "description": "配置键名", + "name": "key", + "in": "path", + "required": true + }, + { + "description": "配置值", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "不支持的键", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/search": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "分页搜索租户(需要跨租户访问权限)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "搜索租户", + "parameters": [ + { + "type": "string", + "description": "搜索关键词", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "description": "租户ID筛选", + "name": "tenant_id", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "每页数量", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "搜索结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "403": { + "description": "权限不足", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取租户详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户详情", + "parameters": [ + { + "type": "integer", + "description": "租户ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "租户详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "租户不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新租户信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "更新租户", + "parameters": [ + { + "type": "integer", + "description": "租户ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "租户信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant" + } + } + ], + "responses": { + "200": { + "description": "更新后的租户", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的租户", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "删除租户", + "parameters": [ + { + "type": "integer", + "description": "租户ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + } + }, + "definitions": { + "github_com_Tencent_WeKnora_internal_errors.AppError": { + "type": "object", + "properties": { + "code": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.ErrorCode" + }, + "details": {}, + "message": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_errors.ErrorCode": { + "type": "integer", + "enum": [ + 1000, + 1001, + 1002, + 1003, + 1004, + 1005, + 1006, + 1007, + 1008, + 1009, + 1010, + 2000, + 2001, + 2002, + 2003, + 2004, + 2100, + 2101, + 2102, + 2103 + ], + "x-enum-varnames": [ + "ErrBadRequest", + "ErrUnauthorized", + "ErrForbidden", + "ErrNotFound", + "ErrMethodNotAllowed", + "ErrConflict", + "ErrTooManyRequests", + "ErrInternalServer", + "ErrServiceUnavailable", + "ErrTimeout", + "ErrValidation", + "ErrTenantNotFound", + "ErrTenantAlreadyExists", + "ErrTenantInactive", + "ErrTenantNameRequired", + "ErrTenantInvalidStatus", + "ErrAgentMissingThinkingModel", + "ErrAgentMissingAllowedTools", + "ErrAgentInvalidMaxIterations", + "ErrAgentInvalidTemperature" + ] + }, + "github_com_Tencent_WeKnora_internal_types.AgentConfig": { + "type": "object", + "properties": { + "allowed_tools": { + "description": "List of allowed tool names", + "type": "array", + "items": { + "type": "string" + } + }, + "knowledge_bases": { + "description": "Accessible knowledge base IDs", + "type": "array", + "items": { + "type": "string" + } + }, + "max_iterations": { + "description": "Maximum number of ReAct iterations", + "type": "integer" + }, + "reflection_enabled": { + "description": "Whether to enable reflection", + "type": "boolean" + }, + "system_prompt_web_disabled": { + "description": "Custom prompt when web search is disabled", + "type": "string" + }, + "system_prompt_web_enabled": { + "description": "Custom prompt when web search is enabled", + "type": "string" + }, + "temperature": { + "description": "LLM temperature for agent", + "type": "number" + }, + "use_custom_system_prompt": { + "description": "Whether to use custom system prompt instead of default", + "type": "boolean" + }, + "web_search_enabled": { + "description": "Whether web search tool is enabled", + "type": "boolean" + }, + "web_search_max_results": { + "description": "Maximum number of web search results (default: 5)", + "type": "integer" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.AgentStep": { + "type": "object", + "properties": { + "iteration": { + "description": "Iteration number (0-indexed)", + "type": "integer" + }, + "thought": { + "description": "LLM's reasoning/thinking (Think phase)", + "type": "string" + }, + "timestamp": { + "description": "When this step occurred", + "type": "string" + }, + "tool_calls": { + "description": "Tools called in this step (Act phase)", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ToolCall" + } + } + } + }, + "github_com_Tencent_WeKnora_internal_types.AnswerStrategy": { + "type": "string", + "enum": [ + "all", + "random" + ], + "x-enum-varnames": [ + "AnswerStrategyAll", + "AnswerStrategyRandom" + ] + }, + "github_com_Tencent_WeKnora_internal_types.ChunkingConfig": { + "type": "object", + "properties": { + "chunk_overlap": { + "description": "Chunk overlap", + "type": "integer" + }, + "chunk_size": { + "description": "Chunk size", + "type": "integer" + }, + "enable_multimodal": { + "description": "EnableMultimodal (deprecated, kept for backward compatibility with old data)", + "type": "boolean" + }, + "separators": { + "description": "Separators", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ContextCompressionStrategy": { + "type": "string", + "enum": [ + "sliding_window", + "smart" + ], + "x-enum-varnames": [ + "ContextCompressionSlidingWindow", + "ContextCompressionSmart" + ] + }, + "github_com_Tencent_WeKnora_internal_types.ContextConfig": { + "type": "object", + "properties": { + "compression_strategy": { + "description": "Compression strategy: \"sliding_window\" or \"smart\"", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ContextCompressionStrategy" + } + ] + }, + "max_tokens": { + "description": "Maximum tokens allowed in LLM context", + "type": "integer" + }, + "recent_message_count": { + "description": "For sliding_window: number of messages to keep\nFor smart: number of recent messages to keep uncompressed", + "type": "integer" + }, + "summarize_threshold": { + "description": "Summarize threshold: number of messages before summarization", + "type": "integer" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ConversationConfig": { + "type": "object", + "properties": { + "context_template": { + "description": "ContextTemplate is the prompt template for summarizing retrieval results", + "type": "string" + }, + "embedding_top_k": { + "type": "integer" + }, + "enable_query_expansion": { + "type": "boolean" + }, + "enable_rewrite": { + "type": "boolean" + }, + "fallback_prompt": { + "type": "string" + }, + "fallback_response": { + "type": "string" + }, + "fallback_strategy": { + "description": "Fallback strategy", + "type": "string" + }, + "keyword_threshold": { + "type": "number" + }, + "max_completion_tokens": { + "description": "MaxTokens is the maximum number of tokens to generate", + "type": "integer" + }, + "max_rounds": { + "description": "Retrieval \u0026 strategy parameters", + "type": "integer" + }, + "prompt": { + "type": "string" + }, + "rerank_model_id": { + "type": "string" + }, + "rerank_threshold": { + "type": "number" + }, + "rerank_top_k": { + "type": "integer" + }, + "rewrite_prompt_system": { + "description": "Rewrite prompts", + "type": "string" + }, + "rewrite_prompt_user": { + "type": "string" + }, + "summary_model_id": { + "description": "Model configuration", + "type": "string" + }, + "temperature": { + "description": "Temperature controls the randomness of the model output", + "type": "number" + }, + "use_custom_context_template": { + "type": "boolean" + }, + "use_custom_system_prompt": { + "description": "Prompt is the system prompt for normal mode", + "type": "boolean" + }, + "vector_threshold": { + "type": "number" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.EmbeddingParameters": { + "type": "object", + "properties": { + "dimension": { + "type": "integer" + }, + "truncate_prompt_tokens": { + "type": "integer" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ExtractConfig": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.GraphNode" + } + }, + "relations": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.GraphRelation" + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "text": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQBatchUpsertPayload": { + "type": "object", + "required": [ + "entries" + ], + "properties": { + "entries": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryPayload" + } + }, + "knowledge_id": { + "type": "string" + }, + "mode": { + "type": "string", + "enum": [ + "append", + "replace" + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQConfig": { + "type": "object", + "properties": { + "index_mode": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQIndexMode" + }, + "question_index_mode": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQQuestionIndexMode" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsBatchUpdate": { + "type": "object", + "properties": { + "by_id": { + "description": "ByID 按条目ID更新,key为条目ID", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsUpdate" + } + }, + "by_tag": { + "description": "ByTag 按Tag批量更新,key为TagID(空字符串表示未分类)", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsUpdate" + } + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsUpdate": { + "type": "object", + "properties": { + "is_enabled": { + "type": "boolean" + }, + "is_recommended": { + "type": "boolean" + }, + "tag_id": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQEntryPayload": { + "type": "object", + "required": [ + "answers", + "standard_question" + ], + "properties": { + "answer_strategy": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.AnswerStrategy" + }, + "answers": { + "type": "array", + "items": { + "type": "string" + } + }, + "is_enabled": { + "type": "boolean" + }, + "is_recommended": { + "type": "boolean" + }, + "negative_questions": { + "type": "array", + "items": { + "type": "string" + } + }, + "similar_questions": { + "type": "array", + "items": { + "type": "string" + } + }, + "standard_question": { + "type": "string" + }, + "tag_id": { + "type": "string" + }, + "tag_name": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQIndexMode": { + "type": "string", + "enum": [ + "question_only", + "question_answer" + ], + "x-enum-varnames": [ + "FAQIndexModeQuestionOnly", + "FAQIndexModeQuestionAnswer" + ] + }, + "github_com_Tencent_WeKnora_internal_types.FAQQuestionIndexMode": { + "type": "string", + "enum": [ + "combined", + "separate" + ], + "x-enum-varnames": [ + "FAQQuestionIndexModeCombined", + "FAQQuestionIndexModeSeparate" + ] + }, + "github_com_Tencent_WeKnora_internal_types.FAQSearchRequest": { + "type": "object", + "required": [ + "query_text" + ], + "properties": { + "match_count": { + "type": "integer" + }, + "query_text": { + "type": "string" + }, + "vector_threshold": { + "type": "number" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FallbackStrategy": { + "type": "string", + "enum": [ + "fixed", + "model" + ], + "x-enum-comments": { + "FallbackStrategyFixed": "Fixed response", + "FallbackStrategyModel": "Model fallback response" + }, + "x-enum-descriptions": [ + "Fixed response", + "Model fallback response" + ], + "x-enum-varnames": [ + "FallbackStrategyFixed", + "FallbackStrategyModel" + ] + }, + "github_com_Tencent_WeKnora_internal_types.GraphNode": { + "type": "object", + "properties": { + "attributes": { + "type": "array", + "items": { + "type": "string" + } + }, + "chunks": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.GraphRelation": { + "type": "object", + "properties": { + "node1": { + "type": "string" + }, + "node2": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ImageProcessingConfig": { + "type": "object", + "properties": { + "model_id": { + "description": "Model ID", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.Knowledge": { + "type": "object", + "properties": { + "created_at": { + "description": "Creation time of the knowledge", + "type": "string" + }, + "deleted_at": { + "description": "Deletion time of the knowledge", + "allOf": [ + { + "$ref": "#/definitions/gorm.DeletedAt" + } + ] + }, + "description": { + "description": "Description of the knowledge", + "type": "string" + }, + "embedding_model_id": { + "description": "ID of the embedding model", + "type": "string" + }, + "enable_status": { + "description": "Enable status of the knowledge", + "type": "string" + }, + "error_message": { + "description": "Error message of the knowledge", + "type": "string" + }, + "file_hash": { + "description": "File hash of the knowledge", + "type": "string" + }, + "file_name": { + "description": "File name of the knowledge", + "type": "string" + }, + "file_path": { + "description": "File path of the knowledge", + "type": "string" + }, + "file_size": { + "description": "File size of the knowledge", + "type": "integer" + }, + "file_type": { + "description": "File type of the knowledge", + "type": "string" + }, + "id": { + "description": "Unique identifier of the knowledge", + "type": "string" + }, + "knowledge_base_id": { + "description": "ID of the knowledge base", + "type": "string" + }, + "metadata": { + "description": "Metadata of the knowledge", + "type": "array", + "items": { + "type": "integer" + } + }, + "parse_status": { + "description": "Parse status of the knowledge", + "type": "string" + }, + "processed_at": { + "description": "Processed time of the knowledge", + "type": "string" + }, + "source": { + "description": "Source of the knowledge", + "type": "string" + }, + "storage_size": { + "description": "Storage size of the knowledge", + "type": "integer" + }, + "summary_status": { + "description": "Summary status for async summary generation", + "type": "string" + }, + "tag_id": { + "description": "Optional tag ID for categorization within a knowledge base", + "type": "string" + }, + "tenant_id": { + "description": "Tenant ID", + "type": "integer" + }, + "title": { + "description": "Title of the knowledge", + "type": "string" + }, + "type": { + "description": "Type of the knowledge", + "type": "string" + }, + "updated_at": { + "description": "Last updated time of the knowledge", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.KnowledgeBase": { + "type": "object", + "properties": { + "chunk_count": { + "description": "Chunk count (not stored in database, calculated on query)", + "type": "integer" + }, + "chunking_config": { + "description": "Chunking configuration", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ChunkingConfig" + } + ] + }, + "cos_config": { + "description": "Storage config", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.StorageConfig" + } + ] + }, + "created_at": { + "description": "Creation time of the knowledge base", + "type": "string" + }, + "deleted_at": { + "description": "Deletion time of the knowledge base", + "allOf": [ + { + "$ref": "#/definitions/gorm.DeletedAt" + } + ] + }, + "description": { + "description": "Description of the knowledge base", + "type": "string" + }, + "embedding_model_id": { + "description": "ID of the embedding model", + "type": "string" + }, + "extract_config": { + "description": "Extract config", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ExtractConfig" + } + ] + }, + "faq_config": { + "description": "FAQConfig stores FAQ specific configuration such as indexing strategy", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQConfig" + } + ] + }, + "id": { + "description": "Unique identifier of the knowledge base", + "type": "string" + }, + "image_processing_config": { + "description": "Image processing configuration", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ImageProcessingConfig" + } + ] + }, + "is_processing": { + "description": "IsProcessing indicates if there is a processing import task (for FAQ type knowledge bases)", + "type": "boolean" + }, + "is_temporary": { + "description": "Whether this knowledge base is temporary (ephemeral) and should be hidden from UI", + "type": "boolean" + }, + "knowledge_count": { + "description": "Knowledge count (not stored in database, calculated on query)", + "type": "integer" + }, + "name": { + "description": "Name of the knowledge base", + "type": "string" + }, + "processing_count": { + "description": "ProcessingCount indicates the number of knowledge items being processed (for document type knowledge bases)", + "type": "integer" + }, + "question_generation_config": { + "description": "QuestionGenerationConfig stores question generation configuration for document knowledge bases", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.QuestionGenerationConfig" + } + ] + }, + "summary_model_id": { + "description": "Summary model ID", + "type": "string" + }, + "tenant_id": { + "description": "Tenant ID", + "type": "integer" + }, + "type": { + "description": "Type of the knowledge base (document, faq, etc.)", + "type": "string" + }, + "updated_at": { + "description": "Last updated time of the knowledge base", + "type": "string" + }, + "vlm_config": { + "description": "VLM config", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.VLMConfig" + } + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.KnowledgeBaseConfig": { + "type": "object", + "properties": { + "chunking_config": { + "description": "Chunking configuration", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ChunkingConfig" + } + ] + }, + "faq_config": { + "description": "FAQ configuration (only for FAQ type knowledge bases)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQConfig" + } + ] + }, + "image_processing_config": { + "description": "Image processing configuration", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ImageProcessingConfig" + } + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.LoginRequest": { + "type": "object", + "required": [ + "email", + "password" + ], + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string", + "minLength": 6 + } + } + }, + "github_com_Tencent_WeKnora_internal_types.LoginResponse": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "refresh_token": { + "type": "string" + }, + "success": { + "type": "boolean" + }, + "tenant": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant" + }, + "token": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.User" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPAdvancedConfig": { + "type": "object", + "properties": { + "retry_count": { + "description": "Number of retries, default: 3", + "type": "integer" + }, + "retry_delay": { + "description": "Delay between retries in seconds, default: 1", + "type": "integer" + }, + "timeout": { + "description": "Timeout in seconds, default: 30", + "type": "integer" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPAuthConfig": { + "type": "object", + "properties": { + "api_key": { + "type": "string" + }, + "custom_headers": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "token": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPEnvVars": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPHeaders": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPService": { + "type": "object", + "properties": { + "advanced_config": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPAdvancedConfig" + }, + "auth_config": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPAuthConfig" + }, + "created_at": { + "type": "string" + }, + "deleted_at": { + "$ref": "#/definitions/gorm.DeletedAt" + }, + "description": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "env_vars": { + "description": "Environment variables for stdio", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPEnvVars" + } + ] + }, + "headers": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPHeaders" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "stdio_config": { + "description": "Required for stdio transport", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPStdioConfig" + } + ] + }, + "tenant_id": { + "type": "integer" + }, + "transport_type": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPTransportType" + }, + "updated_at": { + "type": "string" + }, + "url": { + "description": "Optional: required for SSE/HTTP Streamable", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPStdioConfig": { + "type": "object", + "properties": { + "args": { + "description": "Command arguments array", + "type": "array", + "items": { + "type": "string" + } + }, + "command": { + "description": "Command: \"uvx\" or \"npx\"", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPTransportType": { + "type": "string", + "enum": [ + "sse", + "http-streamable", + "stdio" + ], + "x-enum-comments": { + "MCPTransportHTTPStreamable": "HTTP Streamable", + "MCPTransportSSE": "Server-Sent Events", + "MCPTransportStdio": "Stdio (Standard Input/Output)" + }, + "x-enum-descriptions": [ + "Server-Sent Events", + "HTTP Streamable", + "Stdio (Standard Input/Output)" + ], + "x-enum-varnames": [ + "MCPTransportSSE", + "MCPTransportHTTPStreamable", + "MCPTransportStdio" + ] + }, + "github_com_Tencent_WeKnora_internal_types.ManualKnowledgePayload": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "status": { + "type": "string" + }, + "title": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MatchType": { + "type": "integer", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7 + ], + "x-enum-comments": { + "MatchTypeParentChunk": "父Chunk匹配类型", + "MatchTypeRelationChunk": "关系Chunk匹配类型", + "MatchTypeWebSearch": "网络搜索匹配类型" + }, + "x-enum-descriptions": [ + "", + "", + "", + "", + "父Chunk匹配类型", + "关系Chunk匹配类型", + "", + "网络搜索匹配类型" + ], + "x-enum-varnames": [ + "MatchTypeEmbedding", + "MatchTypeKeywords", + "MatchTypeNearByChunk", + "MatchTypeHistory", + "MatchTypeParentChunk", + "MatchTypeRelationChunk", + "MatchTypeGraph", + "MatchTypeWebSearch" + ] + }, + "github_com_Tencent_WeKnora_internal_types.Message": { + "type": "object", + "properties": { + "agent_steps": { + "description": "Agent execution steps (only for assistant messages generated by agent)\nThis contains the detailed reasoning process and tool calls made by the agent\nStored for user history display, but NOT included in LLM context to avoid redundancy", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.AgentStep" + } + }, + "content": { + "description": "Message text content", + "type": "string" + }, + "created_at": { + "description": "Message creation timestamp", + "type": "string" + }, + "deleted_at": { + "description": "Soft delete timestamp", + "allOf": [ + { + "$ref": "#/definitions/gorm.DeletedAt" + } + ] + }, + "id": { + "description": "Unique identifier for the message", + "type": "string" + }, + "is_completed": { + "description": "Whether message generation is complete", + "type": "boolean" + }, + "knowledge_references": { + "description": "References to knowledge chunks used in the response", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SearchResult" + } + }, + "request_id": { + "description": "Request identifier for tracking API requests", + "type": "string" + }, + "role": { + "description": "Message role: \"user\", \"assistant\", \"system\"", + "type": "string" + }, + "session_id": { + "description": "ID of the session this message belongs to", + "type": "string" + }, + "updated_at": { + "description": "Last update timestamp", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ModelParameters": { + "type": "object", + "properties": { + "api_key": { + "type": "string" + }, + "base_url": { + "type": "string" + }, + "embedding_parameters": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.EmbeddingParameters" + }, + "interface_type": { + "type": "string" + }, + "parameter_size": { + "description": "Ollama model parameter size (e.g., \"7B\", \"13B\", \"70B\")", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ModelSource": { + "type": "string", + "enum": [ + "local", + "remote", + "aliyun" + ], + "x-enum-comments": { + "ModelSourceAliyun": "Aliyun DashScope model", + "ModelSourceLocal": "Local model", + "ModelSourceRemote": "Remote model" + }, + "x-enum-descriptions": [ + "Local model", + "Remote model", + "Aliyun DashScope model" + ], + "x-enum-varnames": [ + "ModelSourceLocal", + "ModelSourceRemote", + "ModelSourceAliyun" + ] + }, + "github_com_Tencent_WeKnora_internal_types.ModelType": { + "type": "string", + "enum": [ + "Embedding", + "Rerank", + "KnowledgeQA", + "VLLM" + ], + "x-enum-comments": { + "ModelTypeEmbedding": "Embedding model", + "ModelTypeKnowledgeQA": "KnowledgeQA model", + "ModelTypeRerank": "Rerank model", + "ModelTypeVLLM": "VLLM model" + }, + "x-enum-descriptions": [ + "Embedding model", + "Rerank model", + "KnowledgeQA model", + "VLLM model" + ], + "x-enum-varnames": [ + "ModelTypeEmbedding", + "ModelTypeRerank", + "ModelTypeKnowledgeQA", + "ModelTypeVLLM" + ] + }, + "github_com_Tencent_WeKnora_internal_types.QuestionGenerationConfig": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "question_count": { + "description": "Number of questions to generate per chunk (default: 3, max: 10)", + "type": "integer" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.RegisterRequest": { + "type": "object", + "required": [ + "email", + "password", + "username" + ], + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string", + "minLength": 6 + }, + "username": { + "type": "string", + "maxLength": 50, + "minLength": 3 + } + } + }, + "github_com_Tencent_WeKnora_internal_types.RegisterResponse": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "success": { + "type": "boolean" + }, + "tenant": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant" + }, + "user": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.User" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.RetrieverEngineParams": { + "type": "object", + "properties": { + "retriever_engine_type": { + "description": "Retriever engine type", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverEngineType" + } + ] + }, + "retriever_type": { + "description": "Retriever type", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverType" + } + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.RetrieverEngineType": { + "type": "string", + "enum": [ + "postgres", + "elasticsearch", + "infinity", + "elasticfaiss", + "qdrant" + ], + "x-enum-varnames": [ + "PostgresRetrieverEngineType", + "ElasticsearchRetrieverEngineType", + "InfinityRetrieverEngineType", + "ElasticFaissRetrieverEngineType", + "QdrantRetrieverEngineType" + ] + }, + "github_com_Tencent_WeKnora_internal_types.RetrieverEngines": { + "type": "object", + "properties": { + "engines": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverEngineParams" + } + } + } + }, + "github_com_Tencent_WeKnora_internal_types.RetrieverType": { + "type": "string", + "enum": [ + "keywords", + "vector", + "websearch" + ], + "x-enum-comments": { + "KeywordsRetrieverType": "Keywords retriever", + "VectorRetrieverType": "Vector retriever", + "WebSearchRetrieverType": "Web search retriever" + }, + "x-enum-descriptions": [ + "Keywords retriever", + "Vector retriever", + "Web search retriever" + ], + "x-enum-varnames": [ + "KeywordsRetrieverType", + "VectorRetrieverType", + "WebSearchRetrieverType" + ] + }, + "github_com_Tencent_WeKnora_internal_types.SearchParams": { + "type": "object", + "properties": { + "disable_keywords_match": { + "type": "boolean" + }, + "disable_vector_match": { + "type": "boolean" + }, + "keyword_threshold": { + "type": "number" + }, + "match_count": { + "type": "integer" + }, + "query_text": { + "type": "string" + }, + "vector_threshold": { + "type": "number" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.SearchResult": { + "type": "object", + "properties": { + "chunk_index": { + "description": "Chunk index", + "type": "integer" + }, + "chunk_metadata": { + "description": "ChunkMetadata stores chunk-level metadata (e.g., generated questions)", + "type": "array", + "items": { + "type": "integer" + } + }, + "chunk_type": { + "description": "Chunk 类型", + "type": "string" + }, + "content": { + "description": "Content", + "type": "string" + }, + "end_at": { + "description": "End at", + "type": "integer" + }, + "id": { + "description": "ID", + "type": "string" + }, + "image_info": { + "description": "图片信息 (JSON 格式)", + "type": "string" + }, + "knowledge_filename": { + "description": "Knowledge file name\nUsed for file type knowledge, contains the original file name", + "type": "string" + }, + "knowledge_id": { + "description": "Knowledge ID", + "type": "string" + }, + "knowledge_source": { + "description": "Knowledge source\nUsed to indicate the source of the knowledge, such as \"url\"", + "type": "string" + }, + "knowledge_title": { + "description": "Knowledge title", + "type": "string" + }, + "match_type": { + "description": "Match type", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MatchType" + } + ] + }, + "metadata": { + "description": "Metadata", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "parent_chunk_id": { + "description": "父 Chunk ID", + "type": "string" + }, + "score": { + "description": "Score", + "type": "number" + }, + "seq": { + "description": "Seq", + "type": "integer" + }, + "start_at": { + "description": "Start at", + "type": "integer" + }, + "sub_chunk_id": { + "description": "SubChunkIndex", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "github_com_Tencent_WeKnora_internal_types.Session": { + "type": "object", + "properties": { + "agent_config": { + "description": "Agent 配置(会话级别,仅存储enabled和knowledge_bases)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SessionAgentConfig" + } + ] + }, + "context_config": { + "description": "上下文管理配置(可选)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ContextConfig" + } + ] + }, + "created_at": { + "type": "string" + }, + "deleted_at": { + "$ref": "#/definitions/gorm.DeletedAt" + }, + "description": { + "description": "Description", + "type": "string" + }, + "embedding_top_k": { + "description": "向量召回TopK", + "type": "integer" + }, + "enable_rewrite": { + "description": "多轮改写开关", + "type": "boolean" + }, + "fallback_response": { + "description": "固定回复内容", + "type": "string" + }, + "fallback_strategy": { + "description": "兜底策略", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FallbackStrategy" + } + ] + }, + "id": { + "description": "ID", + "type": "string" + }, + "keyword_threshold": { + "description": "关键词召回阈值", + "type": "number" + }, + "knowledge_base_id": { + "description": "Strategy configuration", + "type": "string" + }, + "max_rounds": { + "description": "多轮保持轮数", + "type": "integer" + }, + "rerank_model_id": { + "description": "排序模型ID", + "type": "string" + }, + "rerank_threshold": { + "description": "排序阈值", + "type": "number" + }, + "rerank_top_k": { + "description": "排序TopK", + "type": "integer" + }, + "summary_model_id": { + "description": "总结模型ID", + "type": "string" + }, + "summary_parameters": { + "description": "总结模型参数", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SummaryConfig" + } + ] + }, + "tenant_id": { + "description": "Tenant ID", + "type": "integer" + }, + "title": { + "description": "Title", + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "vector_threshold": { + "description": "向量召回阈值", + "type": "number" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.SessionAgentConfig": { + "type": "object", + "properties": { + "agent_mode_enabled": { + "description": "Whether agent mode is enabled for this session", + "type": "boolean" + }, + "knowledge_bases": { + "description": "Accessible knowledge base IDs for this session", + "type": "array", + "items": { + "type": "string" + } + }, + "web_search_enabled": { + "description": "Whether web search is enabled for this session", + "type": "boolean" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.StorageConfig": { + "type": "object", + "properties": { + "app_id": { + "description": "App ID", + "type": "string" + }, + "bucket_name": { + "description": "Bucket Name", + "type": "string" + }, + "path_prefix": { + "description": "Path Prefix", + "type": "string" + }, + "provider": { + "description": "Provider", + "type": "string" + }, + "region": { + "description": "Region", + "type": "string" + }, + "secret_id": { + "description": "Secret ID", + "type": "string" + }, + "secret_key": { + "description": "Secret Key", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.SummaryConfig": { + "type": "object", + "properties": { + "context_template": { + "description": "Context template", + "type": "string" + }, + "frequency_penalty": { + "description": "Frequency penalty", + "type": "number" + }, + "max_completion_tokens": { + "description": "Max completion tokens", + "type": "integer" + }, + "max_tokens": { + "description": "Max tokens", + "type": "integer" + }, + "no_match_prefix": { + "description": "No match prefix", + "type": "string" + }, + "presence_penalty": { + "description": "Presence penalty", + "type": "number" + }, + "prompt": { + "description": "Prompt", + "type": "string" + }, + "repeat_penalty": { + "description": "Repeat penalty", + "type": "number" + }, + "seed": { + "description": "Seed", + "type": "integer" + }, + "temperature": { + "description": "Temperature", + "type": "number" + }, + "top_k": { + "description": "TopK", + "type": "integer" + }, + "top_p": { + "description": "TopP", + "type": "number" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.Tenant": { + "type": "object", + "properties": { + "agent_config": { + "description": "Global Agent configuration for this tenant (default for all sessions)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.AgentConfig" + } + ] + }, + "api_key": { + "description": "API key", + "type": "string" + }, + "business": { + "description": "Business", + "type": "string" + }, + "context_config": { + "description": "Global Context configuration for this tenant (default for all sessions)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ContextConfig" + } + ] + }, + "conversation_config": { + "description": "Global Conversation configuration for this tenant (default for normal mode sessions)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ConversationConfig" + } + ] + }, + "created_at": { + "description": "Creation time", + "type": "string" + }, + "deleted_at": { + "description": "Deletion time", + "allOf": [ + { + "$ref": "#/definitions/gorm.DeletedAt" + } + ] + }, + "description": { + "description": "Description", + "type": "string" + }, + "id": { + "description": "ID", + "type": "integer" + }, + "name": { + "description": "Name", + "type": "string" + }, + "retriever_engines": { + "description": "Retriever engines", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverEngines" + } + ] + }, + "status": { + "description": "Status", + "type": "string" + }, + "storage_quota": { + "description": "Storage quota (Bytes), default is 10GB, including vector, original file, text, index, etc.", + "type": "integer" + }, + "storage_used": { + "description": "Storage used (Bytes)", + "type": "integer" + }, + "updated_at": { + "description": "Last updated time", + "type": "string" + }, + "web_search_config": { + "description": "Global WebSearch configuration for this tenant", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.WebSearchConfig" + } + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ToolCall": { + "type": "object", + "properties": { + "args": { + "description": "Tool arguments", + "type": "object", + "additionalProperties": true + }, + "duration": { + "description": "Execution time in milliseconds", + "type": "integer" + }, + "id": { + "description": "Function call ID from LLM", + "type": "string" + }, + "name": { + "description": "Tool name", + "type": "string" + }, + "reflection": { + "description": "Agent's reflection on this tool call result (if enabled)", + "type": "string" + }, + "result": { + "description": "Execution result (contains Output)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ToolResult" + } + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ToolResult": { + "type": "object", + "properties": { + "data": { + "description": "Structured data for programmatic use", + "type": "object", + "additionalProperties": true + }, + "error": { + "description": "Error message if execution failed", + "type": "string" + }, + "output": { + "description": "Human-readable output", + "type": "string" + }, + "success": { + "description": "Whether the tool executed successfully", + "type": "boolean" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.User": { + "type": "object", + "properties": { + "avatar": { + "description": "Avatar URL of the user", + "type": "string" + }, + "can_access_all_tenants": { + "description": "Whether the user can access all tenants (cross-tenant access)", + "type": "boolean" + }, + "created_at": { + "description": "Creation time of the user", + "type": "string" + }, + "deleted_at": { + "description": "Deletion time of the user", + "allOf": [ + { + "$ref": "#/definitions/gorm.DeletedAt" + } + ] + }, + "email": { + "description": "Email address of the user", + "type": "string" + }, + "id": { + "description": "Unique identifier of the user", + "type": "string" + }, + "is_active": { + "description": "Whether the user is active", + "type": "boolean" + }, + "tenant": { + "description": "Association relationship, not stored in the database", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant" + } + ] + }, + "tenant_id": { + "description": "Tenant ID that the user belongs to", + "type": "integer" + }, + "updated_at": { + "description": "Last updated time of the user", + "type": "string" + }, + "username": { + "description": "Username of the user", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.VLMConfig": { + "type": "object", + "properties": { + "api_key": { + "description": "API Key", + "type": "string" + }, + "base_url": { + "description": "Base URL", + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "interface_type": { + "description": "Interface Type: \"ollama\" or \"openai\"", + "type": "string" + }, + "model_id": { + "type": "string" + }, + "model_name": { + "description": "兼容老版本\nModel Name", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.WebSearchConfig": { + "type": "object", + "properties": { + "api_key": { + "description": "API密钥(如果需要)", + "type": "string" + }, + "blacklist": { + "description": "黑名单规则列表", + "type": "array", + "items": { + "type": "string" + } + }, + "compression_method": { + "description": "压缩方法:none, summary, extract, rag", + "type": "string" + }, + "document_fragments": { + "description": "文档片段数量(用于RAG压缩)", + "type": "integer" + }, + "embedding_dimension": { + "description": "嵌入维度(用于RAG压缩)", + "type": "integer" + }, + "embedding_model_id": { + "description": "RAG压缩相关配置", + "type": "string" + }, + "include_date": { + "description": "是否包含日期", + "type": "boolean" + }, + "max_results": { + "description": "最大搜索结果数", + "type": "integer" + }, + "provider": { + "description": "搜索引擎提供商ID", + "type": "string" + }, + "rerank_model_id": { + "description": "重排模型ID(用于RAG压缩)", + "type": "string" + } + } + }, + "gorm.DeletedAt": { + "type": "object", + "properties": { + "time": { + "type": "string" + }, + "valid": { + "description": "Valid is true if Time is not NULL", + "type": "boolean" + } + } + }, + "internal_handler.CopyKnowledgeBaseRequest": { + "type": "object", + "required": [ + "source_id" + ], + "properties": { + "source_id": { + "type": "string" + }, + "target_id": { + "type": "string" + } + } + }, + "internal_handler.CreateModelRequest": { + "type": "object", + "required": [ + "name", + "parameters", + "source", + "type" + ], + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parameters": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelParameters" + }, + "source": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelSource" + }, + "type": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelType" + } + } + }, + "internal_handler.EvaluationRequest": { + "type": "object", + "properties": { + "chat_id": { + "description": "ID of chat model to use", + "type": "string" + }, + "dataset_id": { + "description": "ID of dataset to evaluate", + "type": "string" + }, + "knowledge_base_id": { + "description": "ID of knowledge base to use", + "type": "string" + }, + "rerank_id": { + "description": "ID of rerank model to use", + "type": "string" + } + } + }, + "internal_handler.FabriTextRequest": { + "type": "object", + "properties": { + "llm_config": { + "$ref": "#/definitions/internal_handler.LLMConfig" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "internal_handler.GetSystemInfoResponse": { + "type": "object", + "properties": { + "build_time": { + "type": "string" + }, + "commit_id": { + "type": "string" + }, + "go_version": { + "type": "string" + }, + "graph_database_engine": { + "type": "string" + }, + "keyword_index_engine": { + "type": "string" + }, + "minio_enabled": { + "type": "boolean" + }, + "vector_store_engine": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "internal_handler.KBModelConfigRequest": { + "type": "object", + "required": [ + "embeddingModelId", + "llmModelId" + ], + "properties": { + "documentSplitting": { + "description": "文档分块配置", + "type": "object", + "properties": { + "chunkOverlap": { + "type": "integer" + }, + "chunkSize": { + "type": "integer" + }, + "separators": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "embeddingModelId": { + "type": "string" + }, + "llmModelId": { + "type": "string" + }, + "multimodal": { + "description": "多模态配置", + "type": "object", + "properties": { + "cos": { + "type": "object", + "properties": { + "appId": { + "type": "string" + }, + "bucketName": { + "type": "string" + }, + "pathPrefix": { + "type": "string" + }, + "region": { + "type": "string" + }, + "secretId": { + "type": "string" + }, + "secretKey": { + "type": "string" + } + } + }, + "enabled": { + "type": "boolean" + }, + "minio": { + "type": "object", + "properties": { + "bucketName": { + "type": "string" + }, + "pathPrefix": { + "type": "string" + }, + "useSSL": { + "type": "boolean" + } + } + }, + "storageType": { + "description": "\"cos\" or \"minio\"", + "type": "string" + } + } + }, + "nodeExtract": { + "description": "知识图谱配置", + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.GraphNode" + } + }, + "relations": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.GraphRelation" + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "text": { + "type": "string" + } + } + }, + "questionGeneration": { + "description": "问题生成配置", + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "questionCount": { + "type": "integer" + } + } + }, + "vlm_config": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.VLMConfig" + } + } + }, + "internal_handler.LLMConfig": { + "type": "object", + "properties": { + "api_key": { + "type": "string" + }, + "base_url": { + "type": "string" + }, + "model_name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + }, + "internal_handler.RemoteModelCheckRequest": { + "type": "object", + "required": [ + "baseUrl", + "modelName" + ], + "properties": { + "apiKey": { + "type": "string" + }, + "baseUrl": { + "type": "string" + }, + "modelName": { + "type": "string" + } + } + }, + "internal_handler.TextRelationExtractionRequest": { + "type": "object", + "required": [ + "tags", + "text" + ], + "properties": { + "llm_config": { + "$ref": "#/definitions/internal_handler.LLMConfig" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "text": { + "type": "string" + } + } + }, + "internal_handler.UpdateChunkRequest": { + "type": "object", + "properties": { + "chunk_index": { + "type": "integer" + }, + "content": { + "type": "string" + }, + "embedding": { + "type": "array", + "items": { + "type": "number" + } + }, + "end_at": { + "type": "integer" + }, + "image_info": { + "type": "string" + }, + "is_enabled": { + "type": "boolean" + }, + "start_at": { + "type": "integer" + } + } + }, + "internal_handler.UpdateKnowledgeBaseRequest": { + "type": "object", + "required": [ + "config", + "name" + ], + "properties": { + "config": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.KnowledgeBaseConfig" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "internal_handler.UpdateModelRequest": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parameters": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelParameters" + }, + "source": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelSource" + }, + "type": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelType" + } + } + }, + "internal_handler_session.CreateKnowledgeQARequest": { + "type": "object", + "required": [ + "query" + ], + "properties": { + "agent_enabled": { + "description": "Whether agent mode is enabled for this request", + "type": "boolean" + }, + "knowledge_base_ids": { + "description": "Selected knowledge base ID for this request", + "type": "array", + "items": { + "type": "string" + } + }, + "query": { + "description": "Query text for knowledge base search", + "type": "string" + }, + "summary_model_id": { + "description": "Optional summary model ID for this request (overrides session default)", + "type": "string" + }, + "web_search_enabled": { + "description": "Whether web search is enabled for this request", + "type": "boolean" + } + } + }, + "internal_handler_session.CreateSessionRequest": { + "type": "object", + "properties": { + "agent_config": { + "description": "Agent configuration (optional, session-level config only: enabled and knowledge_bases)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SessionAgentConfig" + } + ] + }, + "knowledge_base_id": { + "description": "ID of the associated knowledge base (optional, can be set/changed during queries)", + "type": "string" + }, + "session_strategy": { + "description": "Session strategy configuration", + "allOf": [ + { + "$ref": "#/definitions/internal_handler_session.SessionStrategy" + } + ] + } + } + }, + "internal_handler_session.GenerateTitleRequest": { + "type": "object", + "required": [ + "messages" + ], + "properties": { + "messages": { + "description": "Messages to use as context for title generation", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Message" + } + } + } + }, + "internal_handler_session.SearchKnowledgeRequest": { + "type": "object", + "required": [ + "knowledge_base_id", + "query" + ], + "properties": { + "knowledge_base_id": { + "description": "ID of the knowledge base to search", + "type": "string" + }, + "query": { + "description": "Query text to search for", + "type": "string" + } + } + }, + "internal_handler_session.SessionStrategy": { + "type": "object", + "properties": { + "embedding_top_k": { + "description": "Number of top results to retrieve from vector search", + "type": "integer" + }, + "enable_rewrite": { + "description": "Whether to enable query rewrite for multi-round conversations", + "type": "boolean" + }, + "fallback_response": { + "description": "Fixed response content for fallback", + "type": "string" + }, + "fallback_strategy": { + "description": "Strategy to use when no relevant knowledge is found", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FallbackStrategy" + } + ] + }, + "keyword_threshold": { + "description": "Threshold for keyword-based retrieval", + "type": "number" + }, + "max_rounds": { + "description": "Maximum number of conversation rounds to maintain", + "type": "integer" + }, + "no_match_prefix": { + "description": "Prefix for responses when no match is found", + "type": "string" + }, + "rerank_model_id": { + "description": "ID of the model used for reranking results", + "type": "string" + }, + "rerank_threshold": { + "description": "Threshold for reranking results", + "type": "number" + }, + "rerank_top_k": { + "description": "Number of top results after reranking", + "type": "integer" + }, + "summary_model_id": { + "description": "ID of the model used for summarization", + "type": "string" + }, + "summary_parameters": { + "description": "Parameters for the summary model", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SummaryConfig" + } + ] + }, + "vector_threshold": { + "description": "Threshold for vector-based retrieval", + "type": "number" + } + } + }, + "internal_handler_session.StopSessionRequest": { + "type": "object", + "required": [ + "message_id" + ], + "properties": { + "message_id": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "Bearer": { + "description": "输入 Bearer {token} 格式的 JWT 令牌", + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "localhost:8080", + BasePath: "/api/v1", + Schemes: []string{}, + Title: "WeKnora API", + Description: "WeKnora 知识库管理系统 API 文档", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 00000000..6c7a25a9 --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,7384 @@ +{ + "swagger": "2.0", + "info": { + "description": "WeKnora 知识库管理系统 API 文档", + "title": "WeKnora API", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "WeKnora Github", + "url": "https://github.com/Tencent/WeKnora" + }, + "version": "1.0" + }, + "host": "localhost:8080", + "basePath": "/api/v1", + "paths": { + "/api/v1/web-search/providers": { + "get": { + "description": "Returns the list of available web search providers from configuration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "web-search" + ], + "summary": "Get available web search providers", + "responses": { + "200": { + "description": "List of providers", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/auth/change-password": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "修改当前用户的登录密码", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "修改密码", + "parameters": [ + { + "description": "密码修改请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "new_password": { + "type": "string" + }, + "old_password": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "修改成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/login": { + "post": { + "description": "用户登录并获取访问令牌", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "用户登录", + "parameters": [ + { + "description": "登录请求参数", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.LoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.LoginResponse" + } + }, + "401": { + "description": "认证失败", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/logout": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "撤销当前访问令牌并登出", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "用户登出", + "responses": { + "200": { + "description": "登出成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/me": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前登录用户的详细信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "获取当前用户信息", + "responses": { + "200": { + "description": "用户信息", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "未授权", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/refresh": { + "post": { + "description": "使用刷新令牌获取新的访问令牌", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "刷新令牌", + "parameters": [ + { + "description": "刷新令牌", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "refreshToken": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "新令牌", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "令牌无效", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/register": { + "post": { + "description": "注册新用户账号", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "用户注册", + "parameters": [ + { + "description": "注册请求参数", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RegisterRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RegisterResponse" + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/auth/validate": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "验证访问令牌是否有效", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "认证" + ], + "summary": "验证令牌", + "responses": { + "200": { + "description": "令牌有效", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "401": { + "description": "令牌无效", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/chunks/by-id/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "仅通过分块ID获取分块详情(不需要knowledge_id)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "通过ID获取分块", + "parameters": [ + { + "type": "string", + "description": "分块ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "分块详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "分块不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/chunks/by-id/{id}/questions": { + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除分块中生成的问题", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "删除生成的问题", + "parameters": [ + { + "type": "string", + "description": "分块ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "问题ID", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "question_id": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "分块不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/chunks/{knowledge_id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取指定知识下的所有分块列表,支持分页", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "获取知识分块列表", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "knowledge_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 1, + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "default": 10, + "description": "每页数量", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "分块列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定知识下的所有分块", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "删除知识下所有分块", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "knowledge_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/chunks/{knowledge_id}/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新指定分块的内容和属性", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "更新分块", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "knowledge_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "分块ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.UpdateChunkRequest" + } + } + ], + "responses": { + "200": { + "description": "更新后的分块", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "分块不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的分块", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "分块管理" + ], + "summary": "删除分块", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "knowledge_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "分块ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "分块不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/evaluation/": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据任务ID获取评估结果", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "评估" + ], + "summary": "获取评估结果", + "parameters": [ + { + "type": "string", + "description": "评估任务ID", + "name": "task_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "评估结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "对知识库进行评估测试", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "评估" + ], + "summary": "执行评估", + "parameters": [ + { + "description": "评估请求参数", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.EvaluationRequest" + } + } + ], + "responses": { + "200": { + "description": "评估任务", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/extract/relations": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "从文本中提取实体和关系", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "提取文本关系", + "parameters": [ + { + "description": "提取请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.TextRelationExtractionRequest" + } + } + ], + "responses": { + "200": { + "description": "提取结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/fabri/tag": { + "get": { + "description": "随机生成一组标签", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "生成随机标签", + "responses": { + "200": { + "description": "生成的标签", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/initialization/fabri/text": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据标签生成示例文本", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "生成示例文本", + "parameters": [ + { + "description": "生成请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.FabriTextRequest" + } + } + ], + "responses": { + "200": { + "description": "生成的文本", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/kb/{kbId}": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据知识库ID执行完整配置更新", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "初始化知识库配置", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "kbId", + "in": "path", + "required": true + }, + { + "description": "初始化请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "初始化成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/kb/{kbId}/config": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据知识库ID获取当前配置信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "获取知识库配置", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "kbId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "配置信息", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "知识库不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据知识库ID更新模型和分块配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "更新知识库配置", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "kbId", + "in": "path", + "required": true + }, + { + "description": "配置请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.KBModelConfigRequest" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "知识库不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/models/embedding/test": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "测试Embedding接口是否可用并返回向量维度", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "测试Embedding模型", + "parameters": [ + { + "description": "Embedding测试请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "测试结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/models/remote/check": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "检查远程API模型连接是否正常", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "检查远程模型", + "parameters": [ + { + "description": "模型检查请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.RemoteModelCheckRequest" + } + } + ], + "responses": { + "200": { + "description": "检查结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/models/rerank/check": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "检查Rerank模型连接和功能是否正常", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "检查Rerank模型", + "parameters": [ + { + "description": "Rerank检查请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "检查结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/multimodal/test": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "上传图片测试多模态处理功能", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "测试多模态功能", + "parameters": [ + { + "type": "file", + "description": "测试图片", + "name": "image", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "VLM模型名称", + "name": "vlm_model", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "VLM Base URL", + "name": "vlm_base_url", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "VLM API Key", + "name": "vlm_api_key", + "in": "formData" + }, + { + "type": "string", + "description": "VLM接口类型", + "name": "vlm_interface_type", + "in": "formData" + }, + { + "type": "string", + "description": "存储类型(cos/minio)", + "name": "storage_type", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "测试结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/ollama/download/tasks": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "列出所有Ollama模型下载任务", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "列出下载任务", + "responses": { + "200": { + "description": "任务列表", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/initialization/ollama/download/{taskId}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取Ollama模型下载任务的进度", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "获取下载进度", + "parameters": [ + { + "type": "string", + "description": "任务ID", + "name": "taskId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "下载进度", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "任务不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/ollama/models": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "列出已安装的Ollama模型", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "列出Ollama模型", + "responses": { + "200": { + "description": "模型列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/ollama/models/check": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "检查指定的Ollama模型是否已安装", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "检查Ollama模型状态", + "parameters": [ + { + "description": "模型名称列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "models": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + ], + "responses": { + "200": { + "description": "模型状态", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/ollama/models/download": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "异步下载指定的Ollama模型", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "下载Ollama模型", + "parameters": [ + { + "description": "模型名称", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "modelName": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "下载任务信息", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/initialization/ollama/status": { + "get": { + "description": "检查Ollama服务是否可用", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "初始化" + ], + "summary": "检查Ollama服务状态", + "responses": { + "200": { + "description": "Ollama状态", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/knowledge-bases": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前租户的所有知识库", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "获取知识库列表", + "responses": { + "200": { + "description": "知识库列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "创建新的知识库", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "创建知识库", + "parameters": [ + { + "description": "知识库信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.KnowledgeBase" + } + } + ], + "responses": { + "201": { + "description": "创建的知识库", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/copy": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "将一个知识库的内容复制到另一个知识库", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "复制知识库", + "parameters": [ + { + "description": "复制请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.CopyKnowledgeBaseRequest" + } + } + ], + "responses": { + "200": { + "description": "复制成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取知识库详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "获取知识库详情", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "知识库详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "知识库不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新知识库的名称、描述和配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "更新知识库", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.UpdateKnowledgeBaseRequest" + } + } + ], + "responses": { + "200": { + "description": "更新后的知识库", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的知识库及其所有内容", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "删除知识库", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entries": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取知识库下的FAQ条目列表,支持分页和筛选", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "获取FAQ条目列表", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "标签ID筛选", + "name": "tag_id", + "in": "query" + }, + { + "type": "string", + "description": "关键词搜索", + "name": "keyword", + "in": "query" + } + ], + "responses": { + "200": { + "description": "FAQ列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "异步批量更新或插入FAQ条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "批量更新/插入FAQ条目", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "批量操作请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQBatchUpsertPayload" + } + } + ], + "responses": { + "200": { + "description": "任务ID", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "批量删除指定的FAQ条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "批量删除FAQ条目", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "要删除的FAQ ID列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "ids": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entries/export": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "将所有FAQ条目导出为CSV文件", + "consumes": [ + "application/json" + ], + "produces": [ + "text/csv" + ], + "tags": [ + "FAQ管理" + ], + "summary": "导出FAQ条目", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "CSV文件", + "schema": { + "type": "file" + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entries/fields": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "批量更新FAQ条目的多个字段(is_enabled, is_recommended, tag_id)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "批量更新FAQ字段", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "字段更新请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsBatchUpdate" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entries/tags": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "批量更新FAQ条目的标签", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "批量更新FAQ标签", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "标签更新请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entries/{entry_id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新指定的FAQ条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "更新FAQ条目", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "FAQ条目ID", + "name": "entry_id", + "in": "path", + "required": true + }, + { + "description": "FAQ条目", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryPayload" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/entry": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "同步创建单个FAQ条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "创建单个FAQ条目", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "FAQ条目", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryPayload" + } + } + ], + "responses": { + "200": { + "description": "创建的FAQ条目", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/faq/search": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "使用混合搜索在FAQ中搜索", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "FAQ管理" + ], + "summary": "搜索FAQ", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "搜索请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQSearchRequest" + } + } + ], + "responses": { + "200": { + "description": "搜索结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/hybrid-search": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "在知识库中执行向量和关键词混合搜索", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识库" + ], + "summary": "混合搜索", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "搜索参数", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SearchParams" + } + } + ], + "responses": { + "200": { + "description": "搜索结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/knowledge": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取知识库下的知识列表,支持分页和筛选", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "获取知识列表", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "标签ID筛选", + "name": "tag_id", + "in": "query" + }, + { + "type": "string", + "description": "关键词搜索", + "name": "keyword", + "in": "query" + }, + { + "type": "string", + "description": "文件类型筛选", + "name": "file_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "知识列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/knowledge/file": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "上传文件并创建知识条目", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "从文件创建知识", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "上传的文件", + "name": "file", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "自定义文件名", + "name": "fileName", + "in": "formData" + }, + { + "type": "string", + "description": "元数据JSON", + "name": "metadata", + "in": "formData" + }, + { + "type": "boolean", + "description": "启用多模态处理", + "name": "enable_multimodel", + "in": "formData" + } + ], + "responses": { + "200": { + "description": "创建的知识", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "409": { + "description": "文件重复", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/knowledge-bases/{id}/knowledge/manual": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "手工录入Markdown格式的知识内容", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "手工创建知识", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "手工知识内容", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ManualKnowledgePayload" + } + } + ], + "responses": { + "200": { + "description": "创建的知识", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/knowledge/url": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "从指定URL抓取内容并创建知识条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "从URL创建知识", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "URL请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "enable_multimodel": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "url": { + "type": "string" + } + } + } + } + ], + "responses": { + "201": { + "description": "创建的知识", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "409": { + "description": "URL重复", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } + }, + "/knowledge-bases/{id}/tags": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取知识库下的所有标签及统计信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "标签管理" + ], + "summary": "获取标签列表", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "关键词搜索", + "name": "keyword", + "in": "query" + } + ], + "responses": { + "200": { + "description": "标签列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "在知识库下创建新标签", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "标签管理" + ], + "summary": "创建标签", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "标签信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "name": { + "type": "string" + }, + "sort_order": { + "type": "integer" + } + } + } + } + ], + "responses": { + "200": { + "description": "创建的标签", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge-bases/{id}/tags/{tag_id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新标签信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "标签管理" + ], + "summary": "更新标签", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "标签ID", + "name": "tag_id", + "in": "path", + "required": true + }, + { + "description": "标签更新信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新后的标签", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除标签,可使用force=true强制删除被引用的标签", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "标签管理" + ], + "summary": "删除标签", + "parameters": [ + { + "type": "string", + "description": "知识库ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "标签ID", + "name": "tag_id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "强制删除", + "name": "force", + "in": "query" + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/batch": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID列表批量获取知识条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "批量获取知识", + "parameters": [ + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "csv", + "description": "知识ID列表", + "name": "ids", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "知识列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/image/{id}/{chunk_id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新知识分块的图像信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "更新图像信息", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "分块ID", + "name": "chunk_id", + "in": "path", + "required": true + }, + { + "description": "图像信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "image_info": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/manual/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新手工录入的Markdown知识内容", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "更新手工知识", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "手工知识内容", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ManualKnowledgePayload" + } + } + ], + "responses": { + "200": { + "description": "更新后的知识", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/tags": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "批量更新知识条目的标签", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "批量更新知识标签", + "parameters": [ + { + "description": "标签更新请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取知识条目详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "获取知识详情", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "知识详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "知识不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新知识条目信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "更新知识", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "知识信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Knowledge" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID删除知识条目", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "知识管理" + ], + "summary": "删除知识", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/knowledge/{id}/download": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "下载知识条目关联的原始文件", + "consumes": [ + "application/json" + ], + "produces": [ + "application/octet-stream" + ], + "tags": [ + "知识管理" + ], + "summary": "下载知识文件", + "parameters": [ + { + "type": "string", + "description": "知识ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "文件内容", + "schema": { + "type": "file" + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/mcp-services": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前租户的所有MCP服务", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "获取MCP服务列表", + "responses": { + "200": { + "description": "MCP服务列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "创建新的MCP服务配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "创建MCP服务", + "parameters": [ + { + "description": "MCP服务配置", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPService" + } + } + ], + "responses": { + "200": { + "description": "创建的MCP服务", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/mcp-services/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取MCP服务详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "获取MCP服务详情", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "MCP服务详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "服务不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新MCP服务配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "更新MCP服务", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新字段", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新后的MCP服务", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的MCP服务", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "删除MCP服务", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/mcp-services/{id}/resources": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取MCP服务提供的资源列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "获取MCP服务资源列表", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "资源列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/mcp-services/{id}/test": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "测试MCP服务是否可以正常连接", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "测试MCP服务连接", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "测试结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/mcp-services/{id}/tools": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取MCP服务提供的工具列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "MCP服务" + ], + "summary": "获取MCP服务工具列表", + "parameters": [ + { + "type": "string", + "description": "MCP服务ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "工具列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/messages/{session_id}/load": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "加载会话的消息历史,支持分页和时间筛选", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息" + ], + "summary": "加载消息历史", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "返回数量", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "description": "在此时间之前的消息(RFC3339Nano格式)", + "name": "before_time", + "in": "query" + } + ], + "responses": { + "200": { + "description": "消息列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/messages/{session_id}/{id}": { + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "从会话中删除指定消息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "消息" + ], + "summary": "删除消息", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "消息ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/models": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前租户的所有模型", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "模型管理" + ], + "summary": "获取模型列表", + "responses": { + "200": { + "description": "模型列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "创建新的模型配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "模型管理" + ], + "summary": "创建模型", + "parameters": [ + { + "description": "模型信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.CreateModelRequest" + } + } + ], + "responses": { + "201": { + "description": "创建的模型", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/models/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取模型详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "模型管理" + ], + "summary": "获取模型详情", + "parameters": [ + { + "type": "string", + "description": "模型ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "模型详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "模型不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新模型配置信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "模型管理" + ], + "summary": "更新模型", + "parameters": [ + { + "type": "string", + "description": "模型ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler.UpdateModelRequest" + } + } + ], + "responses": { + "200": { + "description": "更新后的模型", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "模型不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的模型", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "模型管理" + ], + "summary": "删除模型", + "parameters": [ + { + "type": "string", + "description": "模型ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "模型不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前租户的会话列表,支持分页", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "获取会话列表", + "parameters": [ + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "会话列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "创建新的对话会话", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "创建会话", + "parameters": [ + { + "description": "会话创建请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.CreateSessionRequest" + } + } + ], + "responses": { + "201": { + "description": "创建的会话", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/search": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "在知识库中搜索(不使用LLM总结)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "问答" + ], + "summary": "知识搜索", + "parameters": [ + { + "description": "搜索请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.SearchKnowledgeRequest" + } + } + ], + "responses": { + "200": { + "description": "搜索结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取会话详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "获取会话详情", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "会话详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "会话不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新会话属性", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "更新会话", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "会话信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Session" + } + } + ], + "responses": { + "200": { + "description": "更新后的会话", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "会话不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的会话", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "删除会话", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "会话不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{session_id}/agent-qa": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "基于Agent的智能问答,支持多轮对话和SSE流式响应", + "consumes": [ + "application/json" + ], + "produces": [ + "text/event-stream" + ], + "tags": [ + "问答" + ], + "summary": "Agent问答", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "description": "问答请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.CreateKnowledgeQARequest" + } + } + ], + "responses": { + "200": { + "description": "问答结果(SSE流)", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{session_id}/continue": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "继续获取正在进行的流式响应", + "consumes": [ + "application/json" + ], + "produces": [ + "text/event-stream" + ], + "tags": [ + "问答" + ], + "summary": "继续流式响应", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "消息ID", + "name": "message_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "流式响应", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "会话或消息不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{session_id}/knowledge-qa": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "基于知识库的问答(使用LLM总结),支持SSE流式响应", + "consumes": [ + "application/json" + ], + "produces": [ + "text/event-stream" + ], + "tags": [ + "问答" + ], + "summary": "知识问答", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "description": "问答请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.CreateKnowledgeQARequest" + } + } + ], + "responses": { + "200": { + "description": "问答结果(SSE流)", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{session_id}/stop": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "停止当前正在进行的生成任务", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "问答" + ], + "summary": "停止生成", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "description": "停止请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.StopSessionRequest" + } + } + ], + "responses": { + "200": { + "description": "停止成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "会话或消息不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/sessions/{session_id}/title": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据消息内容自动生成会话标题", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "会话" + ], + "summary": "生成会话标题", + "parameters": [ + { + "type": "string", + "description": "会话ID", + "name": "session_id", + "in": "path", + "required": true + }, + { + "description": "生成请求", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_handler_session.GenerateTitleRequest" + } + } + ], + "responses": { + "200": { + "description": "生成的标题", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/system/info": { + "get": { + "description": "获取系统版本、构建信息和引擎配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "系统" + ], + "summary": "获取系统信息", + "responses": { + "200": { + "description": "系统信息", + "schema": { + "$ref": "#/definitions/internal_handler.GetSystemInfoResponse" + } + } + } + } + }, + "/tenants": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取当前用户可访问的租户列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户列表", + "responses": { + "200": { + "description": "租户列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "500": { + "description": "服务器错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "创建新的租户", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "创建租户", + "parameters": [ + { + "description": "租户信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant" + } + } + ], + "responses": { + "201": { + "description": "创建的租户", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/all": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取系统中所有租户(需要跨租户访问权限)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取所有租户列表", + "responses": { + "200": { + "description": "所有租户列表", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "403": { + "description": "权限不足", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/kv/agent-config": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取租户的全局Agent配置(默认应用于所有会话)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户Agent配置", + "responses": { + "200": { + "description": "Agent配置", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/kv/conversation-config": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取租户的全局对话配置(默认应用于普通模式会话)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户对话配置", + "responses": { + "200": { + "description": "对话配置", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/kv/web-search-config": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取租户的网络搜索配置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户网络搜索配置", + "responses": { + "200": { + "description": "网络搜索配置", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/kv/{key}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "获取租户级别的KV配置(支持agent-config、web-search-config、conversation-config)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户KV配置", + "parameters": [ + { + "type": "string", + "description": "配置键名", + "name": "key", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "配置值", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "不支持的键", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新租户级别的KV配置(支持agent-config、web-search-config、conversation-config)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "更新租户KV配置", + "parameters": [ + { + "type": "string", + "description": "配置键名", + "name": "key", + "in": "path", + "required": true + }, + { + "description": "配置值", + "name": "request", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "不支持的键", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/search": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "分页搜索租户(需要跨租户访问权限)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "搜索租户", + "parameters": [ + { + "type": "string", + "description": "搜索关键词", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "description": "租户ID筛选", + "name": "tenant_id", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "每页数量", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "搜索结果", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "403": { + "description": "权限不足", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + }, + "/tenants/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "根据ID获取租户详情", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "获取租户详情", + "parameters": [ + { + "type": "integer", + "description": "租户ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "租户详情", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + }, + "404": { + "description": "租户不存在", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "更新租户信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "更新租户", + "parameters": [ + { + "type": "integer", + "description": "租户ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "租户信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant" + } + } + ], + "responses": { + "200": { + "description": "更新后的租户", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "删除指定的租户", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "租户管理" + ], + "summary": "删除租户", + "parameters": [ + { + "type": "integer", + "description": "租户ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "400": { + "description": "请求参数错误", + "schema": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError" + } + } + } + } + } + }, + "definitions": { + "github_com_Tencent_WeKnora_internal_errors.AppError": { + "type": "object", + "properties": { + "code": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_errors.ErrorCode" + }, + "details": {}, + "message": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_errors.ErrorCode": { + "type": "integer", + "enum": [ + 1000, + 1001, + 1002, + 1003, + 1004, + 1005, + 1006, + 1007, + 1008, + 1009, + 1010, + 2000, + 2001, + 2002, + 2003, + 2004, + 2100, + 2101, + 2102, + 2103 + ], + "x-enum-varnames": [ + "ErrBadRequest", + "ErrUnauthorized", + "ErrForbidden", + "ErrNotFound", + "ErrMethodNotAllowed", + "ErrConflict", + "ErrTooManyRequests", + "ErrInternalServer", + "ErrServiceUnavailable", + "ErrTimeout", + "ErrValidation", + "ErrTenantNotFound", + "ErrTenantAlreadyExists", + "ErrTenantInactive", + "ErrTenantNameRequired", + "ErrTenantInvalidStatus", + "ErrAgentMissingThinkingModel", + "ErrAgentMissingAllowedTools", + "ErrAgentInvalidMaxIterations", + "ErrAgentInvalidTemperature" + ] + }, + "github_com_Tencent_WeKnora_internal_types.AgentConfig": { + "type": "object", + "properties": { + "allowed_tools": { + "description": "List of allowed tool names", + "type": "array", + "items": { + "type": "string" + } + }, + "knowledge_bases": { + "description": "Accessible knowledge base IDs", + "type": "array", + "items": { + "type": "string" + } + }, + "max_iterations": { + "description": "Maximum number of ReAct iterations", + "type": "integer" + }, + "reflection_enabled": { + "description": "Whether to enable reflection", + "type": "boolean" + }, + "system_prompt_web_disabled": { + "description": "Custom prompt when web search is disabled", + "type": "string" + }, + "system_prompt_web_enabled": { + "description": "Custom prompt when web search is enabled", + "type": "string" + }, + "temperature": { + "description": "LLM temperature for agent", + "type": "number" + }, + "use_custom_system_prompt": { + "description": "Whether to use custom system prompt instead of default", + "type": "boolean" + }, + "web_search_enabled": { + "description": "Whether web search tool is enabled", + "type": "boolean" + }, + "web_search_max_results": { + "description": "Maximum number of web search results (default: 5)", + "type": "integer" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.AgentStep": { + "type": "object", + "properties": { + "iteration": { + "description": "Iteration number (0-indexed)", + "type": "integer" + }, + "thought": { + "description": "LLM's reasoning/thinking (Think phase)", + "type": "string" + }, + "timestamp": { + "description": "When this step occurred", + "type": "string" + }, + "tool_calls": { + "description": "Tools called in this step (Act phase)", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ToolCall" + } + } + } + }, + "github_com_Tencent_WeKnora_internal_types.AnswerStrategy": { + "type": "string", + "enum": [ + "all", + "random" + ], + "x-enum-varnames": [ + "AnswerStrategyAll", + "AnswerStrategyRandom" + ] + }, + "github_com_Tencent_WeKnora_internal_types.ChunkingConfig": { + "type": "object", + "properties": { + "chunk_overlap": { + "description": "Chunk overlap", + "type": "integer" + }, + "chunk_size": { + "description": "Chunk size", + "type": "integer" + }, + "enable_multimodal": { + "description": "EnableMultimodal (deprecated, kept for backward compatibility with old data)", + "type": "boolean" + }, + "separators": { + "description": "Separators", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ContextCompressionStrategy": { + "type": "string", + "enum": [ + "sliding_window", + "smart" + ], + "x-enum-varnames": [ + "ContextCompressionSlidingWindow", + "ContextCompressionSmart" + ] + }, + "github_com_Tencent_WeKnora_internal_types.ContextConfig": { + "type": "object", + "properties": { + "compression_strategy": { + "description": "Compression strategy: \"sliding_window\" or \"smart\"", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ContextCompressionStrategy" + } + ] + }, + "max_tokens": { + "description": "Maximum tokens allowed in LLM context", + "type": "integer" + }, + "recent_message_count": { + "description": "For sliding_window: number of messages to keep\nFor smart: number of recent messages to keep uncompressed", + "type": "integer" + }, + "summarize_threshold": { + "description": "Summarize threshold: number of messages before summarization", + "type": "integer" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ConversationConfig": { + "type": "object", + "properties": { + "context_template": { + "description": "ContextTemplate is the prompt template for summarizing retrieval results", + "type": "string" + }, + "embedding_top_k": { + "type": "integer" + }, + "enable_query_expansion": { + "type": "boolean" + }, + "enable_rewrite": { + "type": "boolean" + }, + "fallback_prompt": { + "type": "string" + }, + "fallback_response": { + "type": "string" + }, + "fallback_strategy": { + "description": "Fallback strategy", + "type": "string" + }, + "keyword_threshold": { + "type": "number" + }, + "max_completion_tokens": { + "description": "MaxTokens is the maximum number of tokens to generate", + "type": "integer" + }, + "max_rounds": { + "description": "Retrieval \u0026 strategy parameters", + "type": "integer" + }, + "prompt": { + "type": "string" + }, + "rerank_model_id": { + "type": "string" + }, + "rerank_threshold": { + "type": "number" + }, + "rerank_top_k": { + "type": "integer" + }, + "rewrite_prompt_system": { + "description": "Rewrite prompts", + "type": "string" + }, + "rewrite_prompt_user": { + "type": "string" + }, + "summary_model_id": { + "description": "Model configuration", + "type": "string" + }, + "temperature": { + "description": "Temperature controls the randomness of the model output", + "type": "number" + }, + "use_custom_context_template": { + "type": "boolean" + }, + "use_custom_system_prompt": { + "description": "Prompt is the system prompt for normal mode", + "type": "boolean" + }, + "vector_threshold": { + "type": "number" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.EmbeddingParameters": { + "type": "object", + "properties": { + "dimension": { + "type": "integer" + }, + "truncate_prompt_tokens": { + "type": "integer" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ExtractConfig": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.GraphNode" + } + }, + "relations": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.GraphRelation" + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "text": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQBatchUpsertPayload": { + "type": "object", + "required": [ + "entries" + ], + "properties": { + "entries": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryPayload" + } + }, + "knowledge_id": { + "type": "string" + }, + "mode": { + "type": "string", + "enum": [ + "append", + "replace" + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQConfig": { + "type": "object", + "properties": { + "index_mode": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQIndexMode" + }, + "question_index_mode": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQQuestionIndexMode" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsBatchUpdate": { + "type": "object", + "properties": { + "by_id": { + "description": "ByID 按条目ID更新,key为条目ID", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsUpdate" + } + }, + "by_tag": { + "description": "ByTag 按Tag批量更新,key为TagID(空字符串表示未分类)", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsUpdate" + } + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsUpdate": { + "type": "object", + "properties": { + "is_enabled": { + "type": "boolean" + }, + "is_recommended": { + "type": "boolean" + }, + "tag_id": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQEntryPayload": { + "type": "object", + "required": [ + "answers", + "standard_question" + ], + "properties": { + "answer_strategy": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.AnswerStrategy" + }, + "answers": { + "type": "array", + "items": { + "type": "string" + } + }, + "is_enabled": { + "type": "boolean" + }, + "is_recommended": { + "type": "boolean" + }, + "negative_questions": { + "type": "array", + "items": { + "type": "string" + } + }, + "similar_questions": { + "type": "array", + "items": { + "type": "string" + } + }, + "standard_question": { + "type": "string" + }, + "tag_id": { + "type": "string" + }, + "tag_name": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FAQIndexMode": { + "type": "string", + "enum": [ + "question_only", + "question_answer" + ], + "x-enum-varnames": [ + "FAQIndexModeQuestionOnly", + "FAQIndexModeQuestionAnswer" + ] + }, + "github_com_Tencent_WeKnora_internal_types.FAQQuestionIndexMode": { + "type": "string", + "enum": [ + "combined", + "separate" + ], + "x-enum-varnames": [ + "FAQQuestionIndexModeCombined", + "FAQQuestionIndexModeSeparate" + ] + }, + "github_com_Tencent_WeKnora_internal_types.FAQSearchRequest": { + "type": "object", + "required": [ + "query_text" + ], + "properties": { + "match_count": { + "type": "integer" + }, + "query_text": { + "type": "string" + }, + "vector_threshold": { + "type": "number" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.FallbackStrategy": { + "type": "string", + "enum": [ + "fixed", + "model" + ], + "x-enum-comments": { + "FallbackStrategyFixed": "Fixed response", + "FallbackStrategyModel": "Model fallback response" + }, + "x-enum-descriptions": [ + "Fixed response", + "Model fallback response" + ], + "x-enum-varnames": [ + "FallbackStrategyFixed", + "FallbackStrategyModel" + ] + }, + "github_com_Tencent_WeKnora_internal_types.GraphNode": { + "type": "object", + "properties": { + "attributes": { + "type": "array", + "items": { + "type": "string" + } + }, + "chunks": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.GraphRelation": { + "type": "object", + "properties": { + "node1": { + "type": "string" + }, + "node2": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ImageProcessingConfig": { + "type": "object", + "properties": { + "model_id": { + "description": "Model ID", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.Knowledge": { + "type": "object", + "properties": { + "created_at": { + "description": "Creation time of the knowledge", + "type": "string" + }, + "deleted_at": { + "description": "Deletion time of the knowledge", + "allOf": [ + { + "$ref": "#/definitions/gorm.DeletedAt" + } + ] + }, + "description": { + "description": "Description of the knowledge", + "type": "string" + }, + "embedding_model_id": { + "description": "ID of the embedding model", + "type": "string" + }, + "enable_status": { + "description": "Enable status of the knowledge", + "type": "string" + }, + "error_message": { + "description": "Error message of the knowledge", + "type": "string" + }, + "file_hash": { + "description": "File hash of the knowledge", + "type": "string" + }, + "file_name": { + "description": "File name of the knowledge", + "type": "string" + }, + "file_path": { + "description": "File path of the knowledge", + "type": "string" + }, + "file_size": { + "description": "File size of the knowledge", + "type": "integer" + }, + "file_type": { + "description": "File type of the knowledge", + "type": "string" + }, + "id": { + "description": "Unique identifier of the knowledge", + "type": "string" + }, + "knowledge_base_id": { + "description": "ID of the knowledge base", + "type": "string" + }, + "metadata": { + "description": "Metadata of the knowledge", + "type": "array", + "items": { + "type": "integer" + } + }, + "parse_status": { + "description": "Parse status of the knowledge", + "type": "string" + }, + "processed_at": { + "description": "Processed time of the knowledge", + "type": "string" + }, + "source": { + "description": "Source of the knowledge", + "type": "string" + }, + "storage_size": { + "description": "Storage size of the knowledge", + "type": "integer" + }, + "summary_status": { + "description": "Summary status for async summary generation", + "type": "string" + }, + "tag_id": { + "description": "Optional tag ID for categorization within a knowledge base", + "type": "string" + }, + "tenant_id": { + "description": "Tenant ID", + "type": "integer" + }, + "title": { + "description": "Title of the knowledge", + "type": "string" + }, + "type": { + "description": "Type of the knowledge", + "type": "string" + }, + "updated_at": { + "description": "Last updated time of the knowledge", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.KnowledgeBase": { + "type": "object", + "properties": { + "chunk_count": { + "description": "Chunk count (not stored in database, calculated on query)", + "type": "integer" + }, + "chunking_config": { + "description": "Chunking configuration", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ChunkingConfig" + } + ] + }, + "cos_config": { + "description": "Storage config", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.StorageConfig" + } + ] + }, + "created_at": { + "description": "Creation time of the knowledge base", + "type": "string" + }, + "deleted_at": { + "description": "Deletion time of the knowledge base", + "allOf": [ + { + "$ref": "#/definitions/gorm.DeletedAt" + } + ] + }, + "description": { + "description": "Description of the knowledge base", + "type": "string" + }, + "embedding_model_id": { + "description": "ID of the embedding model", + "type": "string" + }, + "extract_config": { + "description": "Extract config", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ExtractConfig" + } + ] + }, + "faq_config": { + "description": "FAQConfig stores FAQ specific configuration such as indexing strategy", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQConfig" + } + ] + }, + "id": { + "description": "Unique identifier of the knowledge base", + "type": "string" + }, + "image_processing_config": { + "description": "Image processing configuration", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ImageProcessingConfig" + } + ] + }, + "is_processing": { + "description": "IsProcessing indicates if there is a processing import task (for FAQ type knowledge bases)", + "type": "boolean" + }, + "is_temporary": { + "description": "Whether this knowledge base is temporary (ephemeral) and should be hidden from UI", + "type": "boolean" + }, + "knowledge_count": { + "description": "Knowledge count (not stored in database, calculated on query)", + "type": "integer" + }, + "name": { + "description": "Name of the knowledge base", + "type": "string" + }, + "processing_count": { + "description": "ProcessingCount indicates the number of knowledge items being processed (for document type knowledge bases)", + "type": "integer" + }, + "question_generation_config": { + "description": "QuestionGenerationConfig stores question generation configuration for document knowledge bases", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.QuestionGenerationConfig" + } + ] + }, + "summary_model_id": { + "description": "Summary model ID", + "type": "string" + }, + "tenant_id": { + "description": "Tenant ID", + "type": "integer" + }, + "type": { + "description": "Type of the knowledge base (document, faq, etc.)", + "type": "string" + }, + "updated_at": { + "description": "Last updated time of the knowledge base", + "type": "string" + }, + "vlm_config": { + "description": "VLM config", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.VLMConfig" + } + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.KnowledgeBaseConfig": { + "type": "object", + "properties": { + "chunking_config": { + "description": "Chunking configuration", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ChunkingConfig" + } + ] + }, + "faq_config": { + "description": "FAQ configuration (only for FAQ type knowledge bases)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FAQConfig" + } + ] + }, + "image_processing_config": { + "description": "Image processing configuration", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ImageProcessingConfig" + } + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.LoginRequest": { + "type": "object", + "required": [ + "email", + "password" + ], + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string", + "minLength": 6 + } + } + }, + "github_com_Tencent_WeKnora_internal_types.LoginResponse": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "refresh_token": { + "type": "string" + }, + "success": { + "type": "boolean" + }, + "tenant": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant" + }, + "token": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.User" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPAdvancedConfig": { + "type": "object", + "properties": { + "retry_count": { + "description": "Number of retries, default: 3", + "type": "integer" + }, + "retry_delay": { + "description": "Delay between retries in seconds, default: 1", + "type": "integer" + }, + "timeout": { + "description": "Timeout in seconds, default: 30", + "type": "integer" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPAuthConfig": { + "type": "object", + "properties": { + "api_key": { + "type": "string" + }, + "custom_headers": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "token": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPEnvVars": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPHeaders": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPService": { + "type": "object", + "properties": { + "advanced_config": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPAdvancedConfig" + }, + "auth_config": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPAuthConfig" + }, + "created_at": { + "type": "string" + }, + "deleted_at": { + "$ref": "#/definitions/gorm.DeletedAt" + }, + "description": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "env_vars": { + "description": "Environment variables for stdio", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPEnvVars" + } + ] + }, + "headers": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPHeaders" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "stdio_config": { + "description": "Required for stdio transport", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPStdioConfig" + } + ] + }, + "tenant_id": { + "type": "integer" + }, + "transport_type": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MCPTransportType" + }, + "updated_at": { + "type": "string" + }, + "url": { + "description": "Optional: required for SSE/HTTP Streamable", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPStdioConfig": { + "type": "object", + "properties": { + "args": { + "description": "Command arguments array", + "type": "array", + "items": { + "type": "string" + } + }, + "command": { + "description": "Command: \"uvx\" or \"npx\"", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MCPTransportType": { + "type": "string", + "enum": [ + "sse", + "http-streamable", + "stdio" + ], + "x-enum-comments": { + "MCPTransportHTTPStreamable": "HTTP Streamable", + "MCPTransportSSE": "Server-Sent Events", + "MCPTransportStdio": "Stdio (Standard Input/Output)" + }, + "x-enum-descriptions": [ + "Server-Sent Events", + "HTTP Streamable", + "Stdio (Standard Input/Output)" + ], + "x-enum-varnames": [ + "MCPTransportSSE", + "MCPTransportHTTPStreamable", + "MCPTransportStdio" + ] + }, + "github_com_Tencent_WeKnora_internal_types.ManualKnowledgePayload": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "status": { + "type": "string" + }, + "title": { + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.MatchType": { + "type": "integer", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7 + ], + "x-enum-comments": { + "MatchTypeParentChunk": "父Chunk匹配类型", + "MatchTypeRelationChunk": "关系Chunk匹配类型", + "MatchTypeWebSearch": "网络搜索匹配类型" + }, + "x-enum-descriptions": [ + "", + "", + "", + "", + "父Chunk匹配类型", + "关系Chunk匹配类型", + "", + "网络搜索匹配类型" + ], + "x-enum-varnames": [ + "MatchTypeEmbedding", + "MatchTypeKeywords", + "MatchTypeNearByChunk", + "MatchTypeHistory", + "MatchTypeParentChunk", + "MatchTypeRelationChunk", + "MatchTypeGraph", + "MatchTypeWebSearch" + ] + }, + "github_com_Tencent_WeKnora_internal_types.Message": { + "type": "object", + "properties": { + "agent_steps": { + "description": "Agent execution steps (only for assistant messages generated by agent)\nThis contains the detailed reasoning process and tool calls made by the agent\nStored for user history display, but NOT included in LLM context to avoid redundancy", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.AgentStep" + } + }, + "content": { + "description": "Message text content", + "type": "string" + }, + "created_at": { + "description": "Message creation timestamp", + "type": "string" + }, + "deleted_at": { + "description": "Soft delete timestamp", + "allOf": [ + { + "$ref": "#/definitions/gorm.DeletedAt" + } + ] + }, + "id": { + "description": "Unique identifier for the message", + "type": "string" + }, + "is_completed": { + "description": "Whether message generation is complete", + "type": "boolean" + }, + "knowledge_references": { + "description": "References to knowledge chunks used in the response", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SearchResult" + } + }, + "request_id": { + "description": "Request identifier for tracking API requests", + "type": "string" + }, + "role": { + "description": "Message role: \"user\", \"assistant\", \"system\"", + "type": "string" + }, + "session_id": { + "description": "ID of the session this message belongs to", + "type": "string" + }, + "updated_at": { + "description": "Last update timestamp", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ModelParameters": { + "type": "object", + "properties": { + "api_key": { + "type": "string" + }, + "base_url": { + "type": "string" + }, + "embedding_parameters": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.EmbeddingParameters" + }, + "interface_type": { + "type": "string" + }, + "parameter_size": { + "description": "Ollama model parameter size (e.g., \"7B\", \"13B\", \"70B\")", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ModelSource": { + "type": "string", + "enum": [ + "local", + "remote", + "aliyun" + ], + "x-enum-comments": { + "ModelSourceAliyun": "Aliyun DashScope model", + "ModelSourceLocal": "Local model", + "ModelSourceRemote": "Remote model" + }, + "x-enum-descriptions": [ + "Local model", + "Remote model", + "Aliyun DashScope model" + ], + "x-enum-varnames": [ + "ModelSourceLocal", + "ModelSourceRemote", + "ModelSourceAliyun" + ] + }, + "github_com_Tencent_WeKnora_internal_types.ModelType": { + "type": "string", + "enum": [ + "Embedding", + "Rerank", + "KnowledgeQA", + "VLLM" + ], + "x-enum-comments": { + "ModelTypeEmbedding": "Embedding model", + "ModelTypeKnowledgeQA": "KnowledgeQA model", + "ModelTypeRerank": "Rerank model", + "ModelTypeVLLM": "VLLM model" + }, + "x-enum-descriptions": [ + "Embedding model", + "Rerank model", + "KnowledgeQA model", + "VLLM model" + ], + "x-enum-varnames": [ + "ModelTypeEmbedding", + "ModelTypeRerank", + "ModelTypeKnowledgeQA", + "ModelTypeVLLM" + ] + }, + "github_com_Tencent_WeKnora_internal_types.QuestionGenerationConfig": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "question_count": { + "description": "Number of questions to generate per chunk (default: 3, max: 10)", + "type": "integer" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.RegisterRequest": { + "type": "object", + "required": [ + "email", + "password", + "username" + ], + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string", + "minLength": 6 + }, + "username": { + "type": "string", + "maxLength": 50, + "minLength": 3 + } + } + }, + "github_com_Tencent_WeKnora_internal_types.RegisterResponse": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "success": { + "type": "boolean" + }, + "tenant": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant" + }, + "user": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.User" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.RetrieverEngineParams": { + "type": "object", + "properties": { + "retriever_engine_type": { + "description": "Retriever engine type", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverEngineType" + } + ] + }, + "retriever_type": { + "description": "Retriever type", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverType" + } + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.RetrieverEngineType": { + "type": "string", + "enum": [ + "postgres", + "elasticsearch", + "infinity", + "elasticfaiss", + "qdrant" + ], + "x-enum-varnames": [ + "PostgresRetrieverEngineType", + "ElasticsearchRetrieverEngineType", + "InfinityRetrieverEngineType", + "ElasticFaissRetrieverEngineType", + "QdrantRetrieverEngineType" + ] + }, + "github_com_Tencent_WeKnora_internal_types.RetrieverEngines": { + "type": "object", + "properties": { + "engines": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverEngineParams" + } + } + } + }, + "github_com_Tencent_WeKnora_internal_types.RetrieverType": { + "type": "string", + "enum": [ + "keywords", + "vector", + "websearch" + ], + "x-enum-comments": { + "KeywordsRetrieverType": "Keywords retriever", + "VectorRetrieverType": "Vector retriever", + "WebSearchRetrieverType": "Web search retriever" + }, + "x-enum-descriptions": [ + "Keywords retriever", + "Vector retriever", + "Web search retriever" + ], + "x-enum-varnames": [ + "KeywordsRetrieverType", + "VectorRetrieverType", + "WebSearchRetrieverType" + ] + }, + "github_com_Tencent_WeKnora_internal_types.SearchParams": { + "type": "object", + "properties": { + "disable_keywords_match": { + "type": "boolean" + }, + "disable_vector_match": { + "type": "boolean" + }, + "keyword_threshold": { + "type": "number" + }, + "match_count": { + "type": "integer" + }, + "query_text": { + "type": "string" + }, + "vector_threshold": { + "type": "number" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.SearchResult": { + "type": "object", + "properties": { + "chunk_index": { + "description": "Chunk index", + "type": "integer" + }, + "chunk_metadata": { + "description": "ChunkMetadata stores chunk-level metadata (e.g., generated questions)", + "type": "array", + "items": { + "type": "integer" + } + }, + "chunk_type": { + "description": "Chunk 类型", + "type": "string" + }, + "content": { + "description": "Content", + "type": "string" + }, + "end_at": { + "description": "End at", + "type": "integer" + }, + "id": { + "description": "ID", + "type": "string" + }, + "image_info": { + "description": "图片信息 (JSON 格式)", + "type": "string" + }, + "knowledge_filename": { + "description": "Knowledge file name\nUsed for file type knowledge, contains the original file name", + "type": "string" + }, + "knowledge_id": { + "description": "Knowledge ID", + "type": "string" + }, + "knowledge_source": { + "description": "Knowledge source\nUsed to indicate the source of the knowledge, such as \"url\"", + "type": "string" + }, + "knowledge_title": { + "description": "Knowledge title", + "type": "string" + }, + "match_type": { + "description": "Match type", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.MatchType" + } + ] + }, + "metadata": { + "description": "Metadata", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "parent_chunk_id": { + "description": "父 Chunk ID", + "type": "string" + }, + "score": { + "description": "Score", + "type": "number" + }, + "seq": { + "description": "Seq", + "type": "integer" + }, + "start_at": { + "description": "Start at", + "type": "integer" + }, + "sub_chunk_id": { + "description": "SubChunkIndex", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "github_com_Tencent_WeKnora_internal_types.Session": { + "type": "object", + "properties": { + "agent_config": { + "description": "Agent 配置(会话级别,仅存储enabled和knowledge_bases)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SessionAgentConfig" + } + ] + }, + "context_config": { + "description": "上下文管理配置(可选)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ContextConfig" + } + ] + }, + "created_at": { + "type": "string" + }, + "deleted_at": { + "$ref": "#/definitions/gorm.DeletedAt" + }, + "description": { + "description": "Description", + "type": "string" + }, + "embedding_top_k": { + "description": "向量召回TopK", + "type": "integer" + }, + "enable_rewrite": { + "description": "多轮改写开关", + "type": "boolean" + }, + "fallback_response": { + "description": "固定回复内容", + "type": "string" + }, + "fallback_strategy": { + "description": "兜底策略", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FallbackStrategy" + } + ] + }, + "id": { + "description": "ID", + "type": "string" + }, + "keyword_threshold": { + "description": "关键词召回阈值", + "type": "number" + }, + "knowledge_base_id": { + "description": "Strategy configuration", + "type": "string" + }, + "max_rounds": { + "description": "多轮保持轮数", + "type": "integer" + }, + "rerank_model_id": { + "description": "排序模型ID", + "type": "string" + }, + "rerank_threshold": { + "description": "排序阈值", + "type": "number" + }, + "rerank_top_k": { + "description": "排序TopK", + "type": "integer" + }, + "summary_model_id": { + "description": "总结模型ID", + "type": "string" + }, + "summary_parameters": { + "description": "总结模型参数", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SummaryConfig" + } + ] + }, + "tenant_id": { + "description": "Tenant ID", + "type": "integer" + }, + "title": { + "description": "Title", + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "vector_threshold": { + "description": "向量召回阈值", + "type": "number" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.SessionAgentConfig": { + "type": "object", + "properties": { + "agent_mode_enabled": { + "description": "Whether agent mode is enabled for this session", + "type": "boolean" + }, + "knowledge_bases": { + "description": "Accessible knowledge base IDs for this session", + "type": "array", + "items": { + "type": "string" + } + }, + "web_search_enabled": { + "description": "Whether web search is enabled for this session", + "type": "boolean" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.StorageConfig": { + "type": "object", + "properties": { + "app_id": { + "description": "App ID", + "type": "string" + }, + "bucket_name": { + "description": "Bucket Name", + "type": "string" + }, + "path_prefix": { + "description": "Path Prefix", + "type": "string" + }, + "provider": { + "description": "Provider", + "type": "string" + }, + "region": { + "description": "Region", + "type": "string" + }, + "secret_id": { + "description": "Secret ID", + "type": "string" + }, + "secret_key": { + "description": "Secret Key", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.SummaryConfig": { + "type": "object", + "properties": { + "context_template": { + "description": "Context template", + "type": "string" + }, + "frequency_penalty": { + "description": "Frequency penalty", + "type": "number" + }, + "max_completion_tokens": { + "description": "Max completion tokens", + "type": "integer" + }, + "max_tokens": { + "description": "Max tokens", + "type": "integer" + }, + "no_match_prefix": { + "description": "No match prefix", + "type": "string" + }, + "presence_penalty": { + "description": "Presence penalty", + "type": "number" + }, + "prompt": { + "description": "Prompt", + "type": "string" + }, + "repeat_penalty": { + "description": "Repeat penalty", + "type": "number" + }, + "seed": { + "description": "Seed", + "type": "integer" + }, + "temperature": { + "description": "Temperature", + "type": "number" + }, + "top_k": { + "description": "TopK", + "type": "integer" + }, + "top_p": { + "description": "TopP", + "type": "number" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.Tenant": { + "type": "object", + "properties": { + "agent_config": { + "description": "Global Agent configuration for this tenant (default for all sessions)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.AgentConfig" + } + ] + }, + "api_key": { + "description": "API key", + "type": "string" + }, + "business": { + "description": "Business", + "type": "string" + }, + "context_config": { + "description": "Global Context configuration for this tenant (default for all sessions)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ContextConfig" + } + ] + }, + "conversation_config": { + "description": "Global Conversation configuration for this tenant (default for normal mode sessions)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ConversationConfig" + } + ] + }, + "created_at": { + "description": "Creation time", + "type": "string" + }, + "deleted_at": { + "description": "Deletion time", + "allOf": [ + { + "$ref": "#/definitions/gorm.DeletedAt" + } + ] + }, + "description": { + "description": "Description", + "type": "string" + }, + "id": { + "description": "ID", + "type": "integer" + }, + "name": { + "description": "Name", + "type": "string" + }, + "retriever_engines": { + "description": "Retriever engines", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverEngines" + } + ] + }, + "status": { + "description": "Status", + "type": "string" + }, + "storage_quota": { + "description": "Storage quota (Bytes), default is 10GB, including vector, original file, text, index, etc.", + "type": "integer" + }, + "storage_used": { + "description": "Storage used (Bytes)", + "type": "integer" + }, + "updated_at": { + "description": "Last updated time", + "type": "string" + }, + "web_search_config": { + "description": "Global WebSearch configuration for this tenant", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.WebSearchConfig" + } + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ToolCall": { + "type": "object", + "properties": { + "args": { + "description": "Tool arguments", + "type": "object", + "additionalProperties": true + }, + "duration": { + "description": "Execution time in milliseconds", + "type": "integer" + }, + "id": { + "description": "Function call ID from LLM", + "type": "string" + }, + "name": { + "description": "Tool name", + "type": "string" + }, + "reflection": { + "description": "Agent's reflection on this tool call result (if enabled)", + "type": "string" + }, + "result": { + "description": "Execution result (contains Output)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ToolResult" + } + ] + } + } + }, + "github_com_Tencent_WeKnora_internal_types.ToolResult": { + "type": "object", + "properties": { + "data": { + "description": "Structured data for programmatic use", + "type": "object", + "additionalProperties": true + }, + "error": { + "description": "Error message if execution failed", + "type": "string" + }, + "output": { + "description": "Human-readable output", + "type": "string" + }, + "success": { + "description": "Whether the tool executed successfully", + "type": "boolean" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.User": { + "type": "object", + "properties": { + "avatar": { + "description": "Avatar URL of the user", + "type": "string" + }, + "can_access_all_tenants": { + "description": "Whether the user can access all tenants (cross-tenant access)", + "type": "boolean" + }, + "created_at": { + "description": "Creation time of the user", + "type": "string" + }, + "deleted_at": { + "description": "Deletion time of the user", + "allOf": [ + { + "$ref": "#/definitions/gorm.DeletedAt" + } + ] + }, + "email": { + "description": "Email address of the user", + "type": "string" + }, + "id": { + "description": "Unique identifier of the user", + "type": "string" + }, + "is_active": { + "description": "Whether the user is active", + "type": "boolean" + }, + "tenant": { + "description": "Association relationship, not stored in the database", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant" + } + ] + }, + "tenant_id": { + "description": "Tenant ID that the user belongs to", + "type": "integer" + }, + "updated_at": { + "description": "Last updated time of the user", + "type": "string" + }, + "username": { + "description": "Username of the user", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.VLMConfig": { + "type": "object", + "properties": { + "api_key": { + "description": "API Key", + "type": "string" + }, + "base_url": { + "description": "Base URL", + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "interface_type": { + "description": "Interface Type: \"ollama\" or \"openai\"", + "type": "string" + }, + "model_id": { + "type": "string" + }, + "model_name": { + "description": "兼容老版本\nModel Name", + "type": "string" + } + } + }, + "github_com_Tencent_WeKnora_internal_types.WebSearchConfig": { + "type": "object", + "properties": { + "api_key": { + "description": "API密钥(如果需要)", + "type": "string" + }, + "blacklist": { + "description": "黑名单规则列表", + "type": "array", + "items": { + "type": "string" + } + }, + "compression_method": { + "description": "压缩方法:none, summary, extract, rag", + "type": "string" + }, + "document_fragments": { + "description": "文档片段数量(用于RAG压缩)", + "type": "integer" + }, + "embedding_dimension": { + "description": "嵌入维度(用于RAG压缩)", + "type": "integer" + }, + "embedding_model_id": { + "description": "RAG压缩相关配置", + "type": "string" + }, + "include_date": { + "description": "是否包含日期", + "type": "boolean" + }, + "max_results": { + "description": "最大搜索结果数", + "type": "integer" + }, + "provider": { + "description": "搜索引擎提供商ID", + "type": "string" + }, + "rerank_model_id": { + "description": "重排模型ID(用于RAG压缩)", + "type": "string" + } + } + }, + "gorm.DeletedAt": { + "type": "object", + "properties": { + "time": { + "type": "string" + }, + "valid": { + "description": "Valid is true if Time is not NULL", + "type": "boolean" + } + } + }, + "internal_handler.CopyKnowledgeBaseRequest": { + "type": "object", + "required": [ + "source_id" + ], + "properties": { + "source_id": { + "type": "string" + }, + "target_id": { + "type": "string" + } + } + }, + "internal_handler.CreateModelRequest": { + "type": "object", + "required": [ + "name", + "parameters", + "source", + "type" + ], + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parameters": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelParameters" + }, + "source": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelSource" + }, + "type": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelType" + } + } + }, + "internal_handler.EvaluationRequest": { + "type": "object", + "properties": { + "chat_id": { + "description": "ID of chat model to use", + "type": "string" + }, + "dataset_id": { + "description": "ID of dataset to evaluate", + "type": "string" + }, + "knowledge_base_id": { + "description": "ID of knowledge base to use", + "type": "string" + }, + "rerank_id": { + "description": "ID of rerank model to use", + "type": "string" + } + } + }, + "internal_handler.FabriTextRequest": { + "type": "object", + "properties": { + "llm_config": { + "$ref": "#/definitions/internal_handler.LLMConfig" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "internal_handler.GetSystemInfoResponse": { + "type": "object", + "properties": { + "build_time": { + "type": "string" + }, + "commit_id": { + "type": "string" + }, + "go_version": { + "type": "string" + }, + "graph_database_engine": { + "type": "string" + }, + "keyword_index_engine": { + "type": "string" + }, + "minio_enabled": { + "type": "boolean" + }, + "vector_store_engine": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "internal_handler.KBModelConfigRequest": { + "type": "object", + "required": [ + "embeddingModelId", + "llmModelId" + ], + "properties": { + "documentSplitting": { + "description": "文档分块配置", + "type": "object", + "properties": { + "chunkOverlap": { + "type": "integer" + }, + "chunkSize": { + "type": "integer" + }, + "separators": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "embeddingModelId": { + "type": "string" + }, + "llmModelId": { + "type": "string" + }, + "multimodal": { + "description": "多模态配置", + "type": "object", + "properties": { + "cos": { + "type": "object", + "properties": { + "appId": { + "type": "string" + }, + "bucketName": { + "type": "string" + }, + "pathPrefix": { + "type": "string" + }, + "region": { + "type": "string" + }, + "secretId": { + "type": "string" + }, + "secretKey": { + "type": "string" + } + } + }, + "enabled": { + "type": "boolean" + }, + "minio": { + "type": "object", + "properties": { + "bucketName": { + "type": "string" + }, + "pathPrefix": { + "type": "string" + }, + "useSSL": { + "type": "boolean" + } + } + }, + "storageType": { + "description": "\"cos\" or \"minio\"", + "type": "string" + } + } + }, + "nodeExtract": { + "description": "知识图谱配置", + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.GraphNode" + } + }, + "relations": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.GraphRelation" + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "text": { + "type": "string" + } + } + }, + "questionGeneration": { + "description": "问题生成配置", + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "questionCount": { + "type": "integer" + } + } + }, + "vlm_config": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.VLMConfig" + } + } + }, + "internal_handler.LLMConfig": { + "type": "object", + "properties": { + "api_key": { + "type": "string" + }, + "base_url": { + "type": "string" + }, + "model_name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + }, + "internal_handler.RemoteModelCheckRequest": { + "type": "object", + "required": [ + "baseUrl", + "modelName" + ], + "properties": { + "apiKey": { + "type": "string" + }, + "baseUrl": { + "type": "string" + }, + "modelName": { + "type": "string" + } + } + }, + "internal_handler.TextRelationExtractionRequest": { + "type": "object", + "required": [ + "tags", + "text" + ], + "properties": { + "llm_config": { + "$ref": "#/definitions/internal_handler.LLMConfig" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "text": { + "type": "string" + } + } + }, + "internal_handler.UpdateChunkRequest": { + "type": "object", + "properties": { + "chunk_index": { + "type": "integer" + }, + "content": { + "type": "string" + }, + "embedding": { + "type": "array", + "items": { + "type": "number" + } + }, + "end_at": { + "type": "integer" + }, + "image_info": { + "type": "string" + }, + "is_enabled": { + "type": "boolean" + }, + "start_at": { + "type": "integer" + } + } + }, + "internal_handler.UpdateKnowledgeBaseRequest": { + "type": "object", + "required": [ + "config", + "name" + ], + "properties": { + "config": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.KnowledgeBaseConfig" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "internal_handler.UpdateModelRequest": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parameters": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelParameters" + }, + "source": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelSource" + }, + "type": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.ModelType" + } + } + }, + "internal_handler_session.CreateKnowledgeQARequest": { + "type": "object", + "required": [ + "query" + ], + "properties": { + "agent_enabled": { + "description": "Whether agent mode is enabled for this request", + "type": "boolean" + }, + "knowledge_base_ids": { + "description": "Selected knowledge base ID for this request", + "type": "array", + "items": { + "type": "string" + } + }, + "query": { + "description": "Query text for knowledge base search", + "type": "string" + }, + "summary_model_id": { + "description": "Optional summary model ID for this request (overrides session default)", + "type": "string" + }, + "web_search_enabled": { + "description": "Whether web search is enabled for this request", + "type": "boolean" + } + } + }, + "internal_handler_session.CreateSessionRequest": { + "type": "object", + "properties": { + "agent_config": { + "description": "Agent configuration (optional, session-level config only: enabled and knowledge_bases)", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SessionAgentConfig" + } + ] + }, + "knowledge_base_id": { + "description": "ID of the associated knowledge base (optional, can be set/changed during queries)", + "type": "string" + }, + "session_strategy": { + "description": "Session strategy configuration", + "allOf": [ + { + "$ref": "#/definitions/internal_handler_session.SessionStrategy" + } + ] + } + } + }, + "internal_handler_session.GenerateTitleRequest": { + "type": "object", + "required": [ + "messages" + ], + "properties": { + "messages": { + "description": "Messages to use as context for title generation", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.Message" + } + } + } + }, + "internal_handler_session.SearchKnowledgeRequest": { + "type": "object", + "required": [ + "knowledge_base_id", + "query" + ], + "properties": { + "knowledge_base_id": { + "description": "ID of the knowledge base to search", + "type": "string" + }, + "query": { + "description": "Query text to search for", + "type": "string" + } + } + }, + "internal_handler_session.SessionStrategy": { + "type": "object", + "properties": { + "embedding_top_k": { + "description": "Number of top results to retrieve from vector search", + "type": "integer" + }, + "enable_rewrite": { + "description": "Whether to enable query rewrite for multi-round conversations", + "type": "boolean" + }, + "fallback_response": { + "description": "Fixed response content for fallback", + "type": "string" + }, + "fallback_strategy": { + "description": "Strategy to use when no relevant knowledge is found", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.FallbackStrategy" + } + ] + }, + "keyword_threshold": { + "description": "Threshold for keyword-based retrieval", + "type": "number" + }, + "max_rounds": { + "description": "Maximum number of conversation rounds to maintain", + "type": "integer" + }, + "no_match_prefix": { + "description": "Prefix for responses when no match is found", + "type": "string" + }, + "rerank_model_id": { + "description": "ID of the model used for reranking results", + "type": "string" + }, + "rerank_threshold": { + "description": "Threshold for reranking results", + "type": "number" + }, + "rerank_top_k": { + "description": "Number of top results after reranking", + "type": "integer" + }, + "summary_model_id": { + "description": "ID of the model used for summarization", + "type": "string" + }, + "summary_parameters": { + "description": "Parameters for the summary model", + "allOf": [ + { + "$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.SummaryConfig" + } + ] + }, + "vector_threshold": { + "description": "Threshold for vector-based retrieval", + "type": "number" + } + } + }, + "internal_handler_session.StopSessionRequest": { + "type": "object", + "required": [ + "message_id" + ], + "properties": { + "message_id": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "Bearer": { + "description": "输入 Bearer {token} 格式的 JWT 令牌", + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml new file mode 100644 index 00000000..1fad1d10 --- /dev/null +++ b/docs/swagger.yaml @@ -0,0 +1,4869 @@ +basePath: /api/v1 +definitions: + github_com_Tencent_WeKnora_internal_errors.AppError: + properties: + code: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.ErrorCode' + details: {} + message: + type: string + type: object + github_com_Tencent_WeKnora_internal_errors.ErrorCode: + enum: + - 1000 + - 1001 + - 1002 + - 1003 + - 1004 + - 1005 + - 1006 + - 1007 + - 1008 + - 1009 + - 1010 + - 2000 + - 2001 + - 2002 + - 2003 + - 2004 + - 2100 + - 2101 + - 2102 + - 2103 + type: integer + x-enum-varnames: + - ErrBadRequest + - ErrUnauthorized + - ErrForbidden + - ErrNotFound + - ErrMethodNotAllowed + - ErrConflict + - ErrTooManyRequests + - ErrInternalServer + - ErrServiceUnavailable + - ErrTimeout + - ErrValidation + - ErrTenantNotFound + - ErrTenantAlreadyExists + - ErrTenantInactive + - ErrTenantNameRequired + - ErrTenantInvalidStatus + - ErrAgentMissingThinkingModel + - ErrAgentMissingAllowedTools + - ErrAgentInvalidMaxIterations + - ErrAgentInvalidTemperature + github_com_Tencent_WeKnora_internal_types.AgentConfig: + properties: + allowed_tools: + description: List of allowed tool names + items: + type: string + type: array + knowledge_bases: + description: Accessible knowledge base IDs + items: + type: string + type: array + max_iterations: + description: Maximum number of ReAct iterations + type: integer + reflection_enabled: + description: Whether to enable reflection + type: boolean + system_prompt_web_disabled: + description: Custom prompt when web search is disabled + type: string + system_prompt_web_enabled: + description: Custom prompt when web search is enabled + type: string + temperature: + description: LLM temperature for agent + type: number + use_custom_system_prompt: + description: Whether to use custom system prompt instead of default + type: boolean + web_search_enabled: + description: Whether web search tool is enabled + type: boolean + web_search_max_results: + description: 'Maximum number of web search results (default: 5)' + type: integer + type: object + github_com_Tencent_WeKnora_internal_types.AgentStep: + properties: + iteration: + description: Iteration number (0-indexed) + type: integer + thought: + description: LLM's reasoning/thinking (Think phase) + type: string + timestamp: + description: When this step occurred + type: string + tool_calls: + description: Tools called in this step (Act phase) + items: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ToolCall' + type: array + type: object + github_com_Tencent_WeKnora_internal_types.AnswerStrategy: + enum: + - all + - random + type: string + x-enum-varnames: + - AnswerStrategyAll + - AnswerStrategyRandom + github_com_Tencent_WeKnora_internal_types.ChunkingConfig: + properties: + chunk_overlap: + description: Chunk overlap + type: integer + chunk_size: + description: Chunk size + type: integer + enable_multimodal: + description: EnableMultimodal (deprecated, kept for backward compatibility + with old data) + type: boolean + separators: + description: Separators + items: + type: string + type: array + type: object + github_com_Tencent_WeKnora_internal_types.ContextCompressionStrategy: + enum: + - sliding_window + - smart + type: string + x-enum-varnames: + - ContextCompressionSlidingWindow + - ContextCompressionSmart + github_com_Tencent_WeKnora_internal_types.ContextConfig: + properties: + compression_strategy: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ContextCompressionStrategy' + description: 'Compression strategy: "sliding_window" or "smart"' + max_tokens: + description: Maximum tokens allowed in LLM context + type: integer + recent_message_count: + description: |- + For sliding_window: number of messages to keep + For smart: number of recent messages to keep uncompressed + type: integer + summarize_threshold: + description: 'Summarize threshold: number of messages before summarization' + type: integer + type: object + github_com_Tencent_WeKnora_internal_types.ConversationConfig: + properties: + context_template: + description: ContextTemplate is the prompt template for summarizing retrieval + results + type: string + embedding_top_k: + type: integer + enable_query_expansion: + type: boolean + enable_rewrite: + type: boolean + fallback_prompt: + type: string + fallback_response: + type: string + fallback_strategy: + description: Fallback strategy + type: string + keyword_threshold: + type: number + max_completion_tokens: + description: MaxTokens is the maximum number of tokens to generate + type: integer + max_rounds: + description: Retrieval & strategy parameters + type: integer + prompt: + type: string + rerank_model_id: + type: string + rerank_threshold: + type: number + rerank_top_k: + type: integer + rewrite_prompt_system: + description: Rewrite prompts + type: string + rewrite_prompt_user: + type: string + summary_model_id: + description: Model configuration + type: string + temperature: + description: Temperature controls the randomness of the model output + type: number + use_custom_context_template: + type: boolean + use_custom_system_prompt: + description: Prompt is the system prompt for normal mode + type: boolean + vector_threshold: + type: number + type: object + github_com_Tencent_WeKnora_internal_types.EmbeddingParameters: + properties: + dimension: + type: integer + truncate_prompt_tokens: + type: integer + type: object + github_com_Tencent_WeKnora_internal_types.ExtractConfig: + properties: + enabled: + type: boolean + nodes: + items: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.GraphNode' + type: array + relations: + items: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.GraphRelation' + type: array + tags: + items: + type: string + type: array + text: + type: string + type: object + github_com_Tencent_WeKnora_internal_types.FAQBatchUpsertPayload: + properties: + entries: + items: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryPayload' + type: array + knowledge_id: + type: string + mode: + enum: + - append + - replace + type: string + required: + - entries + type: object + github_com_Tencent_WeKnora_internal_types.FAQConfig: + properties: + index_mode: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQIndexMode' + question_index_mode: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQQuestionIndexMode' + type: object + github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsBatchUpdate: + properties: + by_id: + additionalProperties: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsUpdate' + description: ByID 按条目ID更新,key为条目ID + type: object + by_tag: + additionalProperties: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsUpdate' + description: ByTag 按Tag批量更新,key为TagID(空字符串表示未分类) + type: object + type: object + github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsUpdate: + properties: + is_enabled: + type: boolean + is_recommended: + type: boolean + tag_id: + type: string + type: object + github_com_Tencent_WeKnora_internal_types.FAQEntryPayload: + properties: + answer_strategy: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.AnswerStrategy' + answers: + items: + type: string + type: array + is_enabled: + type: boolean + is_recommended: + type: boolean + negative_questions: + items: + type: string + type: array + similar_questions: + items: + type: string + type: array + standard_question: + type: string + tag_id: + type: string + tag_name: + type: string + required: + - answers + - standard_question + type: object + github_com_Tencent_WeKnora_internal_types.FAQIndexMode: + enum: + - question_only + - question_answer + type: string + x-enum-varnames: + - FAQIndexModeQuestionOnly + - FAQIndexModeQuestionAnswer + github_com_Tencent_WeKnora_internal_types.FAQQuestionIndexMode: + enum: + - combined + - separate + type: string + x-enum-varnames: + - FAQQuestionIndexModeCombined + - FAQQuestionIndexModeSeparate + github_com_Tencent_WeKnora_internal_types.FAQSearchRequest: + properties: + match_count: + type: integer + query_text: + type: string + vector_threshold: + type: number + required: + - query_text + type: object + github_com_Tencent_WeKnora_internal_types.FallbackStrategy: + enum: + - fixed + - model + type: string + x-enum-comments: + FallbackStrategyFixed: Fixed response + FallbackStrategyModel: Model fallback response + x-enum-descriptions: + - Fixed response + - Model fallback response + x-enum-varnames: + - FallbackStrategyFixed + - FallbackStrategyModel + github_com_Tencent_WeKnora_internal_types.GraphNode: + properties: + attributes: + items: + type: string + type: array + chunks: + items: + type: string + type: array + name: + type: string + type: object + github_com_Tencent_WeKnora_internal_types.GraphRelation: + properties: + node1: + type: string + node2: + type: string + type: + type: string + type: object + github_com_Tencent_WeKnora_internal_types.ImageProcessingConfig: + properties: + model_id: + description: Model ID + type: string + type: object + github_com_Tencent_WeKnora_internal_types.Knowledge: + properties: + created_at: + description: Creation time of the knowledge + type: string + deleted_at: + allOf: + - $ref: '#/definitions/gorm.DeletedAt' + description: Deletion time of the knowledge + description: + description: Description of the knowledge + type: string + embedding_model_id: + description: ID of the embedding model + type: string + enable_status: + description: Enable status of the knowledge + type: string + error_message: + description: Error message of the knowledge + type: string + file_hash: + description: File hash of the knowledge + type: string + file_name: + description: File name of the knowledge + type: string + file_path: + description: File path of the knowledge + type: string + file_size: + description: File size of the knowledge + type: integer + file_type: + description: File type of the knowledge + type: string + id: + description: Unique identifier of the knowledge + type: string + knowledge_base_id: + description: ID of the knowledge base + type: string + metadata: + description: Metadata of the knowledge + items: + type: integer + type: array + parse_status: + description: Parse status of the knowledge + type: string + processed_at: + description: Processed time of the knowledge + type: string + source: + description: Source of the knowledge + type: string + storage_size: + description: Storage size of the knowledge + type: integer + summary_status: + description: Summary status for async summary generation + type: string + tag_id: + description: Optional tag ID for categorization within a knowledge base + type: string + tenant_id: + description: Tenant ID + type: integer + title: + description: Title of the knowledge + type: string + type: + description: Type of the knowledge + type: string + updated_at: + description: Last updated time of the knowledge + type: string + type: object + github_com_Tencent_WeKnora_internal_types.KnowledgeBase: + properties: + chunk_count: + description: Chunk count (not stored in database, calculated on query) + type: integer + chunking_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ChunkingConfig' + description: Chunking configuration + cos_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.StorageConfig' + description: Storage config + created_at: + description: Creation time of the knowledge base + type: string + deleted_at: + allOf: + - $ref: '#/definitions/gorm.DeletedAt' + description: Deletion time of the knowledge base + description: + description: Description of the knowledge base + type: string + embedding_model_id: + description: ID of the embedding model + type: string + extract_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ExtractConfig' + description: Extract config + faq_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQConfig' + description: FAQConfig stores FAQ specific configuration such as indexing + strategy + id: + description: Unique identifier of the knowledge base + type: string + image_processing_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ImageProcessingConfig' + description: Image processing configuration + is_processing: + description: IsProcessing indicates if there is a processing import task (for + FAQ type knowledge bases) + type: boolean + is_temporary: + description: Whether this knowledge base is temporary (ephemeral) and should + be hidden from UI + type: boolean + knowledge_count: + description: Knowledge count (not stored in database, calculated on query) + type: integer + name: + description: Name of the knowledge base + type: string + processing_count: + description: ProcessingCount indicates the number of knowledge items being + processed (for document type knowledge bases) + type: integer + question_generation_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.QuestionGenerationConfig' + description: QuestionGenerationConfig stores question generation configuration + for document knowledge bases + summary_model_id: + description: Summary model ID + type: string + tenant_id: + description: Tenant ID + type: integer + type: + description: Type of the knowledge base (document, faq, etc.) + type: string + updated_at: + description: Last updated time of the knowledge base + type: string + vlm_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.VLMConfig' + description: VLM config + type: object + github_com_Tencent_WeKnora_internal_types.KnowledgeBaseConfig: + properties: + chunking_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ChunkingConfig' + description: Chunking configuration + faq_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQConfig' + description: FAQ configuration (only for FAQ type knowledge bases) + image_processing_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ImageProcessingConfig' + description: Image processing configuration + type: object + github_com_Tencent_WeKnora_internal_types.LoginRequest: + properties: + email: + type: string + password: + minLength: 6 + type: string + required: + - email + - password + type: object + github_com_Tencent_WeKnora_internal_types.LoginResponse: + properties: + message: + type: string + refresh_token: + type: string + success: + type: boolean + tenant: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant' + token: + type: string + user: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.User' + type: object + github_com_Tencent_WeKnora_internal_types.MCPAdvancedConfig: + properties: + retry_count: + description: 'Number of retries, default: 3' + type: integer + retry_delay: + description: 'Delay between retries in seconds, default: 1' + type: integer + timeout: + description: 'Timeout in seconds, default: 30' + type: integer + type: object + github_com_Tencent_WeKnora_internal_types.MCPAuthConfig: + properties: + api_key: + type: string + custom_headers: + additionalProperties: + type: string + type: object + token: + type: string + type: object + github_com_Tencent_WeKnora_internal_types.MCPEnvVars: + additionalProperties: + type: string + type: object + github_com_Tencent_WeKnora_internal_types.MCPHeaders: + additionalProperties: + type: string + type: object + github_com_Tencent_WeKnora_internal_types.MCPService: + properties: + advanced_config: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.MCPAdvancedConfig' + auth_config: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.MCPAuthConfig' + created_at: + type: string + deleted_at: + $ref: '#/definitions/gorm.DeletedAt' + description: + type: string + enabled: + type: boolean + env_vars: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.MCPEnvVars' + description: Environment variables for stdio + headers: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.MCPHeaders' + id: + type: string + name: + type: string + stdio_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.MCPStdioConfig' + description: Required for stdio transport + tenant_id: + type: integer + transport_type: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.MCPTransportType' + updated_at: + type: string + url: + description: 'Optional: required for SSE/HTTP Streamable' + type: string + type: object + github_com_Tencent_WeKnora_internal_types.MCPStdioConfig: + properties: + args: + description: Command arguments array + items: + type: string + type: array + command: + description: 'Command: "uvx" or "npx"' + type: string + type: object + github_com_Tencent_WeKnora_internal_types.MCPTransportType: + enum: + - sse + - http-streamable + - stdio + type: string + x-enum-comments: + MCPTransportHTTPStreamable: HTTP Streamable + MCPTransportSSE: Server-Sent Events + MCPTransportStdio: Stdio (Standard Input/Output) + x-enum-descriptions: + - Server-Sent Events + - HTTP Streamable + - Stdio (Standard Input/Output) + x-enum-varnames: + - MCPTransportSSE + - MCPTransportHTTPStreamable + - MCPTransportStdio + github_com_Tencent_WeKnora_internal_types.ManualKnowledgePayload: + properties: + content: + type: string + status: + type: string + title: + type: string + type: object + github_com_Tencent_WeKnora_internal_types.MatchType: + enum: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + type: integer + x-enum-comments: + MatchTypeParentChunk: 父Chunk匹配类型 + MatchTypeRelationChunk: 关系Chunk匹配类型 + MatchTypeWebSearch: 网络搜索匹配类型 + x-enum-descriptions: + - "" + - "" + - "" + - "" + - 父Chunk匹配类型 + - 关系Chunk匹配类型 + - "" + - 网络搜索匹配类型 + x-enum-varnames: + - MatchTypeEmbedding + - MatchTypeKeywords + - MatchTypeNearByChunk + - MatchTypeHistory + - MatchTypeParentChunk + - MatchTypeRelationChunk + - MatchTypeGraph + - MatchTypeWebSearch + github_com_Tencent_WeKnora_internal_types.Message: + properties: + agent_steps: + description: |- + Agent execution steps (only for assistant messages generated by agent) + This contains the detailed reasoning process and tool calls made by the agent + Stored for user history display, but NOT included in LLM context to avoid redundancy + items: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.AgentStep' + type: array + content: + description: Message text content + type: string + created_at: + description: Message creation timestamp + type: string + deleted_at: + allOf: + - $ref: '#/definitions/gorm.DeletedAt' + description: Soft delete timestamp + id: + description: Unique identifier for the message + type: string + is_completed: + description: Whether message generation is complete + type: boolean + knowledge_references: + description: References to knowledge chunks used in the response + items: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.SearchResult' + type: array + request_id: + description: Request identifier for tracking API requests + type: string + role: + description: 'Message role: "user", "assistant", "system"' + type: string + session_id: + description: ID of the session this message belongs to + type: string + updated_at: + description: Last update timestamp + type: string + type: object + github_com_Tencent_WeKnora_internal_types.ModelParameters: + properties: + api_key: + type: string + base_url: + type: string + embedding_parameters: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.EmbeddingParameters' + interface_type: + type: string + parameter_size: + description: Ollama model parameter size (e.g., "7B", "13B", "70B") + type: string + type: object + github_com_Tencent_WeKnora_internal_types.ModelSource: + enum: + - local + - remote + - aliyun + type: string + x-enum-comments: + ModelSourceAliyun: Aliyun DashScope model + ModelSourceLocal: Local model + ModelSourceRemote: Remote model + x-enum-descriptions: + - Local model + - Remote model + - Aliyun DashScope model + x-enum-varnames: + - ModelSourceLocal + - ModelSourceRemote + - ModelSourceAliyun + github_com_Tencent_WeKnora_internal_types.ModelType: + enum: + - Embedding + - Rerank + - KnowledgeQA + - VLLM + type: string + x-enum-comments: + ModelTypeEmbedding: Embedding model + ModelTypeKnowledgeQA: KnowledgeQA model + ModelTypeRerank: Rerank model + ModelTypeVLLM: VLLM model + x-enum-descriptions: + - Embedding model + - Rerank model + - KnowledgeQA model + - VLLM model + x-enum-varnames: + - ModelTypeEmbedding + - ModelTypeRerank + - ModelTypeKnowledgeQA + - ModelTypeVLLM + github_com_Tencent_WeKnora_internal_types.QuestionGenerationConfig: + properties: + enabled: + type: boolean + question_count: + description: 'Number of questions to generate per chunk (default: 3, max: + 10)' + type: integer + type: object + github_com_Tencent_WeKnora_internal_types.RegisterRequest: + properties: + email: + type: string + password: + minLength: 6 + type: string + username: + maxLength: 50 + minLength: 3 + type: string + required: + - email + - password + - username + type: object + github_com_Tencent_WeKnora_internal_types.RegisterResponse: + properties: + message: + type: string + success: + type: boolean + tenant: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant' + user: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.User' + type: object + github_com_Tencent_WeKnora_internal_types.RetrieverEngineParams: + properties: + retriever_engine_type: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverEngineType' + description: Retriever engine type + retriever_type: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverType' + description: Retriever type + type: object + github_com_Tencent_WeKnora_internal_types.RetrieverEngineType: + enum: + - postgres + - elasticsearch + - infinity + - elasticfaiss + - qdrant + type: string + x-enum-varnames: + - PostgresRetrieverEngineType + - ElasticsearchRetrieverEngineType + - InfinityRetrieverEngineType + - ElasticFaissRetrieverEngineType + - QdrantRetrieverEngineType + github_com_Tencent_WeKnora_internal_types.RetrieverEngines: + properties: + engines: + items: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverEngineParams' + type: array + type: object + github_com_Tencent_WeKnora_internal_types.RetrieverType: + enum: + - keywords + - vector + - websearch + type: string + x-enum-comments: + KeywordsRetrieverType: Keywords retriever + VectorRetrieverType: Vector retriever + WebSearchRetrieverType: Web search retriever + x-enum-descriptions: + - Keywords retriever + - Vector retriever + - Web search retriever + x-enum-varnames: + - KeywordsRetrieverType + - VectorRetrieverType + - WebSearchRetrieverType + github_com_Tencent_WeKnora_internal_types.SearchParams: + properties: + disable_keywords_match: + type: boolean + disable_vector_match: + type: boolean + keyword_threshold: + type: number + match_count: + type: integer + query_text: + type: string + vector_threshold: + type: number + type: object + github_com_Tencent_WeKnora_internal_types.SearchResult: + properties: + chunk_index: + description: Chunk index + type: integer + chunk_metadata: + description: ChunkMetadata stores chunk-level metadata (e.g., generated questions) + items: + type: integer + type: array + chunk_type: + description: Chunk 类型 + type: string + content: + description: Content + type: string + end_at: + description: End at + type: integer + id: + description: ID + type: string + image_info: + description: 图片信息 (JSON 格式) + type: string + knowledge_filename: + description: |- + Knowledge file name + Used for file type knowledge, contains the original file name + type: string + knowledge_id: + description: Knowledge ID + type: string + knowledge_source: + description: |- + Knowledge source + Used to indicate the source of the knowledge, such as "url" + type: string + knowledge_title: + description: Knowledge title + type: string + match_type: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.MatchType' + description: Match type + metadata: + additionalProperties: + type: string + description: Metadata + type: object + parent_chunk_id: + description: 父 Chunk ID + type: string + score: + description: Score + type: number + seq: + description: Seq + type: integer + start_at: + description: Start at + type: integer + sub_chunk_id: + description: SubChunkIndex + items: + type: string + type: array + type: object + github_com_Tencent_WeKnora_internal_types.Session: + properties: + agent_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.SessionAgentConfig' + description: Agent 配置(会话级别,仅存储enabled和knowledge_bases) + context_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ContextConfig' + description: 上下文管理配置(可选) + created_at: + type: string + deleted_at: + $ref: '#/definitions/gorm.DeletedAt' + description: + description: Description + type: string + embedding_top_k: + description: 向量召回TopK + type: integer + enable_rewrite: + description: 多轮改写开关 + type: boolean + fallback_response: + description: 固定回复内容 + type: string + fallback_strategy: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FallbackStrategy' + description: 兜底策略 + id: + description: ID + type: string + keyword_threshold: + description: 关键词召回阈值 + type: number + knowledge_base_id: + description: Strategy configuration + type: string + max_rounds: + description: 多轮保持轮数 + type: integer + rerank_model_id: + description: 排序模型ID + type: string + rerank_threshold: + description: 排序阈值 + type: number + rerank_top_k: + description: 排序TopK + type: integer + summary_model_id: + description: 总结模型ID + type: string + summary_parameters: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.SummaryConfig' + description: 总结模型参数 + tenant_id: + description: Tenant ID + type: integer + title: + description: Title + type: string + updated_at: + type: string + vector_threshold: + description: 向量召回阈值 + type: number + type: object + github_com_Tencent_WeKnora_internal_types.SessionAgentConfig: + properties: + agent_mode_enabled: + description: Whether agent mode is enabled for this session + type: boolean + knowledge_bases: + description: Accessible knowledge base IDs for this session + items: + type: string + type: array + web_search_enabled: + description: Whether web search is enabled for this session + type: boolean + type: object + github_com_Tencent_WeKnora_internal_types.StorageConfig: + properties: + app_id: + description: App ID + type: string + bucket_name: + description: Bucket Name + type: string + path_prefix: + description: Path Prefix + type: string + provider: + description: Provider + type: string + region: + description: Region + type: string + secret_id: + description: Secret ID + type: string + secret_key: + description: Secret Key + type: string + type: object + github_com_Tencent_WeKnora_internal_types.SummaryConfig: + properties: + context_template: + description: Context template + type: string + frequency_penalty: + description: Frequency penalty + type: number + max_completion_tokens: + description: Max completion tokens + type: integer + max_tokens: + description: Max tokens + type: integer + no_match_prefix: + description: No match prefix + type: string + presence_penalty: + description: Presence penalty + type: number + prompt: + description: Prompt + type: string + repeat_penalty: + description: Repeat penalty + type: number + seed: + description: Seed + type: integer + temperature: + description: Temperature + type: number + top_k: + description: TopK + type: integer + top_p: + description: TopP + type: number + type: object + github_com_Tencent_WeKnora_internal_types.Tenant: + properties: + agent_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.AgentConfig' + description: Global Agent configuration for this tenant (default for all sessions) + api_key: + description: API key + type: string + business: + description: Business + type: string + context_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ContextConfig' + description: Global Context configuration for this tenant (default for all + sessions) + conversation_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ConversationConfig' + description: Global Conversation configuration for this tenant (default for + normal mode sessions) + created_at: + description: Creation time + type: string + deleted_at: + allOf: + - $ref: '#/definitions/gorm.DeletedAt' + description: Deletion time + description: + description: Description + type: string + id: + description: ID + type: integer + name: + description: Name + type: string + retriever_engines: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.RetrieverEngines' + description: Retriever engines + status: + description: Status + type: string + storage_quota: + description: Storage quota (Bytes), default is 10GB, including vector, original + file, text, index, etc. + type: integer + storage_used: + description: Storage used (Bytes) + type: integer + updated_at: + description: Last updated time + type: string + web_search_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.WebSearchConfig' + description: Global WebSearch configuration for this tenant + type: object + github_com_Tencent_WeKnora_internal_types.ToolCall: + properties: + args: + additionalProperties: true + description: Tool arguments + type: object + duration: + description: Execution time in milliseconds + type: integer + id: + description: Function call ID from LLM + type: string + name: + description: Tool name + type: string + reflection: + description: Agent's reflection on this tool call result (if enabled) + type: string + result: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ToolResult' + description: Execution result (contains Output) + type: object + github_com_Tencent_WeKnora_internal_types.ToolResult: + properties: + data: + additionalProperties: true + description: Structured data for programmatic use + type: object + error: + description: Error message if execution failed + type: string + output: + description: Human-readable output + type: string + success: + description: Whether the tool executed successfully + type: boolean + type: object + github_com_Tencent_WeKnora_internal_types.User: + properties: + avatar: + description: Avatar URL of the user + type: string + can_access_all_tenants: + description: Whether the user can access all tenants (cross-tenant access) + type: boolean + created_at: + description: Creation time of the user + type: string + deleted_at: + allOf: + - $ref: '#/definitions/gorm.DeletedAt' + description: Deletion time of the user + email: + description: Email address of the user + type: string + id: + description: Unique identifier of the user + type: string + is_active: + description: Whether the user is active + type: boolean + tenant: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant' + description: Association relationship, not stored in the database + tenant_id: + description: Tenant ID that the user belongs to + type: integer + updated_at: + description: Last updated time of the user + type: string + username: + description: Username of the user + type: string + type: object + github_com_Tencent_WeKnora_internal_types.VLMConfig: + properties: + api_key: + description: API Key + type: string + base_url: + description: Base URL + type: string + enabled: + type: boolean + interface_type: + description: 'Interface Type: "ollama" or "openai"' + type: string + model_id: + type: string + model_name: + description: |- + 兼容老版本 + Model Name + type: string + type: object + github_com_Tencent_WeKnora_internal_types.WebSearchConfig: + properties: + api_key: + description: API密钥(如果需要) + type: string + blacklist: + description: 黑名单规则列表 + items: + type: string + type: array + compression_method: + description: 压缩方法:none, summary, extract, rag + type: string + document_fragments: + description: 文档片段数量(用于RAG压缩) + type: integer + embedding_dimension: + description: 嵌入维度(用于RAG压缩) + type: integer + embedding_model_id: + description: RAG压缩相关配置 + type: string + include_date: + description: 是否包含日期 + type: boolean + max_results: + description: 最大搜索结果数 + type: integer + provider: + description: 搜索引擎提供商ID + type: string + rerank_model_id: + description: 重排模型ID(用于RAG压缩) + type: string + type: object + gorm.DeletedAt: + properties: + time: + type: string + valid: + description: Valid is true if Time is not NULL + type: boolean + type: object + internal_handler.CopyKnowledgeBaseRequest: + properties: + source_id: + type: string + target_id: + type: string + required: + - source_id + type: object + internal_handler.CreateModelRequest: + properties: + description: + type: string + name: + type: string + parameters: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ModelParameters' + source: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ModelSource' + type: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ModelType' + required: + - name + - parameters + - source + - type + type: object + internal_handler.EvaluationRequest: + properties: + chat_id: + description: ID of chat model to use + type: string + dataset_id: + description: ID of dataset to evaluate + type: string + knowledge_base_id: + description: ID of knowledge base to use + type: string + rerank_id: + description: ID of rerank model to use + type: string + type: object + internal_handler.FabriTextRequest: + properties: + llm_config: + $ref: '#/definitions/internal_handler.LLMConfig' + tags: + items: + type: string + type: array + type: object + internal_handler.GetSystemInfoResponse: + properties: + build_time: + type: string + commit_id: + type: string + go_version: + type: string + graph_database_engine: + type: string + keyword_index_engine: + type: string + minio_enabled: + type: boolean + vector_store_engine: + type: string + version: + type: string + type: object + internal_handler.KBModelConfigRequest: + properties: + documentSplitting: + description: 文档分块配置 + properties: + chunkOverlap: + type: integer + chunkSize: + type: integer + separators: + items: + type: string + type: array + type: object + embeddingModelId: + type: string + llmModelId: + type: string + multimodal: + description: 多模态配置 + properties: + cos: + properties: + appId: + type: string + bucketName: + type: string + pathPrefix: + type: string + region: + type: string + secretId: + type: string + secretKey: + type: string + type: object + enabled: + type: boolean + minio: + properties: + bucketName: + type: string + pathPrefix: + type: string + useSSL: + type: boolean + type: object + storageType: + description: '"cos" or "minio"' + type: string + type: object + nodeExtract: + description: 知识图谱配置 + properties: + enabled: + type: boolean + nodes: + items: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.GraphNode' + type: array + relations: + items: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.GraphRelation' + type: array + tags: + items: + type: string + type: array + text: + type: string + type: object + questionGeneration: + description: 问题生成配置 + properties: + enabled: + type: boolean + questionCount: + type: integer + type: object + vlm_config: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.VLMConfig' + required: + - embeddingModelId + - llmModelId + type: object + internal_handler.LLMConfig: + properties: + api_key: + type: string + base_url: + type: string + model_name: + type: string + source: + type: string + type: object + internal_handler.RemoteModelCheckRequest: + properties: + apiKey: + type: string + baseUrl: + type: string + modelName: + type: string + required: + - baseUrl + - modelName + type: object + internal_handler.TextRelationExtractionRequest: + properties: + llm_config: + $ref: '#/definitions/internal_handler.LLMConfig' + tags: + items: + type: string + type: array + text: + type: string + required: + - tags + - text + type: object + internal_handler.UpdateChunkRequest: + properties: + chunk_index: + type: integer + content: + type: string + embedding: + items: + type: number + type: array + end_at: + type: integer + image_info: + type: string + is_enabled: + type: boolean + start_at: + type: integer + type: object + internal_handler.UpdateKnowledgeBaseRequest: + properties: + config: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.KnowledgeBaseConfig' + description: + type: string + name: + type: string + required: + - config + - name + type: object + internal_handler.UpdateModelRequest: + properties: + description: + type: string + name: + type: string + parameters: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ModelParameters' + source: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ModelSource' + type: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ModelType' + type: object + internal_handler_session.CreateKnowledgeQARequest: + properties: + agent_enabled: + description: Whether agent mode is enabled for this request + type: boolean + knowledge_base_ids: + description: Selected knowledge base ID for this request + items: + type: string + type: array + query: + description: Query text for knowledge base search + type: string + summary_model_id: + description: Optional summary model ID for this request (overrides session + default) + type: string + web_search_enabled: + description: Whether web search is enabled for this request + type: boolean + required: + - query + type: object + internal_handler_session.CreateSessionRequest: + properties: + agent_config: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.SessionAgentConfig' + description: 'Agent configuration (optional, session-level config only: enabled + and knowledge_bases)' + knowledge_base_id: + description: ID of the associated knowledge base (optional, can be set/changed + during queries) + type: string + session_strategy: + allOf: + - $ref: '#/definitions/internal_handler_session.SessionStrategy' + description: Session strategy configuration + type: object + internal_handler_session.GenerateTitleRequest: + properties: + messages: + description: Messages to use as context for title generation + items: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.Message' + type: array + required: + - messages + type: object + internal_handler_session.SearchKnowledgeRequest: + properties: + knowledge_base_id: + description: ID of the knowledge base to search + type: string + query: + description: Query text to search for + type: string + required: + - knowledge_base_id + - query + type: object + internal_handler_session.SessionStrategy: + properties: + embedding_top_k: + description: Number of top results to retrieve from vector search + type: integer + enable_rewrite: + description: Whether to enable query rewrite for multi-round conversations + type: boolean + fallback_response: + description: Fixed response content for fallback + type: string + fallback_strategy: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FallbackStrategy' + description: Strategy to use when no relevant knowledge is found + keyword_threshold: + description: Threshold for keyword-based retrieval + type: number + max_rounds: + description: Maximum number of conversation rounds to maintain + type: integer + no_match_prefix: + description: Prefix for responses when no match is found + type: string + rerank_model_id: + description: ID of the model used for reranking results + type: string + rerank_threshold: + description: Threshold for reranking results + type: number + rerank_top_k: + description: Number of top results after reranking + type: integer + summary_model_id: + description: ID of the model used for summarization + type: string + summary_parameters: + allOf: + - $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.SummaryConfig' + description: Parameters for the summary model + vector_threshold: + description: Threshold for vector-based retrieval + type: number + type: object + internal_handler_session.StopSessionRequest: + properties: + message_id: + type: string + required: + - message_id + type: object +host: localhost:8080 +info: + contact: + name: WeKnora Github + url: https://github.com/Tencent/WeKnora + description: WeKnora 知识库管理系统 API 文档 + termsOfService: http://swagger.io/terms/ + title: WeKnora API + version: "1.0" +paths: + /api/v1/web-search/providers: + get: + consumes: + - application/json + description: Returns the list of available web search providers from configuration + produces: + - application/json + responses: + "200": + description: List of providers + schema: + additionalProperties: true + type: object + summary: Get available web search providers + tags: + - web-search + /auth/change-password: + post: + consumes: + - application/json + description: 修改当前用户的登录密码 + parameters: + - description: 密码修改请求 + in: body + name: request + required: true + schema: + properties: + new_password: + type: string + old_password: + type: string + type: object + produces: + - application/json + responses: + "200": + description: 修改成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 修改密码 + tags: + - 认证 + /auth/login: + post: + consumes: + - application/json + description: 用户登录并获取访问令牌 + parameters: + - description: 登录请求参数 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.LoginRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.LoginResponse' + "401": + description: 认证失败 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + summary: 用户登录 + tags: + - 认证 + /auth/logout: + post: + consumes: + - application/json + description: 撤销当前访问令牌并登出 + produces: + - application/json + responses: + "200": + description: 登出成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 用户登出 + tags: + - 认证 + /auth/me: + get: + consumes: + - application/json + description: 获取当前登录用户的详细信息 + produces: + - application/json + responses: + "200": + description: 用户信息 + schema: + additionalProperties: true + type: object + "401": + description: 未授权 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取当前用户信息 + tags: + - 认证 + /auth/refresh: + post: + consumes: + - application/json + description: 使用刷新令牌获取新的访问令牌 + parameters: + - description: 刷新令牌 + in: body + name: request + required: true + schema: + properties: + refreshToken: + type: string + type: object + produces: + - application/json + responses: + "200": + description: 新令牌 + schema: + additionalProperties: true + type: object + "401": + description: 令牌无效 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + summary: 刷新令牌 + tags: + - 认证 + /auth/register: + post: + consumes: + - application/json + description: 注册新用户账号 + parameters: + - description: 注册请求参数 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.RegisterRequest' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.RegisterResponse' + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + summary: 用户注册 + tags: + - 认证 + /auth/validate: + get: + consumes: + - application/json + description: 验证访问令牌是否有效 + produces: + - application/json + responses: + "200": + description: 令牌有效 + schema: + additionalProperties: true + type: object + "401": + description: 令牌无效 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 验证令牌 + tags: + - 认证 + /chunks/{knowledge_id}: + delete: + consumes: + - application/json + description: 删除指定知识下的所有分块 + parameters: + - description: 知识ID + in: path + name: knowledge_id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 删除知识下所有分块 + tags: + - 分块管理 + get: + consumes: + - application/json + description: 获取指定知识下的所有分块列表,支持分页 + parameters: + - description: 知识ID + in: path + name: knowledge_id + required: true + type: string + - default: 1 + description: 页码 + in: query + name: page + type: integer + - default: 10 + description: 每页数量 + in: query + name: page_size + type: integer + produces: + - application/json + responses: + "200": + description: 分块列表 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取知识分块列表 + tags: + - 分块管理 + /chunks/{knowledge_id}/{id}: + delete: + consumes: + - application/json + description: 删除指定的分块 + parameters: + - description: 知识ID + in: path + name: knowledge_id + required: true + type: string + - description: 分块ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "404": + description: 分块不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 删除分块 + tags: + - 分块管理 + put: + consumes: + - application/json + description: 更新指定分块的内容和属性 + parameters: + - description: 知识ID + in: path + name: knowledge_id + required: true + type: string + - description: 分块ID + in: path + name: id + required: true + type: string + - description: 更新请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler.UpdateChunkRequest' + produces: + - application/json + responses: + "200": + description: 更新后的分块 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "404": + description: 分块不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新分块 + tags: + - 分块管理 + /chunks/by-id/{id}: + get: + consumes: + - application/json + description: 仅通过分块ID获取分块详情(不需要knowledge_id) + parameters: + - description: 分块ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 分块详情 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "404": + description: 分块不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 通过ID获取分块 + tags: + - 分块管理 + /chunks/by-id/{id}/questions: + delete: + consumes: + - application/json + description: 删除分块中生成的问题 + parameters: + - description: 分块ID + in: path + name: id + required: true + type: string + - description: 问题ID + in: body + name: request + required: true + schema: + properties: + question_id: + type: string + type: object + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "404": + description: 分块不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 删除生成的问题 + tags: + - 分块管理 + /evaluation/: + get: + consumes: + - application/json + description: 根据任务ID获取评估结果 + parameters: + - description: 评估任务ID + in: query + name: task_id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 评估结果 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取评估结果 + tags: + - 评估 + post: + consumes: + - application/json + description: 对知识库进行评估测试 + parameters: + - description: 评估请求参数 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler.EvaluationRequest' + produces: + - application/json + responses: + "200": + description: 评估任务 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 执行评估 + tags: + - 评估 + /initialization/extract/relations: + post: + consumes: + - application/json + description: 从文本中提取实体和关系 + parameters: + - description: 提取请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler.TextRelationExtractionRequest' + produces: + - application/json + responses: + "200": + description: 提取结果 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 提取文本关系 + tags: + - 初始化 + /initialization/fabri/tag: + get: + consumes: + - application/json + description: 随机生成一组标签 + produces: + - application/json + responses: + "200": + description: 生成的标签 + schema: + additionalProperties: true + type: object + summary: 生成随机标签 + tags: + - 初始化 + /initialization/fabri/text: + post: + consumes: + - application/json + description: 根据标签生成示例文本 + parameters: + - description: 生成请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler.FabriTextRequest' + produces: + - application/json + responses: + "200": + description: 生成的文本 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 生成示例文本 + tags: + - 初始化 + /initialization/kb/{kbId}: + post: + consumes: + - application/json + description: 根据知识库ID执行完整配置更新 + parameters: + - description: 知识库ID + in: path + name: kbId + required: true + type: string + - description: 初始化请求 + in: body + name: request + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: 初始化成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 初始化知识库配置 + tags: + - 初始化 + /initialization/kb/{kbId}/config: + get: + consumes: + - application/json + description: 根据知识库ID获取当前配置信息 + parameters: + - description: 知识库ID + in: path + name: kbId + required: true + type: string + produces: + - application/json + responses: + "200": + description: 配置信息 + schema: + additionalProperties: true + type: object + "404": + description: 知识库不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取知识库配置 + tags: + - 初始化 + put: + consumes: + - application/json + description: 根据知识库ID更新模型和分块配置 + parameters: + - description: 知识库ID + in: path + name: kbId + required: true + type: string + - description: 配置请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler.KBModelConfigRequest' + produces: + - application/json + responses: + "200": + description: 更新成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "404": + description: 知识库不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新知识库配置 + tags: + - 初始化 + /initialization/models/embedding/test: + post: + consumes: + - application/json + description: 测试Embedding接口是否可用并返回向量维度 + parameters: + - description: Embedding测试请求 + in: body + name: request + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: 测试结果 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 测试Embedding模型 + tags: + - 初始化 + /initialization/models/remote/check: + post: + consumes: + - application/json + description: 检查远程API模型连接是否正常 + parameters: + - description: 模型检查请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler.RemoteModelCheckRequest' + produces: + - application/json + responses: + "200": + description: 检查结果 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 检查远程模型 + tags: + - 初始化 + /initialization/models/rerank/check: + post: + consumes: + - application/json + description: 检查Rerank模型连接和功能是否正常 + parameters: + - description: Rerank检查请求 + in: body + name: request + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: 检查结果 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 检查Rerank模型 + tags: + - 初始化 + /initialization/multimodal/test: + post: + consumes: + - multipart/form-data + description: 上传图片测试多模态处理功能 + parameters: + - description: 测试图片 + in: formData + name: image + required: true + type: file + - description: VLM模型名称 + in: formData + name: vlm_model + required: true + type: string + - description: VLM Base URL + in: formData + name: vlm_base_url + required: true + type: string + - description: VLM API Key + in: formData + name: vlm_api_key + type: string + - description: VLM接口类型 + in: formData + name: vlm_interface_type + type: string + - description: 存储类型(cos/minio) + in: formData + name: storage_type + required: true + type: string + produces: + - application/json + responses: + "200": + description: 测试结果 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 测试多模态功能 + tags: + - 初始化 + /initialization/ollama/download/{taskId}: + get: + consumes: + - application/json + description: 获取Ollama模型下载任务的进度 + parameters: + - description: 任务ID + in: path + name: taskId + required: true + type: string + produces: + - application/json + responses: + "200": + description: 下载进度 + schema: + additionalProperties: true + type: object + "404": + description: 任务不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取下载进度 + tags: + - 初始化 + /initialization/ollama/download/tasks: + get: + consumes: + - application/json + description: 列出所有Ollama模型下载任务 + produces: + - application/json + responses: + "200": + description: 任务列表 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 列出下载任务 + tags: + - 初始化 + /initialization/ollama/models: + get: + consumes: + - application/json + description: 列出已安装的Ollama模型 + produces: + - application/json + responses: + "200": + description: 模型列表 + schema: + additionalProperties: true + type: object + "500": + description: 服务器错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 列出Ollama模型 + tags: + - 初始化 + /initialization/ollama/models/check: + post: + consumes: + - application/json + description: 检查指定的Ollama模型是否已安装 + parameters: + - description: 模型名称列表 + in: body + name: request + required: true + schema: + properties: + models: + items: + type: string + type: array + type: object + produces: + - application/json + responses: + "200": + description: 模型状态 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 检查Ollama模型状态 + tags: + - 初始化 + /initialization/ollama/models/download: + post: + consumes: + - application/json + description: 异步下载指定的Ollama模型 + parameters: + - description: 模型名称 + in: body + name: request + required: true + schema: + properties: + modelName: + type: string + type: object + produces: + - application/json + responses: + "200": + description: 下载任务信息 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 下载Ollama模型 + tags: + - 初始化 + /initialization/ollama/status: + get: + consumes: + - application/json + description: 检查Ollama服务是否可用 + produces: + - application/json + responses: + "200": + description: Ollama状态 + schema: + additionalProperties: true + type: object + summary: 检查Ollama服务状态 + tags: + - 初始化 + /knowledge-bases: + get: + consumes: + - application/json + description: 获取当前租户的所有知识库 + produces: + - application/json + responses: + "200": + description: 知识库列表 + schema: + additionalProperties: true + type: object + "500": + description: 服务器错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取知识库列表 + tags: + - 知识库 + post: + consumes: + - application/json + description: 创建新的知识库 + parameters: + - description: 知识库信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.KnowledgeBase' + produces: + - application/json + responses: + "201": + description: 创建的知识库 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 创建知识库 + tags: + - 知识库 + /knowledge-bases/{id}: + delete: + consumes: + - application/json + description: 删除指定的知识库及其所有内容 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 删除知识库 + tags: + - 知识库 + get: + consumes: + - application/json + description: 根据ID获取知识库详情 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 知识库详情 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "404": + description: 知识库不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取知识库详情 + tags: + - 知识库 + put: + consumes: + - application/json + description: 更新知识库的名称、描述和配置 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 更新请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler.UpdateKnowledgeBaseRequest' + produces: + - application/json + responses: + "200": + description: 更新后的知识库 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新知识库 + tags: + - 知识库 + /knowledge-bases/{id}/faq/entries: + delete: + consumes: + - application/json + description: 批量删除指定的FAQ条目 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 要删除的FAQ ID列表 + in: body + name: request + required: true + schema: + properties: + ids: + items: + type: string + type: array + type: object + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 批量删除FAQ条目 + tags: + - FAQ管理 + get: + consumes: + - application/json + description: 获取知识库下的FAQ条目列表,支持分页和筛选 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 页码 + in: query + name: page + type: integer + - description: 每页数量 + in: query + name: page_size + type: integer + - description: 标签ID筛选 + in: query + name: tag_id + type: string + - description: 关键词搜索 + in: query + name: keyword + type: string + produces: + - application/json + responses: + "200": + description: FAQ列表 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取FAQ条目列表 + tags: + - FAQ管理 + post: + consumes: + - application/json + description: 异步批量更新或插入FAQ条目 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 批量操作请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQBatchUpsertPayload' + produces: + - application/json + responses: + "200": + description: 任务ID + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 批量更新/插入FAQ条目 + tags: + - FAQ管理 + /knowledge-bases/{id}/faq/entries/{entry_id}: + put: + consumes: + - application/json + description: 更新指定的FAQ条目 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: FAQ条目ID + in: path + name: entry_id + required: true + type: string + - description: FAQ条目 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryPayload' + produces: + - application/json + responses: + "200": + description: 更新成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新FAQ条目 + tags: + - FAQ管理 + /knowledge-bases/{id}/faq/entries/export: + get: + consumes: + - application/json + description: 将所有FAQ条目导出为CSV文件 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + produces: + - text/csv + responses: + "200": + description: CSV文件 + schema: + type: file + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 导出FAQ条目 + tags: + - FAQ管理 + /knowledge-bases/{id}/faq/entries/fields: + put: + consumes: + - application/json + description: 批量更新FAQ条目的多个字段(is_enabled, is_recommended, tag_id) + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 字段更新请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryFieldsBatchUpdate' + produces: + - application/json + responses: + "200": + description: 更新成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 批量更新FAQ字段 + tags: + - FAQ管理 + /knowledge-bases/{id}/faq/entries/tags: + put: + consumes: + - application/json + description: 批量更新FAQ条目的标签 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 标签更新请求 + in: body + name: request + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: 更新成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 批量更新FAQ标签 + tags: + - FAQ管理 + /knowledge-bases/{id}/faq/entry: + post: + consumes: + - application/json + description: 同步创建单个FAQ条目 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: FAQ条目 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQEntryPayload' + produces: + - application/json + responses: + "200": + description: 创建的FAQ条目 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 创建单个FAQ条目 + tags: + - FAQ管理 + /knowledge-bases/{id}/faq/search: + post: + consumes: + - application/json + description: 使用混合搜索在FAQ中搜索 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 搜索请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.FAQSearchRequest' + produces: + - application/json + responses: + "200": + description: 搜索结果 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 搜索FAQ + tags: + - FAQ管理 + /knowledge-bases/{id}/hybrid-search: + get: + consumes: + - application/json + description: 在知识库中执行向量和关键词混合搜索 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 搜索参数 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.SearchParams' + produces: + - application/json + responses: + "200": + description: 搜索结果 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 混合搜索 + tags: + - 知识库 + /knowledge-bases/{id}/knowledge: + get: + consumes: + - application/json + description: 获取知识库下的知识列表,支持分页和筛选 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 页码 + in: query + name: page + type: integer + - description: 每页数量 + in: query + name: page_size + type: integer + - description: 标签ID筛选 + in: query + name: tag_id + type: string + - description: 关键词搜索 + in: query + name: keyword + type: string + - description: 文件类型筛选 + in: query + name: file_type + type: string + produces: + - application/json + responses: + "200": + description: 知识列表 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取知识列表 + tags: + - 知识管理 + /knowledge-bases/{id}/knowledge/file: + post: + consumes: + - multipart/form-data + description: 上传文件并创建知识条目 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 上传的文件 + in: formData + name: file + required: true + type: file + - description: 自定义文件名 + in: formData + name: fileName + type: string + - description: 元数据JSON + in: formData + name: metadata + type: string + - description: 启用多模态处理 + in: formData + name: enable_multimodel + type: boolean + produces: + - application/json + responses: + "200": + description: 创建的知识 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "409": + description: 文件重复 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 从文件创建知识 + tags: + - 知识管理 + /knowledge-bases/{id}/knowledge/manual: + post: + consumes: + - application/json + description: 手工录入Markdown格式的知识内容 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 手工知识内容 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ManualKnowledgePayload' + produces: + - application/json + responses: + "200": + description: 创建的知识 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 手工创建知识 + tags: + - 知识管理 + /knowledge-bases/{id}/knowledge/url: + post: + consumes: + - application/json + description: 从指定URL抓取内容并创建知识条目 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: URL请求 + in: body + name: request + required: true + schema: + properties: + enable_multimodel: + type: boolean + title: + type: string + url: + type: string + type: object + produces: + - application/json + responses: + "201": + description: 创建的知识 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "409": + description: URL重复 + schema: + additionalProperties: true + type: object + security: + - Bearer: [] + summary: 从URL创建知识 + tags: + - 知识管理 + /knowledge-bases/{id}/tags: + get: + consumes: + - application/json + description: 获取知识库下的所有标签及统计信息 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 页码 + in: query + name: page + type: integer + - description: 每页数量 + in: query + name: page_size + type: integer + - description: 关键词搜索 + in: query + name: keyword + type: string + produces: + - application/json + responses: + "200": + description: 标签列表 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取标签列表 + tags: + - 标签管理 + post: + consumes: + - application/json + description: 在知识库下创建新标签 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 标签信息 + in: body + name: request + required: true + schema: + properties: + color: + type: string + name: + type: string + sort_order: + type: integer + type: object + produces: + - application/json + responses: + "200": + description: 创建的标签 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 创建标签 + tags: + - 标签管理 + /knowledge-bases/{id}/tags/{tag_id}: + delete: + consumes: + - application/json + description: 删除标签,可使用force=true强制删除被引用的标签 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 标签ID + in: path + name: tag_id + required: true + type: string + - description: 强制删除 + in: query + name: force + type: boolean + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 删除标签 + tags: + - 标签管理 + put: + consumes: + - application/json + description: 更新标签信息 + parameters: + - description: 知识库ID + in: path + name: id + required: true + type: string + - description: 标签ID + in: path + name: tag_id + required: true + type: string + - description: 标签更新信息 + in: body + name: request + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: 更新后的标签 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新标签 + tags: + - 标签管理 + /knowledge-bases/copy: + post: + consumes: + - application/json + description: 将一个知识库的内容复制到另一个知识库 + parameters: + - description: 复制请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler.CopyKnowledgeBaseRequest' + produces: + - application/json + responses: + "200": + description: 复制成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 复制知识库 + tags: + - 知识库 + /knowledge/{id}: + delete: + consumes: + - application/json + description: 根据ID删除知识条目 + parameters: + - description: 知识ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 删除知识 + tags: + - 知识管理 + get: + consumes: + - application/json + description: 根据ID获取知识条目详情 + parameters: + - description: 知识ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 知识详情 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "404": + description: 知识不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取知识详情 + tags: + - 知识管理 + put: + consumes: + - application/json + description: 更新知识条目信息 + parameters: + - description: 知识ID + in: path + name: id + required: true + type: string + - description: 知识信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.Knowledge' + produces: + - application/json + responses: + "200": + description: 更新成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新知识 + tags: + - 知识管理 + /knowledge/{id}/download: + get: + consumes: + - application/json + description: 下载知识条目关联的原始文件 + parameters: + - description: 知识ID + in: path + name: id + required: true + type: string + produces: + - application/octet-stream + responses: + "200": + description: 文件内容 + schema: + type: file + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 下载知识文件 + tags: + - 知识管理 + /knowledge/batch: + get: + consumes: + - application/json + description: 根据ID列表批量获取知识条目 + parameters: + - collectionFormat: csv + description: 知识ID列表 + in: query + items: + type: string + name: ids + required: true + type: array + produces: + - application/json + responses: + "200": + description: 知识列表 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 批量获取知识 + tags: + - 知识管理 + /knowledge/image/{id}/{chunk_id}: + put: + consumes: + - application/json + description: 更新知识分块的图像信息 + parameters: + - description: 知识ID + in: path + name: id + required: true + type: string + - description: 分块ID + in: path + name: chunk_id + required: true + type: string + - description: 图像信息 + in: body + name: request + required: true + schema: + properties: + image_info: + type: string + type: object + produces: + - application/json + responses: + "200": + description: 更新成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新图像信息 + tags: + - 知识管理 + /knowledge/manual/{id}: + put: + consumes: + - application/json + description: 更新手工录入的Markdown知识内容 + parameters: + - description: 知识ID + in: path + name: id + required: true + type: string + - description: 手工知识内容 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.ManualKnowledgePayload' + produces: + - application/json + responses: + "200": + description: 更新后的知识 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新手工知识 + tags: + - 知识管理 + /knowledge/tags: + put: + consumes: + - application/json + description: 批量更新知识条目的标签 + parameters: + - description: 标签更新请求 + in: body + name: request + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: 更新成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 批量更新知识标签 + tags: + - 知识管理 + /mcp-services: + get: + consumes: + - application/json + description: 获取当前租户的所有MCP服务 + produces: + - application/json + responses: + "200": + description: MCP服务列表 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取MCP服务列表 + tags: + - MCP服务 + post: + consumes: + - application/json + description: 创建新的MCP服务配置 + parameters: + - description: MCP服务配置 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.MCPService' + produces: + - application/json + responses: + "200": + description: 创建的MCP服务 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 创建MCP服务 + tags: + - MCP服务 + /mcp-services/{id}: + delete: + consumes: + - application/json + description: 删除指定的MCP服务 + parameters: + - description: MCP服务ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "500": + description: 服务器错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 删除MCP服务 + tags: + - MCP服务 + get: + consumes: + - application/json + description: 根据ID获取MCP服务详情 + parameters: + - description: MCP服务ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: MCP服务详情 + schema: + additionalProperties: true + type: object + "404": + description: 服务不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取MCP服务详情 + tags: + - MCP服务 + put: + consumes: + - application/json + description: 更新MCP服务配置 + parameters: + - description: MCP服务ID + in: path + name: id + required: true + type: string + - description: 更新字段 + in: body + name: request + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: 更新后的MCP服务 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新MCP服务 + tags: + - MCP服务 + /mcp-services/{id}/resources: + get: + consumes: + - application/json + description: 获取MCP服务提供的资源列表 + parameters: + - description: MCP服务ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 资源列表 + schema: + additionalProperties: true + type: object + "500": + description: 服务器错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取MCP服务资源列表 + tags: + - MCP服务 + /mcp-services/{id}/test: + post: + consumes: + - application/json + description: 测试MCP服务是否可以正常连接 + parameters: + - description: MCP服务ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 测试结果 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 测试MCP服务连接 + tags: + - MCP服务 + /mcp-services/{id}/tools: + get: + consumes: + - application/json + description: 获取MCP服务提供的工具列表 + parameters: + - description: MCP服务ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 工具列表 + schema: + additionalProperties: true + type: object + "500": + description: 服务器错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取MCP服务工具列表 + tags: + - MCP服务 + /messages/{session_id}/{id}: + delete: + consumes: + - application/json + description: 从会话中删除指定消息 + parameters: + - description: 会话ID + in: path + name: session_id + required: true + type: string + - description: 消息ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "500": + description: 服务器错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 删除消息 + tags: + - 消息 + /messages/{session_id}/load: + get: + consumes: + - application/json + description: 加载会话的消息历史,支持分页和时间筛选 + parameters: + - description: 会话ID + in: path + name: session_id + required: true + type: string + - default: 20 + description: 返回数量 + in: query + name: limit + type: integer + - description: 在此时间之前的消息(RFC3339Nano格式) + in: query + name: before_time + type: string + produces: + - application/json + responses: + "200": + description: 消息列表 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 加载消息历史 + tags: + - 消息 + /models: + get: + consumes: + - application/json + description: 获取当前租户的所有模型 + produces: + - application/json + responses: + "200": + description: 模型列表 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取模型列表 + tags: + - 模型管理 + post: + consumes: + - application/json + description: 创建新的模型配置 + parameters: + - description: 模型信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler.CreateModelRequest' + produces: + - application/json + responses: + "201": + description: 创建的模型 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 创建模型 + tags: + - 模型管理 + /models/{id}: + delete: + consumes: + - application/json + description: 删除指定的模型 + parameters: + - description: 模型ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "404": + description: 模型不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 删除模型 + tags: + - 模型管理 + get: + consumes: + - application/json + description: 根据ID获取模型详情 + parameters: + - description: 模型ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 模型详情 + schema: + additionalProperties: true + type: object + "404": + description: 模型不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取模型详情 + tags: + - 模型管理 + put: + consumes: + - application/json + description: 更新模型配置信息 + parameters: + - description: 模型ID + in: path + name: id + required: true + type: string + - description: 更新信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler.UpdateModelRequest' + produces: + - application/json + responses: + "200": + description: 更新后的模型 + schema: + additionalProperties: true + type: object + "404": + description: 模型不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新模型 + tags: + - 模型管理 + /sessions: + get: + consumes: + - application/json + description: 获取当前租户的会话列表,支持分页 + parameters: + - description: 页码 + in: query + name: page + type: integer + - description: 每页数量 + in: query + name: page_size + type: integer + produces: + - application/json + responses: + "200": + description: 会话列表 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取会话列表 + tags: + - 会话 + post: + consumes: + - application/json + description: 创建新的对话会话 + parameters: + - description: 会话创建请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler_session.CreateSessionRequest' + produces: + - application/json + responses: + "201": + description: 创建的会话 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 创建会话 + tags: + - 会话 + /sessions/{id}: + delete: + consumes: + - application/json + description: 删除指定的会话 + parameters: + - description: 会话ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "404": + description: 会话不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 删除会话 + tags: + - 会话 + get: + consumes: + - application/json + description: 根据ID获取会话详情 + parameters: + - description: 会话ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 会话详情 + schema: + additionalProperties: true + type: object + "404": + description: 会话不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取会话详情 + tags: + - 会话 + put: + consumes: + - application/json + description: 更新会话属性 + parameters: + - description: 会话ID + in: path + name: id + required: true + type: string + - description: 会话信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.Session' + produces: + - application/json + responses: + "200": + description: 更新后的会话 + schema: + additionalProperties: true + type: object + "404": + description: 会话不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新会话 + tags: + - 会话 + /sessions/{session_id}/agent-qa: + post: + consumes: + - application/json + description: 基于Agent的智能问答,支持多轮对话和SSE流式响应 + parameters: + - description: 会话ID + in: path + name: session_id + required: true + type: string + - description: 问答请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler_session.CreateKnowledgeQARequest' + produces: + - text/event-stream + responses: + "200": + description: 问答结果(SSE流) + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: Agent问答 + tags: + - 问答 + /sessions/{session_id}/continue: + get: + consumes: + - application/json + description: 继续获取正在进行的流式响应 + parameters: + - description: 会话ID + in: path + name: session_id + required: true + type: string + - description: 消息ID + in: query + name: message_id + required: true + type: string + produces: + - text/event-stream + responses: + "200": + description: 流式响应 + schema: + additionalProperties: true + type: object + "404": + description: 会话或消息不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 继续流式响应 + tags: + - 问答 + /sessions/{session_id}/knowledge-qa: + post: + consumes: + - application/json + description: 基于知识库的问答(使用LLM总结),支持SSE流式响应 + parameters: + - description: 会话ID + in: path + name: session_id + required: true + type: string + - description: 问答请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler_session.CreateKnowledgeQARequest' + produces: + - text/event-stream + responses: + "200": + description: 问答结果(SSE流) + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 知识问答 + tags: + - 问答 + /sessions/{session_id}/stop: + post: + consumes: + - application/json + description: 停止当前正在进行的生成任务 + parameters: + - description: 会话ID + in: path + name: session_id + required: true + type: string + - description: 停止请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler_session.StopSessionRequest' + produces: + - application/json + responses: + "200": + description: 停止成功 + schema: + additionalProperties: true + type: object + "404": + description: 会话或消息不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 停止生成 + tags: + - 问答 + /sessions/{session_id}/title: + post: + consumes: + - application/json + description: 根据消息内容自动生成会话标题 + parameters: + - description: 会话ID + in: path + name: session_id + required: true + type: string + - description: 生成请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler_session.GenerateTitleRequest' + produces: + - application/json + responses: + "200": + description: 生成的标题 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 生成会话标题 + tags: + - 会话 + /sessions/search: + post: + consumes: + - application/json + description: 在知识库中搜索(不使用LLM总结) + parameters: + - description: 搜索请求 + in: body + name: request + required: true + schema: + $ref: '#/definitions/internal_handler_session.SearchKnowledgeRequest' + produces: + - application/json + responses: + "200": + description: 搜索结果 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 知识搜索 + tags: + - 问答 + /system/info: + get: + consumes: + - application/json + description: 获取系统版本、构建信息和引擎配置 + produces: + - application/json + responses: + "200": + description: 系统信息 + schema: + $ref: '#/definitions/internal_handler.GetSystemInfoResponse' + summary: 获取系统信息 + tags: + - 系统 + /tenants: + get: + consumes: + - application/json + description: 获取当前用户可访问的租户列表 + produces: + - application/json + responses: + "200": + description: 租户列表 + schema: + additionalProperties: true + type: object + "500": + description: 服务器错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取租户列表 + tags: + - 租户管理 + post: + consumes: + - application/json + description: 创建新的租户 + parameters: + - description: 租户信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant' + produces: + - application/json + responses: + "201": + description: 创建的租户 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 创建租户 + tags: + - 租户管理 + /tenants/{id}: + delete: + consumes: + - application/json + description: 删除指定的租户 + parameters: + - description: 租户ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: 删除成功 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 删除租户 + tags: + - 租户管理 + get: + consumes: + - application/json + description: 根据ID获取租户详情 + parameters: + - description: 租户ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: 租户详情 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + "404": + description: 租户不存在 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取租户详情 + tags: + - 租户管理 + put: + consumes: + - application/json + description: 更新租户信息 + parameters: + - description: 租户ID + in: path + name: id + required: true + type: integer + - description: 租户信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.Tenant' + produces: + - application/json + responses: + "200": + description: 更新后的租户 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新租户 + tags: + - 租户管理 + /tenants/all: + get: + consumes: + - application/json + description: 获取系统中所有租户(需要跨租户访问权限) + produces: + - application/json + responses: + "200": + description: 所有租户列表 + schema: + additionalProperties: true + type: object + "403": + description: 权限不足 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取所有租户列表 + tags: + - 租户管理 + /tenants/kv/{key}: + get: + consumes: + - application/json + description: 获取租户级别的KV配置(支持agent-config、web-search-config、conversation-config) + parameters: + - description: 配置键名 + in: path + name: key + required: true + type: string + produces: + - application/json + responses: + "200": + description: 配置值 + schema: + additionalProperties: true + type: object + "400": + description: 不支持的键 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取租户KV配置 + tags: + - 租户管理 + put: + consumes: + - application/json + description: 更新租户级别的KV配置(支持agent-config、web-search-config、conversation-config) + parameters: + - description: 配置键名 + in: path + name: key + required: true + type: string + - description: 配置值 + in: body + name: request + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: 更新成功 + schema: + additionalProperties: true + type: object + "400": + description: 不支持的键 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 更新租户KV配置 + tags: + - 租户管理 + /tenants/kv/agent-config: + get: + consumes: + - application/json + description: 获取租户的全局Agent配置(默认应用于所有会话) + produces: + - application/json + responses: + "200": + description: Agent配置 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取租户Agent配置 + tags: + - 租户管理 + /tenants/kv/conversation-config: + get: + consumes: + - application/json + description: 获取租户的全局对话配置(默认应用于普通模式会话) + produces: + - application/json + responses: + "200": + description: 对话配置 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取租户对话配置 + tags: + - 租户管理 + /tenants/kv/web-search-config: + get: + consumes: + - application/json + description: 获取租户的网络搜索配置 + produces: + - application/json + responses: + "200": + description: 网络搜索配置 + schema: + additionalProperties: true + type: object + "400": + description: 请求参数错误 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 获取租户网络搜索配置 + tags: + - 租户管理 + /tenants/search: + get: + consumes: + - application/json + description: 分页搜索租户(需要跨租户访问权限) + parameters: + - description: 搜索关键词 + in: query + name: keyword + type: string + - description: 租户ID筛选 + in: query + name: tenant_id + type: integer + - default: 1 + description: 页码 + in: query + name: page + type: integer + - default: 20 + description: 每页数量 + in: query + name: page_size + type: integer + produces: + - application/json + responses: + "200": + description: 搜索结果 + schema: + additionalProperties: true + type: object + "403": + description: 权限不足 + schema: + $ref: '#/definitions/github_com_Tencent_WeKnora_internal_errors.AppError' + security: + - Bearer: [] + summary: 搜索租户 + tags: + - 租户管理 +securityDefinitions: + Bearer: + description: 输入 Bearer {token} 格式的 JWT 令牌 + in: header + name: Authorization + type: apiKey +swagger: "2.0" diff --git a/go.mod b/go.mod index 988d5c95..078371a5 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,9 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/spf13/viper v1.20.1 github.com/stretchr/testify v1.11.1 + github.com/swaggo/files v1.0.1 + github.com/swaggo/gin-swagger v1.6.1 + github.com/swaggo/swag v1.16.6 github.com/tencentyun/cos-go-sdk-v5 v0.7.65 github.com/yanyiwu/gojieba v1.4.5 go.opentelemetry.io/otel v1.38.0 @@ -47,6 +50,9 @@ require ( ) require ( + github.com/KyleBanks/depth v1.2.1 // indirect + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/andybalholm/brotli v1.1.0 // indirect github.com/andybalholm/cascadia v1.3.3 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect @@ -70,6 +76,10 @@ require ( github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.19.6 // indirect + github.com/go-openapi/spec v0.20.4 // indirect + github.com/go-openapi/swag v0.19.15 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.27.0 // indirect @@ -89,6 +99,7 @@ require ( github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.18.1 // indirect github.com/klauspost/cpuid/v2 v2.3.0 // indirect @@ -136,5 +147,6 @@ require ( golang.org/x/tools v0.38.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20251111163417-95abcf5c77ba // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index bbe798f0..a5781cee 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,16 @@ entgo.io/ent v0.14.3 h1:wokAV/kIlH9TeklJWGGS7AYJdVckr0DloWjIcO9iIIQ= entgo.io/ent v0.14.3/go.mod h1:aDPE/OziPEu8+OWbzy4UlvWmD2/kbRuWfK2A40hcxJM= github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg= github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= +github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo= github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= @@ -41,6 +47,7 @@ github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -74,6 +81,8 @@ github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3G github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= github.com/gin-contrib/cors v1.7.5 h1:cXC9SmofOrRg0w9PigwGlHG3ztswH6bqq4vJVXnvYMk= github.com/gin-contrib/cors v1.7.5/go.mod h1:4q3yi7xBEDDWKapjT2o1V7mScKDDr8k+jZ0fSquGoy0= +github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= +github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w= github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM= github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk= @@ -87,6 +96,16 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= +github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= +github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= +github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-pg/pg/v10 v10.11.0 h1:CMKJqLgTrfpE/aOVeLdybezR2om071Vh38OLZjsyMI0= github.com/go-pg/pg/v10 v10.11.0/go.mod h1:4BpHRoxE61y4Onpof3x1a2SQvi9c+q1dJnrNdMjsroA= github.com/go-pg/zerochecker v0.2.0 h1:pp7f72c3DobMWOb2ErtZsnrPaSvHd2W4o9//8HtF4mU= @@ -156,6 +175,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= @@ -163,8 +184,11 @@ github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdB github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo= @@ -173,6 +197,9 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= github.com/mark3labs/mcp-go v0.43.0 h1:lgiKcWMddh4sngbU+hoWOZ9iAe/qp/m851RQpj3Y7jA= @@ -205,6 +232,7 @@ github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSr github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= github.com/neo4j/neo4j-go-driver/v6 v6.0.0-alpha.1 h1:nV3ZdYJTi73jel0mm3dpWumNY3i3nwyo25y69SPGwyg= github.com/neo4j/neo4j-go-driver/v6 v6.0.0-alpha.1/go.mod h1:hzSTfNfM31p1uRSzL1F/BAYOgaiTarE6OAQBajfsm+I= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/ollama/ollama v0.11.4 h1:6xLYLEPTKtw6N20qQecyEL/rrBktPO4o5U05cnvkSmI= @@ -266,6 +294,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -274,6 +303,12 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +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.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI= +github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0= github.com/tencentyun/cos-go-sdk-v5 v0.7.65 h1:+WBbfwThfZSbxpf1Dw6fyMwyzVtWBBExqfDJ5giiR2s= @@ -356,8 +391,10 @@ golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA= golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= @@ -376,6 +413,7 @@ golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -402,6 +440,7 @@ golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= @@ -434,9 +473,15 @@ google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94U google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314= diff --git a/internal/application/service/knowledge.go b/internal/application/service/knowledge.go index bdf4af12..f34b8a16 100644 --- a/internal/application/service/knowledge.go +++ b/internal/application/service/knowledge.go @@ -3990,8 +3990,8 @@ func (s *knowledgeService) buildFAQCSV(chunks []*types.Chunk, tagMap map[string] escapeCSVField(strings.Join(meta.NegativeQuestions, "##")), escapeCSVField(strings.Join(meta.Answers, "##")), boolToCSV(meta.AnswerStrategy == types.AnswerStrategyAll), - boolToCSV(!chunk.IsEnabled), // 是否停用:取反 - boolToCSV(!chunk.Flags.HasFlag(types.ChunkFlagRecommended)), // 是否禁止被推荐:取反 + boolToCSV(!chunk.IsEnabled), // 是否停用:取反 + boolToCSV(!chunk.Flags.HasFlag(types.ChunkFlagRecommended)), // 是否禁止被推荐:取反 } buf.WriteString(strings.Join(row, ",")) buf.WriteString("\n") @@ -4619,11 +4619,6 @@ func (s *knowledgeService) triggerManualProcessing(ctx context.Context, if cfg == nil { logger.GetLogger(ctx).WithField("knowledge_id", knowledge.ID). Error("triggerManualProcessing enable multimodal but VLM config missing") - knowledge.ParseStatus = "failed" - knowledge.ErrorMessage = "VLM 配置缺失" - knowledge.UpdatedAt = time.Now() - s.repo.UpdateKnowledge(ctx, knowledge) - return } vlmConfig = cfg } diff --git a/internal/handler/auth.go b/internal/handler/auth.go index b9908e02..7395df42 100644 --- a/internal/handler/auth.go +++ b/internal/handler/auth.go @@ -38,11 +38,16 @@ func NewAuthHandler(configInfo *config.Config, } } -// Register handles the HTTP request for user registration -// It deserializes the request body into a registration request object, validates it, -// calls the service to create the user, and returns the result -// Parameters: -// - c: Gin context for the HTTP request +// Register godoc +// @Summary 用户注册 +// @Description 注册新用户账号 +// @Tags 认证 +// @Accept json +// @Produce json +// @Param request body types.RegisterRequest true "注册请求参数" +// @Success 201 {object} types.RegisterResponse +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Router /auth/register [post] func (h *AuthHandler) Register(c *gin.Context) { ctx := c.Request.Context() @@ -88,11 +93,16 @@ func (h *AuthHandler) Register(c *gin.Context) { c.JSON(http.StatusCreated, response) } -// Login handles the HTTP request for user login -// It deserializes the request body into a login request object, validates it, -// calls the service to authenticate the user, and returns tokens -// Parameters: -// - c: Gin context for the HTTP request +// Login godoc +// @Summary 用户登录 +// @Description 用户登录并获取访问令牌 +// @Tags 认证 +// @Accept json +// @Produce json +// @Param request body types.LoginRequest true "登录请求参数" +// @Success 200 {object} types.LoginResponse +// @Failure 401 {object} errors.AppError "认证失败" +// @Router /auth/login [post] func (h *AuthHandler) Login(c *gin.Context) { ctx := c.Request.Context() @@ -137,10 +147,16 @@ func (h *AuthHandler) Login(c *gin.Context) { c.JSON(http.StatusOK, response) } -// Logout handles the HTTP request for user logout -// It extracts the token from the Authorization header and revokes it -// Parameters: -// - c: Gin context for the HTTP request +// Logout godoc +// @Summary 用户登出 +// @Description 撤销当前访问令牌并登出 +// @Tags 认证 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "登出成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /auth/logout [post] func (h *AuthHandler) Logout(c *gin.Context) { ctx := c.Request.Context() @@ -182,10 +198,16 @@ func (h *AuthHandler) Logout(c *gin.Context) { }) } -// RefreshToken handles the HTTP request for refreshing access tokens -// It extracts the refresh token from the request body and generates new tokens -// Parameters: -// - c: Gin context for the HTTP request +// RefreshToken godoc +// @Summary 刷新令牌 +// @Description 使用刷新令牌获取新的访问令牌 +// @Tags 认证 +// @Accept json +// @Produce json +// @Param request body object{refreshToken=string} true "刷新令牌" +// @Success 200 {object} map[string]interface{} "新令牌" +// @Failure 401 {object} errors.AppError "令牌无效" +// @Router /auth/refresh [post] func (h *AuthHandler) RefreshToken(c *gin.Context) { ctx := c.Request.Context() @@ -220,10 +242,16 @@ func (h *AuthHandler) RefreshToken(c *gin.Context) { }) } -// GetCurrentUser handles the HTTP request for getting current user information -// It extracts the user from the context (set by auth middleware) and returns user info -// Parameters: -// - c: Gin context for the HTTP request +// GetCurrentUser godoc +// @Summary 获取当前用户信息 +// @Description 获取当前登录用户的详细信息 +// @Tags 认证 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "用户信息" +// @Failure 401 {object} errors.AppError "未授权" +// @Security Bearer +// @Router /auth/me [get] func (h *AuthHandler) GetCurrentUser(c *gin.Context) { ctx := c.Request.Context() @@ -256,10 +284,17 @@ func (h *AuthHandler) GetCurrentUser(c *gin.Context) { }) } -// ChangePassword handles the HTTP request for changing user password -// It extracts the current user and validates the old password before setting new one -// Parameters: -// - c: Gin context for the HTTP request +// ChangePassword godoc +// @Summary 修改密码 +// @Description 修改当前用户的登录密码 +// @Tags 认证 +// @Accept json +// @Produce json +// @Param request body object{old_password=string,new_password=string} true "密码修改请求" +// @Success 200 {object} map[string]interface{} "修改成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /auth/change-password [post] func (h *AuthHandler) ChangePassword(c *gin.Context) { ctx := c.Request.Context() @@ -302,10 +337,16 @@ func (h *AuthHandler) ChangePassword(c *gin.Context) { }) } -// ValidateToken handles the HTTP request for validating access tokens -// It extracts the token from the Authorization header and validates it -// Parameters: -// - c: Gin context for the HTTP request +// ValidateToken godoc +// @Summary 验证令牌 +// @Description 验证访问令牌是否有效 +// @Tags 认证 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "令牌有效" +// @Failure 401 {object} errors.AppError "令牌无效" +// @Security Bearer +// @Router /auth/validate [get] func (h *AuthHandler) ValidateToken(c *gin.Context) { ctx := c.Request.Context() diff --git a/internal/handler/chunk.go b/internal/handler/chunk.go index 46992f4f..907b9d92 100644 --- a/internal/handler/chunk.go +++ b/internal/handler/chunk.go @@ -22,7 +22,18 @@ func NewChunkHandler(service interfaces.ChunkService) *ChunkHandler { return &ChunkHandler{service: service} } -// GetChunkByIDOnly gets a chunk by its ID only (without requiring knowledge_id) +// GetChunkByIDOnly godoc +// @Summary 通过ID获取分块 +// @Description 仅通过分块ID获取分块详情(不需要knowledge_id) +// @Tags 分块管理 +// @Accept json +// @Produce json +// @Param id path string true "分块ID" +// @Success 200 {object} map[string]interface{} "分块详情" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Failure 404 {object} errors.AppError "分块不存在" +// @Security Bearer +// @Router /chunks/by-id/{id} [get] func (h *ChunkHandler) GetChunkByIDOnly(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start retrieving chunk by ID only") @@ -79,7 +90,19 @@ func (h *ChunkHandler) GetChunkByIDOnly(c *gin.Context) { }) } -// ListKnowledgeChunks lists all chunks for a given knowledge ID +// ListKnowledgeChunks godoc +// @Summary 获取知识分块列表 +// @Description 获取指定知识下的所有分块列表,支持分页 +// @Tags 分块管理 +// @Accept json +// @Produce json +// @Param knowledge_id path string true "知识ID" +// @Param page query int false "页码" default(1) +// @Param page_size query int false "每页数量" default(10) +// @Success 200 {object} map[string]interface{} "分块列表" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /chunks/{knowledge_id} [get] func (h *ChunkHandler) ListKnowledgeChunks(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start retrieving knowledge chunks list") @@ -200,7 +223,20 @@ func (h *ChunkHandler) validateAndGetChunk(c *gin.Context) (*types.Chunk, string return chunk, knowledgeID, nil } -// UpdateChunk updates a chunk's properties +// UpdateChunk godoc +// @Summary 更新分块 +// @Description 更新指定分块的内容和属性 +// @Tags 分块管理 +// @Accept json +// @Produce json +// @Param knowledge_id path string true "知识ID" +// @Param id path string true "分块ID" +// @Param request body UpdateChunkRequest true "更新请求" +// @Success 200 {object} map[string]interface{} "更新后的分块" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Failure 404 {object} errors.AppError "分块不存在" +// @Security Bearer +// @Router /chunks/{knowledge_id}/{id} [put] func (h *ChunkHandler) UpdateChunk(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start updating knowledge chunk") @@ -239,7 +275,19 @@ func (h *ChunkHandler) UpdateChunk(c *gin.Context) { }) } -// DeleteChunk deletes a specific chunk +// DeleteChunk godoc +// @Summary 删除分块 +// @Description 删除指定的分块 +// @Tags 分块管理 +// @Accept json +// @Produce json +// @Param knowledge_id path string true "知识ID" +// @Param id path string true "分块ID" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Failure 404 {object} errors.AppError "分块不存在" +// @Security Bearer +// @Router /chunks/{knowledge_id}/{id} [delete] func (h *ChunkHandler) DeleteChunk(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start deleting knowledge chunk") @@ -263,7 +311,17 @@ func (h *ChunkHandler) DeleteChunk(c *gin.Context) { }) } -// DeleteChunksByKnowledgeID deletes all chunks for a given knowledge ID +// DeleteChunksByKnowledgeID godoc +// @Summary 删除知识下所有分块 +// @Description 删除指定知识下的所有分块 +// @Tags 分块管理 +// @Accept json +// @Produce json +// @Param knowledge_id path string true "知识ID" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /chunks/{knowledge_id} [delete] func (h *ChunkHandler) DeleteChunksByKnowledgeID(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start deleting all chunks under knowledge") @@ -289,7 +347,19 @@ func (h *ChunkHandler) DeleteChunksByKnowledgeID(c *gin.Context) { }) } -// DeleteGeneratedQuestion deletes a generated question by its ID +// DeleteGeneratedQuestion godoc +// @Summary 删除生成的问题 +// @Description 删除分块中生成的问题 +// @Tags 分块管理 +// @Accept json +// @Produce json +// @Param id path string true "分块ID" +// @Param request body object{question_id=string} true "问题ID" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Failure 404 {object} errors.AppError "分块不存在" +// @Security Bearer +// @Router /chunks/by-id/{id}/questions [delete] func (h *ChunkHandler) DeleteGeneratedQuestion(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start deleting generated question from chunk") diff --git a/internal/handler/evaluation.go b/internal/handler/evaluation.go index 9a5ba434..0fbce395 100644 --- a/internal/handler/evaluation.go +++ b/internal/handler/evaluation.go @@ -29,7 +29,17 @@ type EvaluationRequest struct { RerankModelID string `json:"rerank_id"` // ID of rerank model to use } -// Evaluation handles evaluation request +// Evaluation godoc +// @Summary 执行评估 +// @Description 对知识库进行评估测试 +// @Tags 评估 +// @Accept json +// @Produce json +// @Param request body EvaluationRequest true "评估请求参数" +// @Success 200 {object} map[string]interface{} "评估任务" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /evaluation/ [post] func (e *EvaluationHandler) Evaluation(c *gin.Context) { ctx := c.Request.Context() @@ -81,7 +91,17 @@ type GetEvaluationRequest struct { TaskID string `form:"task_id" binding:"required"` // ID of evaluation task } -// GetEvaluationResult retrieves evaluation result by task ID +// GetEvaluationResult godoc +// @Summary 获取评估结果 +// @Description 根据任务ID获取评估结果 +// @Tags 评估 +// @Accept json +// @Produce json +// @Param task_id query string true "评估任务ID" +// @Success 200 {object} map[string]interface{} "评估结果" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /evaluation/ [get] func (e *EvaluationHandler) GetEvaluationResult(c *gin.Context) { ctx := c.Request.Context() diff --git a/internal/handler/faq.go b/internal/handler/faq.go index a179854f..533bbb89 100644 --- a/internal/handler/faq.go +++ b/internal/handler/faq.go @@ -22,7 +22,21 @@ func NewFAQHandler(knowledgeService interfaces.KnowledgeService) *FAQHandler { return &FAQHandler{knowledgeService: knowledgeService} } -// ListEntries lists FAQ entries under a knowledge base. +// ListEntries godoc +// @Summary 获取FAQ条目列表 +// @Description 获取知识库下的FAQ条目列表,支持分页和筛选 +// @Tags FAQ管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param page query int false "页码" +// @Param page_size query int false "每页数量" +// @Param tag_id query string false "标签ID筛选" +// @Param keyword query string false "关键词搜索" +// @Success 200 {object} map[string]interface{} "FAQ列表" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/faq/entries [get] func (h *FAQHandler) ListEntries(c *gin.Context) { ctx := c.Request.Context() var page types.Pagination @@ -48,7 +62,18 @@ func (h *FAQHandler) ListEntries(c *gin.Context) { }) } -// UpsertEntries appends or replaces FAQ entries in batch asynchronously. +// UpsertEntries godoc +// @Summary 批量更新/插入FAQ条目 +// @Description 异步批量更新或插入FAQ条目 +// @Tags FAQ管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param request body types.FAQBatchUpsertPayload true "批量操作请求" +// @Success 200 {object} map[string]interface{} "任务ID" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/faq/entries [post] func (h *FAQHandler) UpsertEntries(c *gin.Context) { ctx := c.Request.Context() var req types.FAQBatchUpsertPayload @@ -73,7 +98,18 @@ func (h *FAQHandler) UpsertEntries(c *gin.Context) { }) } -// CreateEntry creates a single FAQ entry synchronously. +// CreateEntry godoc +// @Summary 创建单个FAQ条目 +// @Description 同步创建单个FAQ条目 +// @Tags FAQ管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param request body types.FAQEntryPayload true "FAQ条目" +// @Success 200 {object} map[string]interface{} "创建的FAQ条目" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/faq/entry [post] func (h *FAQHandler) CreateEntry(c *gin.Context) { ctx := c.Request.Context() var req types.FAQEntryPayload @@ -96,7 +132,19 @@ func (h *FAQHandler) CreateEntry(c *gin.Context) { }) } -// UpdateEntry updates a single FAQ entry. +// UpdateEntry godoc +// @Summary 更新FAQ条目 +// @Description 更新指定的FAQ条目 +// @Tags FAQ管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param entry_id path string true "FAQ条目ID" +// @Param request body types.FAQEntryPayload true "FAQ条目" +// @Success 200 {object} map[string]interface{} "更新成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/faq/entries/{entry_id} [put] func (h *FAQHandler) UpdateEntry(c *gin.Context) { ctx := c.Request.Context() var req types.FAQEntryPayload @@ -118,7 +166,18 @@ func (h *FAQHandler) UpdateEntry(c *gin.Context) { }) } -// UpdateEntryTagBatch updates tags for FAQ entries in batch. +// UpdateEntryTagBatch godoc +// @Summary 批量更新FAQ标签 +// @Description 批量更新FAQ条目的标签 +// @Tags FAQ管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param request body object true "标签更新请求" +// @Success 200 {object} map[string]interface{} "更新成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/faq/entries/tags [put] func (h *FAQHandler) UpdateEntryTagBatch(c *gin.Context) { ctx := c.Request.Context() var req faqEntryTagBatchRequest @@ -138,9 +197,18 @@ func (h *FAQHandler) UpdateEntryTagBatch(c *gin.Context) { }) } -// UpdateEntryFieldsBatch updates multiple fields for FAQ entries in batch. -// This is the unified API for batch updating FAQ entry fields. -// Supports updating is_enabled, is_recommended, tag_id in a single call. +// UpdateEntryFieldsBatch godoc +// @Summary 批量更新FAQ字段 +// @Description 批量更新FAQ条目的多个字段(is_enabled, is_recommended, tag_id) +// @Tags FAQ管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param request body types.FAQEntryFieldsBatchUpdate true "字段更新请求" +// @Success 200 {object} map[string]interface{} "更新成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/faq/entries/fields [put] func (h *FAQHandler) UpdateEntryFieldsBatch(c *gin.Context) { ctx := c.Request.Context() var req types.FAQEntryFieldsBatchUpdate @@ -170,7 +238,18 @@ type faqEntryTagBatchRequest struct { Updates map[string]*string `json:"updates" binding:"required,min=1"` } -// DeleteEntries deletes FAQ entries in batch. +// DeleteEntries godoc +// @Summary 批量删除FAQ条目 +// @Description 批量删除指定的FAQ条目 +// @Tags FAQ管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param request body object{ids=[]string} true "要删除的FAQ ID列表" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/faq/entries [delete] func (h *FAQHandler) DeleteEntries(c *gin.Context) { ctx := c.Request.Context() var req faqDeleteRequest @@ -193,7 +272,18 @@ func (h *FAQHandler) DeleteEntries(c *gin.Context) { }) } -// SearchFAQ searches FAQ entries using hybrid search. +// SearchFAQ godoc +// @Summary 搜索FAQ +// @Description 使用混合搜索在FAQ中搜索 +// @Tags FAQ管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param request body types.FAQSearchRequest true "搜索请求" +// @Success 200 {object} map[string]interface{} "搜索结果" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/faq/search [post] func (h *FAQHandler) SearchFAQ(c *gin.Context) { ctx := c.Request.Context() var req types.FAQSearchRequest @@ -222,7 +312,17 @@ func (h *FAQHandler) SearchFAQ(c *gin.Context) { }) } -// ExportEntries exports all FAQ entries as a CSV file. +// ExportEntries godoc +// @Summary 导出FAQ条目 +// @Description 将所有FAQ条目导出为CSV文件 +// @Tags FAQ管理 +// @Accept json +// @Produce text/csv +// @Param id path string true "知识库ID" +// @Success 200 {file} file "CSV文件" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/faq/entries/export [get] func (h *FAQHandler) ExportEntries(c *gin.Context) { ctx := c.Request.Context() kbID := secutils.SanitizeForLog(c.Param("id")) diff --git a/internal/handler/initialization.go b/internal/handler/initialization.go index a83ccf8d..4e35e856 100644 --- a/internal/handler/initialization.go +++ b/internal/handler/initialization.go @@ -205,7 +205,19 @@ type InitializationRequest struct { } `json:"questionGeneration"` } -// UpdateKBConfig 根据知识库ID和模型ID更新配置(简化版) +// UpdateKBConfig godoc +// @Summary 更新知识库配置 +// @Description 根据知识库ID更新模型和分块配置 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Param kbId path string true "知识库ID" +// @Param request body KBModelConfigRequest true "配置请求" +// @Success 200 {object} map[string]interface{} "更新成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Failure 404 {object} errors.AppError "知识库不存在" +// @Security Bearer +// @Router /initialization/kb/{kbId}/config [put] func (h *InitializationHandler) UpdateKBConfig(c *gin.Context) { ctx := c.Request.Context() kbIdStr := utils.SanitizeForLog(c.Param("kbId")) @@ -374,7 +386,18 @@ func (h *InitializationHandler) UpdateKBConfig(c *gin.Context) { }) } -// InitializeByKB 根据知识库ID执行配置更新 +// InitializeByKB godoc +// @Summary 初始化知识库配置 +// @Description 根据知识库ID执行完整配置更新 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Param kbId path string true "知识库ID" +// @Param request body object true "初始化请求" +// @Success 200 {object} map[string]interface{} "初始化成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /initialization/kb/{kbId} [post] func (h *InitializationHandler) InitializeByKB(c *gin.Context) { ctx := c.Request.Context() kbIdStr := utils.SanitizeForLog(c.Param("kbId")) @@ -765,7 +788,14 @@ func extractModelIDs(processedModels []*types.Model) (embeddingModelID, llmModel return } -// CheckOllamaStatus 检查Ollama服务状态 +// CheckOllamaStatus godoc +// @Summary 检查Ollama服务状态 +// @Description 检查Ollama服务是否可用 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "Ollama状态" +// @Router /initialization/ollama/status [get] func (h *InitializationHandler) CheckOllamaStatus(c *gin.Context) { ctx := c.Request.Context() @@ -809,7 +839,17 @@ func (h *InitializationHandler) CheckOllamaStatus(c *gin.Context) { }) } -// CheckOllamaModels 检查Ollama模型状态 +// CheckOllamaModels godoc +// @Summary 检查Ollama模型状态 +// @Description 检查指定的Ollama模型是否已安装 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Param request body object{models=[]string} true "模型名称列表" +// @Success 200 {object} map[string]interface{} "模型状态" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /initialization/ollama/models/check [post] func (h *InitializationHandler) CheckOllamaModels(c *gin.Context) { ctx := c.Request.Context() @@ -860,7 +900,17 @@ func (h *InitializationHandler) CheckOllamaModels(c *gin.Context) { }) } -// DownloadOllamaModel 异步下载Ollama模型 +// DownloadOllamaModel godoc +// @Summary 下载Ollama模型 +// @Description 异步下载指定的Ollama模型 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Param request body object{modelName=string} true "模型名称" +// @Success 200 {object} map[string]interface{} "下载任务信息" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /initialization/ollama/models/download [post] func (h *InitializationHandler) DownloadOllamaModel(c *gin.Context) { ctx := c.Request.Context() @@ -961,7 +1011,17 @@ func (h *InitializationHandler) DownloadOllamaModel(c *gin.Context) { }) } -// GetDownloadProgress 获取下载进度 +// GetDownloadProgress godoc +// @Summary 获取下载进度 +// @Description 获取Ollama模型下载任务的进度 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Param taskId path string true "任务ID" +// @Success 200 {object} map[string]interface{} "下载进度" +// @Failure 404 {object} errors.AppError "任务不存在" +// @Security Bearer +// @Router /initialization/ollama/download/{taskId} [get] func (h *InitializationHandler) GetDownloadProgress(c *gin.Context) { taskID := c.Param("taskId") @@ -985,7 +1045,15 @@ func (h *InitializationHandler) GetDownloadProgress(c *gin.Context) { }) } -// ListDownloadTasks 列出所有下载任务 +// ListDownloadTasks godoc +// @Summary 列出下载任务 +// @Description 列出所有Ollama模型下载任务 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "任务列表" +// @Security Bearer +// @Router /initialization/ollama/download/tasks [get] func (h *InitializationHandler) ListDownloadTasks(c *gin.Context) { tasksMutex.RLock() tasks := make([]*DownloadTask, 0, len(downloadTasks)) @@ -1000,7 +1068,16 @@ func (h *InitializationHandler) ListDownloadTasks(c *gin.Context) { }) } -// ListOllamaModels 列出已安装的 Ollama 模型 +// ListOllamaModels godoc +// @Summary 列出Ollama模型 +// @Description 列出已安装的Ollama模型 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "模型列表" +// @Failure 500 {object} errors.AppError "服务器错误" +// @Security Bearer +// @Router /initialization/ollama/models [get] func (h *InitializationHandler) ListOllamaModels(c *gin.Context) { ctx := c.Request.Context() @@ -1128,7 +1205,17 @@ func (h *InitializationHandler) updateTaskStatus( } } -// GetCurrentConfigByKB 根据知识库ID获取配置信息 +// GetCurrentConfigByKB godoc +// @Summary 获取知识库配置 +// @Description 根据知识库ID获取当前配置信息 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Param kbId path string true "知识库ID" +// @Success 200 {object} map[string]interface{} "配置信息" +// @Failure 404 {object} errors.AppError "知识库不存在" +// @Security Bearer +// @Router /initialization/kb/{kbId}/config [get] func (h *InitializationHandler) GetCurrentConfigByKB(c *gin.Context) { ctx := c.Request.Context() kbIdStr := utils.SanitizeForLog(c.Param("kbId")) @@ -1332,7 +1419,17 @@ type RemoteModelCheckRequest struct { APIKey string `json:"apiKey"` } -// CheckRemoteModel 检查远程API模型连接 +// CheckRemoteModel godoc +// @Summary 检查远程模型 +// @Description 检查远程API模型连接是否正常 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Param request body RemoteModelCheckRequest true "模型检查请求" +// @Success 200 {object} map[string]interface{} "检查结果" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /initialization/models/remote/check [post] func (h *InitializationHandler) CheckRemoteModel(c *gin.Context) { ctx := c.Request.Context() @@ -1377,7 +1474,17 @@ func (h *InitializationHandler) CheckRemoteModel(c *gin.Context) { }) } -// TestEmbeddingModel 测试 Embedding 接口(本地或远程)是否可用 +// TestEmbeddingModel godoc +// @Summary 测试Embedding模型 +// @Description 测试Embedding接口是否可用并返回向量维度 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Param request body object true "Embedding测试请求" +// @Success 200 {object} map[string]interface{} "测试结果" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /initialization/models/embedding/test [post] func (h *InitializationHandler) TestEmbeddingModel(c *gin.Context) { ctx := c.Request.Context() @@ -1530,7 +1637,17 @@ func (h *InitializationHandler) checkRerankModelConnection(ctx context.Context, } } -// CheckRerankModel 检查Rerank模型连接和功能 +// CheckRerankModel godoc +// @Summary 检查Rerank模型 +// @Description 检查Rerank模型连接和功能是否正常 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Param request body object true "Rerank检查请求" +// @Success 200 {object} map[string]interface{} "检查结果" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /initialization/models/rerank/check [post] func (h *InitializationHandler) CheckRerankModel(c *gin.Context) { ctx := c.Request.Context() @@ -1598,7 +1715,22 @@ type testMultimodalForm struct { SeparatorsRaw string `form:"separators"` } -// TestMultimodalFunction 测试多模态功能 +// TestMultimodalFunction godoc +// @Summary 测试多模态功能 +// @Description 上传图片测试多模态处理功能 +// @Tags 初始化 +// @Accept multipart/form-data +// @Produce json +// @Param image formData file true "测试图片" +// @Param vlm_model formData string true "VLM模型名称" +// @Param vlm_base_url formData string true "VLM Base URL" +// @Param vlm_api_key formData string false "VLM API Key" +// @Param vlm_interface_type formData string false "VLM接口类型" +// @Param storage_type formData string true "存储类型(cos/minio)" +// @Success 200 {object} map[string]interface{} "测试结果" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /initialization/multimodal/test [post] func (h *InitializationHandler) TestMultimodalFunction(c *gin.Context) { ctx := c.Request.Context() @@ -1857,7 +1989,17 @@ type TextRelationExtractionResponse struct { Relations []*types.GraphRelation `json:"relations"` } -// ExtractTextRelations extracts text relations from text +// ExtractTextRelations godoc +// @Summary 提取文本关系 +// @Description 从文本中提取实体和关系 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Param request body TextRelationExtractionRequest true "提取请求" +// @Success 200 {object} map[string]interface{} "提取结果" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /initialization/extract/relations [post] func (h *InitializationHandler) ExtractTextRelations(c *gin.Context) { ctx := c.Request.Context() @@ -1951,7 +2093,17 @@ type FabriTextResponse struct { Text string `json:"text"` } -// FabriText generates example text +// FabriText godoc +// @Summary 生成示例文本 +// @Description 根据标签生成示例文本 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Param request body FabriTextRequest true "生成请求" +// @Success 200 {object} map[string]interface{} "生成的文本" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /initialization/fabri/text [post] func (h *InitializationHandler) FabriText(c *gin.Context) { ctx := c.Request.Context() @@ -2024,7 +2176,14 @@ var tagOptions = []string{ "内容", "文化", "人物", "事件", "时间", "地点", "作品", "作者", "关系", "属性", } -// FabriTag generates tags +// FabriTag godoc +// @Summary 生成随机标签 +// @Description 随机生成一组标签 +// @Tags 初始化 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "生成的标签" +// @Router /initialization/fabri/tag [get] func (h *InitializationHandler) FabriTag(c *gin.Context) { tagRandom := RandomSelect(tagOptions, rand.Intn(len(tagOptions)-1)+1) c.JSON(http.StatusOK, gin.H{ diff --git a/internal/handler/knowledge.go b/internal/handler/knowledge.go index 2c50cf09..460c7f6f 100644 --- a/internal/handler/knowledge.go +++ b/internal/handler/knowledge.go @@ -82,7 +82,22 @@ func (h *KnowledgeHandler) handleDuplicateKnowledgeError(c *gin.Context, return false } -// CreateKnowledgeFromFile handles requests to create knowledge from an uploaded file +// CreateKnowledgeFromFile godoc +// @Summary 从文件创建知识 +// @Description 上传文件并创建知识条目 +// @Tags 知识管理 +// @Accept multipart/form-data +// @Produce json +// @Param id path string true "知识库ID" +// @Param file formData file true "上传的文件" +// @Param fileName formData string false "自定义文件名" +// @Param metadata formData string false "元数据JSON" +// @Param enable_multimodel formData bool false "启用多模态处理" +// @Success 200 {object} map[string]interface{} "创建的知识" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Failure 409 {object} map[string]interface{} "文件重复" +// @Security Bearer +// @Router /knowledge-bases/{id}/knowledge/file [post] func (h *KnowledgeHandler) CreateKnowledgeFromFile(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start creating knowledge from file") @@ -167,7 +182,19 @@ func (h *KnowledgeHandler) CreateKnowledgeFromFile(c *gin.Context) { }) } -// CreateKnowledgeFromURL handles requests to create knowledge from a URL +// CreateKnowledgeFromURL godoc +// @Summary 从URL创建知识 +// @Description 从指定URL抓取内容并创建知识条目 +// @Tags 知识管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param request body object{url=string,enable_multimodel=bool,title=string} true "URL请求" +// @Success 201 {object} map[string]interface{} "创建的知识" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Failure 409 {object} map[string]interface{} "URL重复" +// @Security Bearer +// @Router /knowledge-bases/{id}/knowledge/url [post] func (h *KnowledgeHandler) CreateKnowledgeFromURL(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start creating knowledge from URL") @@ -223,7 +250,18 @@ func (h *KnowledgeHandler) CreateKnowledgeFromURL(c *gin.Context) { }) } -// CreateManualKnowledge handles manual Markdown knowledge creation +// CreateManualKnowledge godoc +// @Summary 手工创建知识 +// @Description 手工录入Markdown格式的知识内容 +// @Tags 知识管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param request body types.ManualKnowledgePayload true "手工知识内容" +// @Success 200 {object} map[string]interface{} "创建的知识" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/knowledge/manual [post] func (h *KnowledgeHandler) CreateManualKnowledge(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start creating manual knowledge") @@ -262,7 +300,18 @@ func (h *KnowledgeHandler) CreateManualKnowledge(c *gin.Context) { }) } -// GetKnowledge retrieves a knowledge entry by its ID +// GetKnowledge godoc +// @Summary 获取知识详情 +// @Description 根据ID获取知识条目详情 +// @Tags 知识管理 +// @Accept json +// @Produce json +// @Param id path string true "知识ID" +// @Success 200 {object} map[string]interface{} "知识详情" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Failure 404 {object} errors.AppError "知识不存在" +// @Security Bearer +// @Router /knowledge/{id} [get] func (h *KnowledgeHandler) GetKnowledge(c *gin.Context) { ctx := c.Request.Context() @@ -296,7 +345,22 @@ func (h *KnowledgeHandler) GetKnowledge(c *gin.Context) { }) } -// ListKnowledge retrieves a paginated list of knowledge entries from a knowledge base +// ListKnowledge godoc +// @Summary 获取知识列表 +// @Description 获取知识库下的知识列表,支持分页和筛选 +// @Tags 知识管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param page query int false "页码" +// @Param page_size query int false "每页数量" +// @Param tag_id query string false "标签ID筛选" +// @Param keyword query string false "关键词搜索" +// @Param file_type query string false "文件类型筛选" +// @Success 200 {object} map[string]interface{} "知识列表" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/knowledge [get] func (h *KnowledgeHandler) ListKnowledge(c *gin.Context) { ctx := c.Request.Context() @@ -356,7 +420,17 @@ func (h *KnowledgeHandler) ListKnowledge(c *gin.Context) { }) } -// DeleteKnowledge handles requests to delete a knowledge entry by its ID +// DeleteKnowledge godoc +// @Summary 删除知识 +// @Description 根据ID删除知识条目 +// @Tags 知识管理 +// @Accept json +// @Produce json +// @Param id path string true "知识ID" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge/{id} [delete] func (h *KnowledgeHandler) DeleteKnowledge(c *gin.Context) { ctx := c.Request.Context() @@ -385,7 +459,17 @@ func (h *KnowledgeHandler) DeleteKnowledge(c *gin.Context) { }) } -// DownloadKnowledgeFile handles requests to download a file associated with a knowledge entry +// DownloadKnowledgeFile godoc +// @Summary 下载知识文件 +// @Description 下载知识条目关联的原始文件 +// @Tags 知识管理 +// @Accept json +// @Produce application/octet-stream +// @Param id path string true "知识ID" +// @Success 200 {file} file "文件内容" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge/{id}/download [get] func (h *KnowledgeHandler) DownloadKnowledgeFile(c *gin.Context) { ctx := c.Request.Context() @@ -442,7 +526,17 @@ type GetKnowledgeBatchRequest struct { IDs []string `form:"ids" binding:"required"` // List of knowledge IDs } -// GetKnowledgeBatch handles requests to retrieve multiple knowledge entries in a batch +// GetKnowledgeBatch godoc +// @Summary 批量获取知识 +// @Description 根据ID列表批量获取知识条目 +// @Tags 知识管理 +// @Accept json +// @Produce json +// @Param ids query []string true "知识ID列表" +// @Success 200 {object} map[string]interface{} "知识列表" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge/batch [get] func (h *KnowledgeHandler) GetKnowledgeBatch(c *gin.Context) { ctx := c.Request.Context() @@ -489,6 +583,18 @@ func (h *KnowledgeHandler) GetKnowledgeBatch(c *gin.Context) { }) } +// UpdateKnowledge godoc +// @Summary 更新知识 +// @Description 更新知识条目信息 +// @Tags 知识管理 +// @Accept json +// @Produce json +// @Param id path string true "知识ID" +// @Param request body types.Knowledge true "知识信息" +// @Success 200 {object} map[string]interface{} "更新成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge/{id} [put] func (h *KnowledgeHandler) UpdateKnowledge(c *gin.Context) { ctx := c.Request.Context() // Get knowledge ID from URL path parameter @@ -519,7 +625,18 @@ func (h *KnowledgeHandler) UpdateKnowledge(c *gin.Context) { }) } -// UpdateManualKnowledge handles manual Markdown knowledge updates +// UpdateManualKnowledge godoc +// @Summary 更新手工知识 +// @Description 更新手工录入的Markdown知识内容 +// @Tags 知识管理 +// @Accept json +// @Produce json +// @Param id path string true "知识ID" +// @Param request body types.ManualKnowledgePayload true "手工知识内容" +// @Success 200 {object} map[string]interface{} "更新后的知识" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge/manual/{id} [put] func (h *KnowledgeHandler) UpdateManualKnowledge(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start updating manual knowledge") @@ -562,7 +679,17 @@ type knowledgeTagBatchRequest struct { Updates map[string]*string `json:"updates" binding:"required,min=1"` } -// UpdateKnowledgeTagBatch updates tags for knowledge items in batch. +// UpdateKnowledgeTagBatch godoc +// @Summary 批量更新知识标签 +// @Description 批量更新知识条目的标签 +// @Tags 知识管理 +// @Accept json +// @Produce json +// @Param request body object true "标签更新请求" +// @Success 200 {object} map[string]interface{} "更新成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge/tags [put] func (h *KnowledgeHandler) UpdateKnowledgeTagBatch(c *gin.Context) { ctx := c.Request.Context() var req knowledgeTagBatchRequest @@ -581,7 +708,19 @@ func (h *KnowledgeHandler) UpdateKnowledgeTagBatch(c *gin.Context) { }) } -// UpdateImageInfo updates a chunk's properties +// UpdateImageInfo godoc +// @Summary 更新图像信息 +// @Description 更新知识分块的图像信息 +// @Tags 知识管理 +// @Accept json +// @Produce json +// @Param id path string true "知识ID" +// @Param chunk_id path string true "分块ID" +// @Param request body object{image_info=string} true "图像信息" +// @Success 200 {object} map[string]interface{} "更新成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge/image/{id}/{chunk_id} [put] func (h *KnowledgeHandler) UpdateImageInfo(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start updating image info") diff --git a/internal/handler/knowledgebase.go b/internal/handler/knowledgebase.go index 4ab66bdb..5c4cc705 100644 --- a/internal/handler/knowledgebase.go +++ b/internal/handler/knowledgebase.go @@ -27,7 +27,18 @@ func NewKnowledgeBaseHandler( return &KnowledgeBaseHandler{service: service, knowledgeService: knowledgeService} } -// HybridSearch handles requests to perform hybrid vector and keyword search on a knowledge base +// HybridSearch godoc +// @Summary 混合搜索 +// @Description 在知识库中执行向量和关键词混合搜索 +// @Tags 知识库 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param request body types.SearchParams true "搜索参数" +// @Success 200 {object} map[string]interface{} "搜索结果" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/hybrid-search [get] func (h *KnowledgeBaseHandler) HybridSearch(c *gin.Context) { ctx := c.Request.Context() @@ -68,7 +79,17 @@ func (h *KnowledgeBaseHandler) HybridSearch(c *gin.Context) { }) } -// CreateKnowledgeBase handles requests to create a new knowledge base +// CreateKnowledgeBase godoc +// @Summary 创建知识库 +// @Description 创建新的知识库 +// @Tags 知识库 +// @Accept json +// @Produce json +// @Param request body types.KnowledgeBase true "知识库信息" +// @Success 201 {object} map[string]interface{} "创建的知识库" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases [post] func (h *KnowledgeBaseHandler) CreateKnowledgeBase(c *gin.Context) { ctx := c.Request.Context() @@ -144,7 +165,18 @@ func (h *KnowledgeBaseHandler) validateAndGetKnowledgeBase(c *gin.Context) (*typ return kb, id, nil } -// GetKnowledgeBase handles requests to retrieve a knowledge base by ID +// GetKnowledgeBase godoc +// @Summary 获取知识库详情 +// @Description 根据ID获取知识库详情 +// @Tags 知识库 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Success 200 {object} map[string]interface{} "知识库详情" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Failure 404 {object} errors.AppError "知识库不存在" +// @Security Bearer +// @Router /knowledge-bases/{id} [get] func (h *KnowledgeBaseHandler) GetKnowledgeBase(c *gin.Context) { // Validate and get the knowledge base kb, _, err := h.validateAndGetKnowledgeBase(c) @@ -158,7 +190,16 @@ func (h *KnowledgeBaseHandler) GetKnowledgeBase(c *gin.Context) { }) } -// ListKnowledgeBases handles requests to list all knowledge bases for a tenant +// ListKnowledgeBases godoc +// @Summary 获取知识库列表 +// @Description 获取当前租户的所有知识库 +// @Tags 知识库 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "知识库列表" +// @Failure 500 {object} errors.AppError "服务器错误" +// @Security Bearer +// @Router /knowledge-bases [get] func (h *KnowledgeBaseHandler) ListKnowledgeBases(c *gin.Context) { ctx := c.Request.Context() @@ -183,7 +224,18 @@ type UpdateKnowledgeBaseRequest struct { Config *types.KnowledgeBaseConfig `json:"config" binding:"required"` } -// UpdateKnowledgeBase handles requests to update an existing knowledge base +// UpdateKnowledgeBase godoc +// @Summary 更新知识库 +// @Description 更新知识库的名称、描述和配置 +// @Tags 知识库 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param request body UpdateKnowledgeBaseRequest true "更新请求" +// @Success 200 {object} map[string]interface{} "更新后的知识库" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id} [put] func (h *KnowledgeBaseHandler) UpdateKnowledgeBase(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start updating knowledge base") @@ -222,7 +274,17 @@ func (h *KnowledgeBaseHandler) UpdateKnowledgeBase(c *gin.Context) { }) } -// DeleteKnowledgeBase handles requests to delete a knowledge base +// DeleteKnowledgeBase godoc +// @Summary 删除知识库 +// @Description 删除指定的知识库及其所有内容 +// @Tags 知识库 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id} [delete] func (h *KnowledgeBaseHandler) DeleteKnowledgeBase(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start deleting knowledge base") @@ -257,6 +319,17 @@ type CopyKnowledgeBaseRequest struct { TargetID string `json:"target_id"` } +// CopyKnowledgeBase godoc +// @Summary 复制知识库 +// @Description 将一个知识库的内容复制到另一个知识库 +// @Tags 知识库 +// @Accept json +// @Produce json +// @Param request body CopyKnowledgeBaseRequest true "复制请求" +// @Success 200 {object} map[string]interface{} "复制成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/copy [post] func (h *KnowledgeBaseHandler) CopyKnowledgeBase(c *gin.Context) { ctx := c.Request.Context() var req CopyKnowledgeBaseRequest diff --git a/internal/handler/mcp_service.go b/internal/handler/mcp_service.go index 2555b00a..b8f95979 100644 --- a/internal/handler/mcp_service.go +++ b/internal/handler/mcp_service.go @@ -23,8 +23,17 @@ func NewMCPServiceHandler(mcpServiceService interfaces.MCPServiceService) *MCPSe } } -// CreateMCPService creates a new MCP service -// POST /api/mcp-services +// CreateMCPService godoc +// @Summary 创建MCP服务 +// @Description 创建新的MCP服务配置 +// @Tags MCP服务 +// @Accept json +// @Produce json +// @Param request body types.MCPService true "MCP服务配置" +// @Success 200 {object} map[string]interface{} "创建的MCP服务" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /mcp-services [post] func (h *MCPServiceHandler) CreateMCPService(c *gin.Context) { ctx := c.Request.Context() @@ -55,8 +64,16 @@ func (h *MCPServiceHandler) CreateMCPService(c *gin.Context) { }) } -// ListMCPServices lists all MCP services for a tenant -// GET /api/mcp-services +// ListMCPServices godoc +// @Summary 获取MCP服务列表 +// @Description 获取当前租户的所有MCP服务 +// @Tags MCP服务 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "MCP服务列表" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /mcp-services [get] func (h *MCPServiceHandler) ListMCPServices(c *gin.Context) { ctx := c.Request.Context() @@ -80,8 +97,17 @@ func (h *MCPServiceHandler) ListMCPServices(c *gin.Context) { }) } -// GetMCPService retrieves a single MCP service -// GET /api/mcp-services/:id +// GetMCPService godoc +// @Summary 获取MCP服务详情 +// @Description 根据ID获取MCP服务详情 +// @Tags MCP服务 +// @Accept json +// @Produce json +// @Param id path string true "MCP服务ID" +// @Success 200 {object} map[string]interface{} "MCP服务详情" +// @Failure 404 {object} errors.AppError "服务不存在" +// @Security Bearer +// @Router /mcp-services/{id} [get] func (h *MCPServiceHandler) GetMCPService(c *gin.Context) { ctx := c.Request.Context() serviceID := secutils.SanitizeForLog(c.Param("id")) @@ -106,8 +132,18 @@ func (h *MCPServiceHandler) GetMCPService(c *gin.Context) { }) } -// UpdateMCPService updates an MCP service -// PUT /api/mcp-services/:id +// UpdateMCPService godoc +// @Summary 更新MCP服务 +// @Description 更新MCP服务配置 +// @Tags MCP服务 +// @Accept json +// @Produce json +// @Param id path string true "MCP服务ID" +// @Param request body object true "更新字段" +// @Success 200 {object} map[string]interface{} "更新后的MCP服务" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /mcp-services/{id} [put] func (h *MCPServiceHandler) UpdateMCPService(c *gin.Context) { ctx := c.Request.Context() serviceID := secutils.SanitizeForLog(c.Param("id")) @@ -227,8 +263,17 @@ func (h *MCPServiceHandler) UpdateMCPService(c *gin.Context) { }) } -// DeleteMCPService deletes an MCP service -// DELETE /api/mcp-services/:id +// DeleteMCPService godoc +// @Summary 删除MCP服务 +// @Description 删除指定的MCP服务 +// @Tags MCP服务 +// @Accept json +// @Produce json +// @Param id path string true "MCP服务ID" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 500 {object} errors.AppError "服务器错误" +// @Security Bearer +// @Router /mcp-services/{id} [delete] func (h *MCPServiceHandler) DeleteMCPService(c *gin.Context) { ctx := c.Request.Context() serviceID := secutils.SanitizeForLog(c.Param("id")) @@ -253,8 +298,17 @@ func (h *MCPServiceHandler) DeleteMCPService(c *gin.Context) { }) } -// TestMCPService tests connection to an MCP service -// POST /api/mcp-services/:id/test +// TestMCPService godoc +// @Summary 测试MCP服务连接 +// @Description 测试MCP服务是否可以正常连接 +// @Tags MCP服务 +// @Accept json +// @Produce json +// @Param id path string true "MCP服务ID" +// @Success 200 {object} map[string]interface{} "测试结果" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /mcp-services/{id}/test [post] func (h *MCPServiceHandler) TestMCPService(c *gin.Context) { ctx := c.Request.Context() serviceID := secutils.SanitizeForLog(c.Param("id")) @@ -288,8 +342,17 @@ func (h *MCPServiceHandler) TestMCPService(c *gin.Context) { }) } -// GetMCPServiceTools retrieves tools from an MCP service -// GET /api/mcp-services/:id/tools +// GetMCPServiceTools godoc +// @Summary 获取MCP服务工具列表 +// @Description 获取MCP服务提供的工具列表 +// @Tags MCP服务 +// @Accept json +// @Produce json +// @Param id path string true "MCP服务ID" +// @Success 200 {object} map[string]interface{} "工具列表" +// @Failure 500 {object} errors.AppError "服务器错误" +// @Security Bearer +// @Router /mcp-services/{id}/tools [get] func (h *MCPServiceHandler) GetMCPServiceTools(c *gin.Context) { ctx := c.Request.Context() serviceID := secutils.SanitizeForLog(c.Param("id")) @@ -314,8 +377,17 @@ func (h *MCPServiceHandler) GetMCPServiceTools(c *gin.Context) { }) } -// GetMCPServiceResources retrieves resources from an MCP service -// GET /api/mcp-services/:id/resources +// GetMCPServiceResources godoc +// @Summary 获取MCP服务资源列表 +// @Description 获取MCP服务提供的资源列表 +// @Tags MCP服务 +// @Accept json +// @Produce json +// @Param id path string true "MCP服务ID" +// @Success 200 {object} map[string]interface{} "资源列表" +// @Failure 500 {object} errors.AppError "服务器错误" +// @Security Bearer +// @Router /mcp-services/{id}/resources [get] func (h *MCPServiceHandler) GetMCPServiceResources(c *gin.Context) { ctx := c.Request.Context() serviceID := secutils.SanitizeForLog(c.Param("id")) diff --git a/internal/handler/message.go b/internal/handler/message.go index 78544757..7ff97de7 100644 --- a/internal/handler/message.go +++ b/internal/handler/message.go @@ -30,9 +30,19 @@ func NewMessageHandler(messageService interfaces.MessageService) *MessageHandler } } -// LoadMessages handles requests to load message history -// It supports both loading recent messages and loading messages before a specific timestamp -// This endpoint is used for scrolling through conversation history +// LoadMessages godoc +// @Summary 加载消息历史 +// @Description 加载会话的消息历史,支持分页和时间筛选 +// @Tags 消息 +// @Accept json +// @Produce json +// @Param session_id path string true "会话ID" +// @Param limit query int false "返回数量" default(20) +// @Param before_time query string false "在此时间之前的消息(RFC3339Nano格式)" +// @Success 200 {object} map[string]interface{} "消息列表" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /messages/{session_id}/load [get] func (h *MessageHandler) LoadMessages(c *gin.Context) { ctx := c.Request.Context() @@ -108,8 +118,18 @@ func (h *MessageHandler) LoadMessages(c *gin.Context) { }) } -// DeleteMessage handles requests to delete a message from a session -// It requires both session ID and message ID to identify the specific message to delete +// DeleteMessage godoc +// @Summary 删除消息 +// @Description 从会话中删除指定消息 +// @Tags 消息 +// @Accept json +// @Produce json +// @Param session_id path string true "会话ID" +// @Param id path string true "消息ID" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 500 {object} errors.AppError "服务器错误" +// @Security Bearer +// @Router /messages/{session_id}/{id} [delete] func (h *MessageHandler) DeleteMessage(c *gin.Context) { ctx := c.Request.Context() diff --git a/internal/handler/model.go b/internal/handler/model.go index bae77569..1dd7ff23 100644 --- a/internal/handler/model.go +++ b/internal/handler/model.go @@ -68,11 +68,17 @@ type CreateModelRequest struct { Parameters types.ModelParameters `json:"parameters" binding:"required"` } -// CreateModel handles the HTTP request to create a new model -// It validates the request, processes it using the model service, -// and returns the created model to the client -// Parameters: -// - c: Gin context for the HTTP request +// CreateModel godoc +// @Summary 创建模型 +// @Description 创建新的模型配置 +// @Tags 模型管理 +// @Accept json +// @Produce json +// @Param request body CreateModelRequest true "模型信息" +// @Success 201 {object} map[string]interface{} "创建的模型" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /models [post] func (h *ModelHandler) CreateModel(c *gin.Context) { ctx := c.Request.Context() @@ -125,11 +131,17 @@ func (h *ModelHandler) CreateModel(c *gin.Context) { }) } -// GetModel handles the HTTP request to retrieve a model by its ID -// It fetches the model from the service and returns it to the client, -// or returns appropriate error messages if the model cannot be found -// Parameters: -// - c: Gin context for the HTTP request +// GetModel godoc +// @Summary 获取模型详情 +// @Description 根据ID获取模型详情 +// @Tags 模型管理 +// @Accept json +// @Produce json +// @Param id path string true "模型ID" +// @Success 200 {object} map[string]interface{} "模型详情" +// @Failure 404 {object} errors.AppError "模型不存在" +// @Security Bearer +// @Router /models/{id} [get] func (h *ModelHandler) GetModel(c *gin.Context) { ctx := c.Request.Context() @@ -169,10 +181,16 @@ func (h *ModelHandler) GetModel(c *gin.Context) { }) } -// ListModels handles the HTTP request to retrieve all models for a tenant -// It validates the tenant ID, fetches models from the service, and returns them to the client -// Parameters: -// - c: Gin context for the HTTP request +// ListModels godoc +// @Summary 获取模型列表 +// @Description 获取当前租户的所有模型 +// @Tags 模型管理 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "模型列表" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /models [get] func (h *ModelHandler) ListModels(c *gin.Context) { ctx := c.Request.Context() @@ -219,11 +237,18 @@ type UpdateModelRequest struct { Type types.ModelType `json:"type"` } -// UpdateModel handles the HTTP request to update an existing model -// It validates the request, retrieves the current model, applies changes, -// and updates the model in the service -// Parameters: -// - c: Gin context for the HTTP request +// UpdateModel godoc +// @Summary 更新模型 +// @Description 更新模型配置信息 +// @Tags 模型管理 +// @Accept json +// @Produce json +// @Param id path string true "模型ID" +// @Param request body UpdateModelRequest true "更新信息" +// @Success 200 {object} map[string]interface{} "更新后的模型" +// @Failure 404 {object} errors.AppError "模型不存在" +// @Security Bearer +// @Router /models/{id} [put] func (h *ModelHandler) UpdateModel(c *gin.Context) { ctx := c.Request.Context() @@ -285,11 +310,17 @@ func (h *ModelHandler) UpdateModel(c *gin.Context) { }) } -// DeleteModel handles the HTTP request to delete a model by its ID -// It validates the model ID, attempts to delete the model through the service, -// and returns appropriate status and messages -// Parameters: -// - c: Gin context for the HTTP request +// DeleteModel godoc +// @Summary 删除模型 +// @Description 删除指定的模型 +// @Tags 模型管理 +// @Accept json +// @Produce json +// @Param id path string true "模型ID" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 404 {object} errors.AppError "模型不存在" +// @Security Bearer +// @Router /models/{id} [delete] func (h *ModelHandler) DeleteModel(c *gin.Context) { ctx := c.Request.Context() diff --git a/internal/handler/session/handler.go b/internal/handler/session/handler.go index e0d5cf75..8334b33f 100644 --- a/internal/handler/session/handler.go +++ b/internal/handler/session/handler.go @@ -39,7 +39,17 @@ func NewHandler( } } -// CreateSession handles the creation of a new conversation session +// CreateSession godoc +// @Summary 创建会话 +// @Description 创建新的对话会话 +// @Tags 会话 +// @Accept json +// @Produce json +// @Param request body CreateSessionRequest true "会话创建请求" +// @Success 201 {object} map[string]interface{} "创建的会话" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /sessions [post] func (h *Handler) CreateSession(c *gin.Context) { ctx := c.Request.Context() // Parse and validate the request body @@ -187,7 +197,17 @@ func (h *Handler) applyConversationDefaults(ctx context.Context, session *types. session.SummaryParameters = h.createDefaultSummaryConfig(ctx) } -// GetSession retrieves a session by its ID +// GetSession godoc +// @Summary 获取会话详情 +// @Description 根据ID获取会话详情 +// @Tags 会话 +// @Accept json +// @Produce json +// @Param id path string true "会话ID" +// @Success 200 {object} map[string]interface{} "会话详情" +// @Failure 404 {object} errors.AppError "会话不存在" +// @Security Bearer +// @Router /sessions/{id} [get] func (h *Handler) GetSession(c *gin.Context) { ctx := c.Request.Context() @@ -223,7 +243,18 @@ func (h *Handler) GetSession(c *gin.Context) { }) } -// GetSessionsByTenant retrieves all sessions for the current tenant with pagination +// GetSessionsByTenant godoc +// @Summary 获取会话列表 +// @Description 获取当前租户的会话列表,支持分页 +// @Tags 会话 +// @Accept json +// @Produce json +// @Param page query int false "页码" +// @Param page_size query int false "每页数量" +// @Success 200 {object} map[string]interface{} "会话列表" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /sessions [get] func (h *Handler) GetSessionsByTenant(c *gin.Context) { ctx := c.Request.Context() @@ -253,7 +284,18 @@ func (h *Handler) GetSessionsByTenant(c *gin.Context) { }) } -// UpdateSession updates an existing session's properties +// UpdateSession godoc +// @Summary 更新会话 +// @Description 更新会话属性 +// @Tags 会话 +// @Accept json +// @Produce json +// @Param id path string true "会话ID" +// @Param request body types.Session true "会话信息" +// @Success 200 {object} map[string]interface{} "更新后的会话" +// @Failure 404 {object} errors.AppError "会话不存在" +// @Security Bearer +// @Router /sessions/{id} [put] func (h *Handler) UpdateSession(c *gin.Context) { ctx := c.Request.Context() @@ -304,7 +346,17 @@ func (h *Handler) UpdateSession(c *gin.Context) { }) } -// DeleteSession deletes a session by its ID +// DeleteSession godoc +// @Summary 删除会话 +// @Description 删除指定的会话 +// @Tags 会话 +// @Accept json +// @Produce json +// @Param id path string true "会话ID" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 404 {object} errors.AppError "会话不存在" +// @Security Bearer +// @Router /sessions/{id} [delete] func (h *Handler) DeleteSession(c *gin.Context) { ctx := c.Request.Context() diff --git a/internal/handler/session/qa.go b/internal/handler/session/qa.go index 332456bc..9b34c5e3 100644 --- a/internal/handler/session/qa.go +++ b/internal/handler/session/qa.go @@ -16,7 +16,17 @@ import ( "github.com/gin-gonic/gin" ) -// SearchKnowledge performs knowledge base search without LLM summarization +// SearchKnowledge godoc +// @Summary 知识搜索 +// @Description 在知识库中搜索(不使用LLM总结) +// @Tags 问答 +// @Accept json +// @Produce json +// @Param request body SearchKnowledgeRequest true "搜索请求" +// @Success 200 {object} map[string]interface{} "搜索结果" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /sessions/search [post] func (h *Handler) SearchKnowledge(c *gin.Context) { ctx := logger.CloneContext(c.Request.Context()) @@ -67,7 +77,18 @@ func (h *Handler) SearchKnowledge(c *gin.Context) { }) } -// KnowledgeQA handles knowledge base question answering requests with LLM summarization +// KnowledgeQA godoc +// @Summary 知识问答 +// @Description 基于知识库的问答(使用LLM总结),支持SSE流式响应 +// @Tags 问答 +// @Accept json +// @Produce text/event-stream +// @Param session_id path string true "会话ID" +// @Param request body CreateKnowledgeQARequest true "问答请求" +// @Success 200 {object} map[string]interface{} "问答结果(SSE流)" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /sessions/{session_id}/knowledge-qa [post] func (h *Handler) KnowledgeQA(c *gin.Context) { ctx := logger.CloneContext(c.Request.Context()) @@ -136,7 +157,18 @@ func (h *Handler) KnowledgeQA(c *gin.Context) { assistantMessage, true, secutils.SanitizeForLog(request.SummaryModelID), request.WebSearchEnabled) } -// AgentQA handles agent-based question answering with conversation history and streaming +// AgentQA godoc +// @Summary Agent问答 +// @Description 基于Agent的智能问答,支持多轮对话和SSE流式响应 +// @Tags 问答 +// @Accept json +// @Produce text/event-stream +// @Param session_id path string true "会话ID" +// @Param request body CreateKnowledgeQARequest true "问答请求" +// @Success 200 {object} map[string]interface{} "问答结果(SSE流)" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /sessions/{session_id}/agent-qa [post] func (h *Handler) AgentQA(c *gin.Context) { ctx := logger.CloneContext(c.Request.Context()) logger.Info(ctx, "Start processing agent QA request") diff --git a/internal/handler/session/stream.go b/internal/handler/session/stream.go index 0a21bb47..49d8c982 100644 --- a/internal/handler/session/stream.go +++ b/internal/handler/session/stream.go @@ -15,7 +15,18 @@ import ( "github.com/gin-gonic/gin" ) -// ContinueStream handles continued streaming of an active response stream +// ContinueStream godoc +// @Summary 继续流式响应 +// @Description 继续获取正在进行的流式响应 +// @Tags 问答 +// @Accept json +// @Produce text/event-stream +// @Param session_id path string true "会话ID" +// @Param message_id query string true "消息ID" +// @Success 200 {object} map[string]interface{} "流式响应" +// @Failure 404 {object} errors.AppError "会话或消息不存在" +// @Security Bearer +// @Router /sessions/{session_id}/continue [get] func (h *Handler) ContinueStream(c *gin.Context) { ctx := c.Request.Context() @@ -163,7 +174,18 @@ func (h *Handler) ContinueStream(c *gin.Context) { } } -// StopSession handles the stop generation request +// StopSession godoc +// @Summary 停止生成 +// @Description 停止当前正在进行的生成任务 +// @Tags 问答 +// @Accept json +// @Produce json +// @Param session_id path string true "会话ID" +// @Param request body StopSessionRequest true "停止请求" +// @Success 200 {object} map[string]interface{} "停止成功" +// @Failure 404 {object} errors.AppError "会话或消息不存在" +// @Security Bearer +// @Router /sessions/{session_id}/stop [post] func (h *Handler) StopSession(c *gin.Context) { ctx := logger.CloneContext(c.Request.Context()) sessionID := secutils.SanitizeForLog(c.Param("session_id")) diff --git a/internal/handler/session/title.go b/internal/handler/session/title.go index 82cffc3c..21122d8e 100644 --- a/internal/handler/session/title.go +++ b/internal/handler/session/title.go @@ -8,7 +8,18 @@ import ( "github.com/gin-gonic/gin" ) -// GenerateTitle generates a title for a session based on message content +// GenerateTitle godoc +// @Summary 生成会话标题 +// @Description 根据消息内容自动生成会话标题 +// @Tags 会话 +// @Accept json +// @Produce json +// @Param session_id path string true "会话ID" +// @Param request body GenerateTitleRequest true "生成请求" +// @Success 200 {object} map[string]interface{} "生成的标题" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /sessions/{session_id}/title [post] func (h *Handler) GenerateTitle(c *gin.Context) { ctx := c.Request.Context() diff --git a/internal/handler/system.go b/internal/handler/system.go index b8013501..3357bb96 100644 --- a/internal/handler/system.go +++ b/internal/handler/system.go @@ -44,7 +44,14 @@ var ( GoVersion = "unknown" ) -// GetSystemInfo gets system information including version and commit ID +// GetSystemInfo godoc +// @Summary 获取系统信息 +// @Description 获取系统版本、构建信息和引擎配置 +// @Tags 系统 +// @Accept json +// @Produce json +// @Success 200 {object} GetSystemInfoResponse "系统信息" +// @Router /system/info [get] func (h *SystemHandler) GetSystemInfo(c *gin.Context) { ctx := logger.CloneContext(c.Request.Context()) diff --git a/internal/handler/tag.go b/internal/handler/tag.go index 534e39dd..02593564 100644 --- a/internal/handler/tag.go +++ b/internal/handler/tag.go @@ -22,7 +22,20 @@ func NewTagHandler(tagService interfaces.KnowledgeTagService) *TagHandler { return &TagHandler{tagService: tagService} } -// ListTags returns all tags under a knowledge base with statistics. +// ListTags godoc +// @Summary 获取标签列表 +// @Description 获取知识库下的所有标签及统计信息 +// @Tags 标签管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param page query int false "页码" +// @Param page_size query int false "每页数量" +// @Param keyword query string false "关键词搜索" +// @Success 200 {object} map[string]interface{} "标签列表" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/tags [get] func (h *TagHandler) ListTags(c *gin.Context) { ctx := c.Request.Context() kbID := secutils.SanitizeForLog(c.Param("id")) @@ -55,7 +68,18 @@ type createTagRequest struct { SortOrder int `json:"sort_order"` } -// CreateTag creates a new tag. +// CreateTag godoc +// @Summary 创建标签 +// @Description 在知识库下创建新标签 +// @Tags 标签管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param request body object{name=string,color=string,sort_order=int} true "标签信息" +// @Success 200 {object} map[string]interface{} "创建的标签" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/tags [post] func (h *TagHandler) CreateTag(c *gin.Context) { ctx := c.Request.Context() kbID := secutils.SanitizeForLog(c.Param("id")) @@ -89,7 +113,19 @@ type updateTagRequest struct { SortOrder *int `json:"sort_order"` } -// UpdateTag updates an existing tag. +// UpdateTag godoc +// @Summary 更新标签 +// @Description 更新标签信息 +// @Tags 标签管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param tag_id path string true "标签ID" +// @Param request body object true "标签更新信息" +// @Success 200 {object} map[string]interface{} "更新后的标签" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/tags/{tag_id} [put] func (h *TagHandler) UpdateTag(c *gin.Context) { ctx := c.Request.Context() @@ -116,7 +152,19 @@ func (h *TagHandler) UpdateTag(c *gin.Context) { }) } -// DeleteTag deletes a tag. Use query param force=true to force delete even if referenced. +// DeleteTag godoc +// @Summary 删除标签 +// @Description 删除标签,可使用force=true强制删除被引用的标签 +// @Tags 标签管理 +// @Accept json +// @Produce json +// @Param id path string true "知识库ID" +// @Param tag_id path string true "标签ID" +// @Param force query bool false "强制删除" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /knowledge-bases/{id}/tags/{tag_id} [delete] func (h *TagHandler) DeleteTag(c *gin.Context) { ctx := c.Request.Context() tagID := secutils.SanitizeForLog(c.Param("tag_id")) diff --git a/internal/handler/tenant.go b/internal/handler/tenant.go index f551f612..f268c08b 100644 --- a/internal/handler/tenant.go +++ b/internal/handler/tenant.go @@ -40,11 +40,17 @@ func NewTenantHandler(service interfaces.TenantService, userService interfaces.U } } -// CreateTenant handles the HTTP request for creating a new tenant -// It deserializes the request body into a tenant object, validates it, -// calls the service to create the tenant, and returns the result -// Parameters: -// - c: Gin context for the HTTP request +// CreateTenant godoc +// @Summary 创建租户 +// @Description 创建新的租户 +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Param request body types.Tenant true "租户信息" +// @Success 201 {object} map[string]interface{} "创建的租户" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /tenants [post] func (h *TenantHandler) CreateTenant(c *gin.Context) { ctx := c.Request.Context() @@ -85,11 +91,18 @@ func (h *TenantHandler) CreateTenant(c *gin.Context) { }) } -// GetTenant handles the HTTP request for retrieving a tenant by ID -// It extracts and validates the tenant ID from the URL parameter, -// retrieves the tenant from the service, and returns it in the response -// Parameters: -// - c: Gin context for the HTTP request +// GetTenant godoc +// @Summary 获取租户详情 +// @Description 根据ID获取租户详情 +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Param id path int true "租户ID" +// @Success 200 {object} map[string]interface{} "租户详情" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Failure 404 {object} errors.AppError "租户不存在" +// @Security Bearer +// @Router /tenants/{id} [get] func (h *TenantHandler) GetTenant(c *gin.Context) { ctx := c.Request.Context() @@ -119,11 +132,18 @@ func (h *TenantHandler) GetTenant(c *gin.Context) { }) } -// UpdateTenant handles the HTTP request for updating an existing tenant -// It extracts the tenant ID from the URL parameter, deserializes the request body, -// validates the data, updates the tenant through the service, and returns the result -// Parameters: -// - c: Gin context for the HTTP request +// UpdateTenant godoc +// @Summary 更新租户 +// @Description 更新租户信息 +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Param id path int true "租户ID" +// @Param request body types.Tenant true "租户信息" +// @Success 200 {object} map[string]interface{} "更新后的租户" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /tenants/{id} [put] func (h *TenantHandler) UpdateTenant(c *gin.Context) { ctx := c.Request.Context() @@ -171,11 +191,17 @@ func (h *TenantHandler) UpdateTenant(c *gin.Context) { }) } -// DeleteTenant handles the HTTP request for deleting a tenant -// It extracts and validates the tenant ID from the URL parameter, -// calls the service to delete the tenant, and returns the result -// Parameters: -// - c: Gin context for the HTTP request +// DeleteTenant godoc +// @Summary 删除租户 +// @Description 删除指定的租户 +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Param id path int true "租户ID" +// @Success 200 {object} map[string]interface{} "删除成功" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /tenants/{id} [delete] func (h *TenantHandler) DeleteTenant(c *gin.Context) { ctx := c.Request.Context() @@ -209,10 +235,16 @@ func (h *TenantHandler) DeleteTenant(c *gin.Context) { }) } -// ListTenants handles the HTTP request for retrieving a list of all tenants -// It calls the service to fetch the tenant list and returns it in the response -// Parameters: -// - c: Gin context for the HTTP request +// ListTenants godoc +// @Summary 获取租户列表 +// @Description 获取当前用户可访问的租户列表 +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "租户列表" +// @Failure 500 {object} errors.AppError "服务器错误" +// @Security Bearer +// @Router /tenants [get] func (h *TenantHandler) ListTenants(c *gin.Context) { ctx := c.Request.Context() @@ -237,10 +269,16 @@ func (h *TenantHandler) ListTenants(c *gin.Context) { }) } -// ListAllTenants handles the HTTP request for retrieving a list of all tenants -// This endpoint requires cross-tenant access permission -// Parameters: -// - c: Gin context for the HTTP request +// ListAllTenants godoc +// @Summary 获取所有租户列表 +// @Description 获取系统中所有租户(需要跨租户访问权限) +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "所有租户列表" +// @Failure 403 {object} errors.AppError "权限不足" +// @Security Bearer +// @Router /tenants/all [get] func (h *TenantHandler) ListAllTenants(c *gin.Context) { ctx := c.Request.Context() @@ -287,13 +325,20 @@ func (h *TenantHandler) ListAllTenants(c *gin.Context) { }) } -// SearchTenants handles the HTTP request for searching tenants with pagination -// This endpoint requires cross-tenant access permission -// Query parameters: -// - keyword: search keyword (optional) -// - tenant_id: filter by tenant ID (optional) -// - page: page number (default: 1) -// - page_size: page size (default: 20) +// SearchTenants godoc +// @Summary 搜索租户 +// @Description 分页搜索租户(需要跨租户访问权限) +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Param keyword query string false "搜索关键词" +// @Param tenant_id query int false "租户ID筛选" +// @Param page query int false "页码" default(1) +// @Param page_size query int false "每页数量" default(20) +// @Success 200 {object} map[string]interface{} "搜索结果" +// @Failure 403 {object} errors.AppError "权限不足" +// @Security Bearer +// @Router /tenants/search [get] func (h *TenantHandler) SearchTenants(c *gin.Context) { ctx := c.Request.Context() @@ -381,8 +426,16 @@ type AgentConfigRequest struct { UseCustomPrompt *bool `json:"use_custom_system_prompt"` } -// GetTenantAgentConfig retrieves the agent configuration for a tenant -// This is the global agent configuration that applies to all sessions by default +// GetTenantAgentConfig godoc +// @Summary 获取租户Agent配置 +// @Description 获取租户的全局Agent配置(默认应用于所有会话) +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "Agent配置" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /tenants/kv/agent-config [get] func (h *TenantHandler) GetTenantAgentConfig(c *gin.Context) { ctx := c.Request.Context() tenant := ctx.Value(types.TenantInfoContextKey).(*types.Tenant) @@ -528,10 +581,17 @@ func (h *TenantHandler) updateTenantAgentConfigInternal(c *gin.Context) { }) } -// GetTenantKV provides a generic KV-style getter for tenant-level configurations -// Supported keys: -// - "agent-config": returns tenant.AgentConfig with additional available_* fields -// - "web-search-config": returns masked tenant.WebSearchConfig (API key masked) +// GetTenantKV godoc +// @Summary 获取租户KV配置 +// @Description 获取租户级别的KV配置(支持agent-config、web-search-config、conversation-config) +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Param key path string true "配置键名" +// @Success 200 {object} map[string]interface{} "配置值" +// @Failure 400 {object} errors.AppError "不支持的键" +// @Security Bearer +// @Router /tenants/kv/{key} [get] func (h *TenantHandler) GetTenantKV(c *gin.Context) { ctx := c.Request.Context() key := secutils.SanitizeForLog(c.Param("key")) @@ -553,8 +613,18 @@ func (h *TenantHandler) GetTenantKV(c *gin.Context) { } } -// UpdateTenantKV provides a generic KV-style updater for tenant-level configurations -// Body is the JSON value to set for the key. +// UpdateTenantKV godoc +// @Summary 更新租户KV配置 +// @Description 更新租户级别的KV配置(支持agent-config、web-search-config、conversation-config) +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Param key path string true "配置键名" +// @Param request body object true "配置值" +// @Success 200 {object} map[string]interface{} "更新成功" +// @Failure 400 {object} errors.AppError "不支持的键" +// @Security Bearer +// @Router /tenants/kv/{key} [put] func (h *TenantHandler) UpdateTenantKV(c *gin.Context) { ctx := c.Request.Context() key := secutils.SanitizeForLog(c.Param("key")) @@ -620,7 +690,16 @@ func (h *TenantHandler) updateTenantWebSearchConfigInternal(c *gin.Context) { }) } -// GetTenantWebSearchConfig returns the web search configuration for a tenant +// GetTenantWebSearchConfig godoc +// @Summary 获取租户网络搜索配置 +// @Description 获取租户的网络搜索配置 +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "网络搜索配置" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /tenants/kv/web-search-config [get] func (h *TenantHandler) GetTenantWebSearchConfig(c *gin.Context) { ctx := c.Request.Context() logger.Info(ctx, "Start getting tenant web search config") @@ -696,8 +775,16 @@ func validateConversationConfig(req *types.ConversationConfig) error { return nil } -// GetTenantConversationConfig retrieves the conversation configuration for a tenant -// This is the global conversation configuration that applies to normal mode sessions by default +// GetTenantConversationConfig godoc +// @Summary 获取租户对话配置 +// @Description 获取租户的全局对话配置(默认应用于普通模式会话) +// @Tags 租户管理 +// @Accept json +// @Produce json +// @Success 200 {object} map[string]interface{} "对话配置" +// @Failure 400 {object} errors.AppError "请求参数错误" +// @Security Bearer +// @Router /tenants/kv/conversation-config [get] func (h *TenantHandler) GetTenantConversationConfig(c *gin.Context) { ctx := c.Request.Context() tenant := ctx.Value(types.TenantInfoContextKey).(*types.Tenant) diff --git a/internal/router/router.go b/internal/router/router.go index 4538fbb2..9c2ad7d8 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -5,6 +5,8 @@ import ( "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" + swaggerFiles "github.com/swaggo/files" + ginSwagger "github.com/swaggo/gin-swagger" "go.uber.org/dig" "github.com/Tencent/WeKnora/internal/config" @@ -12,6 +14,8 @@ import ( "github.com/Tencent/WeKnora/internal/handler/session" "github.com/Tencent/WeKnora/internal/middleware" "github.com/Tencent/WeKnora/internal/types/interfaces" + + _ "github.com/Tencent/WeKnora/docs" // swagger docs ) // RouterParams 路由参数 @@ -59,21 +63,31 @@ func NewRouter(params RouterParams) *gin.Engine { MaxAge: 12 * time.Hour, })) - // 其他中间件 + // 基础中间件(不需要认证) r.Use(middleware.RequestID()) r.Use(middleware.Logger()) r.Use(middleware.Recovery()) r.Use(middleware.ErrorHandler()) + + // 健康检查(不需要认证) + r.GET("/health", func(c *gin.Context) { + c.JSON(200, gin.H{"status": "ok"}) + }) + + // Swagger API 文档(不需要认证) + r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, + ginSwagger.DefaultModelsExpandDepth(-1), // 默认折叠 Models + ginSwagger.DocExpansion("list"), // 展开模式: "list"(展开标签), "full"(全部展开), "none"(全部折叠) + ginSwagger.DeepLinking(true), // 启用深度链接 + ginSwagger.PersistAuthorization(true), // 持久化认证信息 + )) + + // 认证中间件 r.Use(middleware.Auth(params.TenantService, params.UserService, params.Config)) // 添加OpenTelemetry追踪中间件 r.Use(middleware.TracingMiddleware()) - // 健康检查 - r.GET("/health", func(c *gin.Context) { - c.JSON(200, gin.H{"status": "ok"}) - }) - // 需要认证的API路由 v1 := r.Group("/api/v1") {