diff --git a/request/src/config/settings.py b/request/src/config/settings.py index b8c2d37..e3c99e5 100644 --- a/request/src/config/settings.py +++ b/request/src/config/settings.py @@ -1,6 +1,7 @@ from pydantic_settings import BaseSettings from typing import Optional import os +from pathlib import Path class Settings(BaseSettings): @@ -16,16 +17,16 @@ class Settings(BaseSettings): # 日志配置 log_level: str = "INFO" - log_file: Optional[str] = "logs/app.log" # 默认写入日志文件 - log_format: str = "json" # json 或 console - log_to_console: bool = False # 是否同时输出到控制台 + log_file: Optional[str] = "logs/app.log" + log_format: str = "json" + log_to_console: bool = False # 高级日志配置 - advanced_logging: bool = True # 是否启用高级日志系统 - logs_dir: str = "logs" # 日志目录 - max_log_days: int = 30 # 日志文件保存天数 - enable_log_cleanup: bool = True # 是否启用自动日志清理 - route_based_logging: bool = True # 是否启用基于路由的日志分类 + advanced_logging: bool = True + logs_dir: str = "logs" + max_log_days: int = 30 + enable_log_cleanup: bool = True + route_based_logging: bool = True # 性能配置 max_requests: int = 1000 @@ -38,7 +39,8 @@ class Settings(BaseSettings): cors_headers: list[str] = ["*"] class Config: - env_file = ".env" + env_file = str(Path(__file__).parent.parent.parent / ".env") + env_file_encoding = "utf-8" case_sensitive = False diff --git a/request/static/doc.html b/request/static/doc.html index 1ae6640..ef141d0 100644 --- a/request/static/doc.html +++ b/request/static/doc.html @@ -688,6 +688,251 @@ } } } + }, + "/api/datasets/{file_id}": { + "delete": { + "tags": [ + "Datasets" + ], + "summary": "delete_dataset", + "description": "删除数据集\n\nArgs:\n file_id: 文件ID\n\nReturns:\n StandardResponse: 包含删除结果的标准响应", + "operationId": "delete_dataset_api_datasets__file_id__delete", + "parameters": [ + { + "name": "file_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "title": "File Id" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StandardResponse" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + }, + "get": { + "tags": [ + "Datasets" + ], + "summary": "get_dataset", + "description": "获取特定数据集的详细信息\n\nArgs:\n file_id: 文件ID\n\nReturns:\n StandardResponse: 包含数据集详情的标准响应", + "operationId": "get_dataset_api_datasets__file_id__get", + "parameters": [ + { + "name": "file_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "title": "File Id" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StandardResponse" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/datasets/{file_id}/content": { + "get": { + "tags": [ + "Datasets" + ], + "summary": "get_dataset_content", + "description": "获取数据集文件内容(前N条记录)\n\nArgs:\n file_id: 文件ID\n limit: 返回的记录数量,默认5条\n\nReturns:\n StandardResponse: 包含数据集内容的标准响应", + "operationId": "get_dataset_content_api_datasets__file_id__content_get", + "parameters": [ + { + "name": "file_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "title": "File Id" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "default": 5, + "title": "Limit" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StandardResponse" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/datasets/list-files": { + "get": { + "tags": [ + "Datasets" + ], + "summary": "list_data_files", + "description": "查询data目录下的文件列表\n\nReturns:\n StandardResponse: 包含文件列表的标准响应", + "operationId": "list_data_files_api_datasets_list_files_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StandardResponse" + } + } + } + } + } + } + }, + "/api/datasets": { + "get": { + "tags": [ + "Datasets" + ], + "summary": "list_datasets", + "description": "获取所有数据集列表\n\nArgs:\n list_all: 是否列出data目录下的所有文件(物理文件),默认False(只列出API上传的文件)\n\nReturns:\n StandardResponse: 包含数据集列表的标准响应", + "operationId": "list_datasets_api_datasets_get", + "parameters": [ + { + "name": "list_all", + "in": "query", + "required": false, + "schema": { + "type": "boolean", + "default": false, + "title": "List All" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StandardResponse" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/datasets/upload": { + "post": { + "tags": [ + "Datasets" + ], + "summary": "upload_dataset", + "description": "上传数据集文件\n\nArgs:\n file: 上传的文件(支持 .json, .jsonl 格式)\n description: 文件描述(可选)\n\nReturns:\n StandardResponse: 包含上传结果的标准响应", + "operationId": "upload_dataset_api_datasets_upload_post", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/Body_upload_dataset_api_datasets_upload_post" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StandardResponse" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } } }, "components": { @@ -726,6 +971,31 @@ "title": "BatchDownloadRequest", "description": "批量下载请求模型" }, + "Body_upload_dataset_api_datasets_upload_post": { + "properties": { + "file": { + "type": "string", + "format": "binary", + "title": "File" + }, + "description": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Description" + } + }, + "type": "object", + "required": [ + "file" + ], + "title": "Body_upload_dataset_api_datasets_upload_post" + }, "HTTPValidationError": { "properties": { "detail": { @@ -739,6 +1009,29 @@ "type": "object", "title": "HTTPValidationError" }, + "StandardResponse": { + "properties": { + "status": { + "type": "integer", + "title": "Status" + }, + "response": { + "title": "Response" + }, + "time": { + "type": "string", + "title": "Time" + } + }, + "type": "object", + "required": [ + "status", + "response", + "time" + ], + "title": "StandardResponse", + "description": "标准响应格式" + }, "ValidationError": { "properties": { "loc": { diff --git a/web/pages/main.html b/web/pages/main.html index 8c93701..cd56775 100644 --- a/web/pages/main.html +++ b/web/pages/main.html @@ -134,9 +134,9 @@ -
+
-
+