diff --git a/.gitignore b/.gitignore index a9ed8ba..0ba3157 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .env + # Python 缓存与编译文件 __pycache__/ *.py[cod] @@ -21,15 +22,20 @@ wheels/ .installed.cfg *.egg -# 虚拟环境(非常重要,防止把本地依赖包提交上去) +# 虚拟环境 venv/ env/ -.idea -.idea/ .venv/ ENV/ -# 日志文件 +# IDE / 编辑器 +.idea +.idea/ +.vscode/ +*.swp +*.swo + +# 日志 *.log logs/ @@ -37,16 +43,18 @@ logs/ .DS_Store Thumbs.db -# pytest 测试产物 +# 测试文件与产物 +tests/ .pytest_cache/ .coverage coverage.xml htmlcov/ junit.xml -# mypy 类型检查缓存 +# mypy / 类型检查缓存 .mypy_cache/ -# 向量库、本地数据库、模型文件(大文件不要提交git) + +# 向量库、本地数据库、模型文件 *.db *.sqlite *.milvus @@ -56,76 +64,15 @@ junit.xml *.ckpt *.onnx -# 本地导出数据、临时csv/excel -data -data/tmp/ -data/output/ -*.csv -*.xlsx -*.parquet -# Python 缓存与编译文件 -__pycache__/ -*.py[cod] -*$py.class -*.so -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg - -# 虚拟环境(非常重要,防止把本地依赖包提交上去) -venv/ -env/ -.idea -.venv/ -ENV/ - -# 日志文件 -*.log - -# 操作系统文件 -.DS_Store -Thumbs.db - -# pytest 测试产物 -.pytest_cache/ -.coverage -coverage.xml -htmlcov/ -junit.xml - -# mypy 类型检查缓存 -.mypy_cache/ -# 向量库、本地数据库、模型文件(大文件不要提交git) -*.db -*.sqlite -*.milvus -*.neo4j -*.bin -*.pth -*.ckpt -*.onnx - -# 本地导出数据、临时csv/excel +# 本地导出数据、临时文件 +data/ data/tmp/ data/output/ *.csv *.xlsx *.parquet -# 本地临时需求&开发计划文档 +# 本地临时需求文档 DK2_客服Agent模块完整开发计划(v1.1).md DK4_客服Agent需求文档(修复完善版v1.4).md -客服Agent模块 · TODO List(最终修复版v1.2).md +客服Agent模块 · TODO List(最终修复版v1.2).md \ No newline at end of file diff --git a/api/chat/customer_agent.py b/api/chat/customer_agent.py index 9b0f47d..c1f059f 100644 --- a/api/chat/customer_agent.py +++ b/api/chat/customer_agent.py @@ -29,8 +29,10 @@ async def create_session(request: Request): return success({"session_id": session_id, "customer_id": None}) -@router.get("/chat") -async def chat(request: Request, session_id: str, query: str): +@router.post("/chat") +async def chat(request: Request, body: dict): + session_id = body.get("session_id", "") + query = body.get("query", "") runtime = _runtime(request) trace_id = request.headers.get("X-Trace-Id") or get_request_id() or new_request_id() try: @@ -79,4 +81,4 @@ async def end_session(request: Request, body: dict): f"session:{session_id}", f"session:{session_id}:messages", f"rate:limit:anon:{session_id}:chat", ) - return success({"session_id": session_id, "archived": False}) + return success({"session_id": session_id, "archived": False}) \ No newline at end of file diff --git a/logs/error.log b/logs/error.log deleted file mode 100644 index 1fe8a22..0000000 --- a/logs/error.log +++ /dev/null @@ -1,1442 +0,0 @@ -2026-09-11 15:07:01,773 ERROR [-] api: unhandled error on /api/knowledge/documents/preview -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 58, in preview_document_upload - form = await request.form() - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\requests.py", line 276, in _get_form - assert parse_options_header is not None, ( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -AssertionError: The `python-multipart` library must be installed to use form parsing. -2026-09-11 15:07:37,652 ERROR [-] api: unhandled error on /api/knowledge/documents/preview -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 58, in preview_document_upload - form = await request.form() - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\requests.py", line 276, in _get_form - assert parse_options_header is not None, ( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -AssertionError: The `python-multipart` library must be installed to use form parsing. -2026-09-11 15:08:14,610 ERROR [-] api: unhandled error on /api/knowledge/documents/preview -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 58, in preview_document_upload - form = await request.form() - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\requests.py", line 276, in _get_form - assert parse_options_header is not None, ( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -AssertionError: The `python-multipart` library must be installed to use form parsing. -2026-09-11 15:09:22,372 ERROR [-] api: unhandled error on /api/knowledge/documents/preview -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 62, in preview_document_upload - result = await _service(request).preview( - ^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 19, in _service - raise RuntimeError("knowledge upload service is not configured") -RuntimeError: knowledge upload service is not configured -2026-09-11 16:19:30,156 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 206, in confirm - exists = await exists - ^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 34, in document_exists_in_milvus - rows = await milvus.query( - ^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\milvus_client\async_milvus_client.py", line 642, in query - return await conn.query( - ^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 489, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 486, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 556, in async_handler - return await func(self, *args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 370, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 332, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\async_grpc_handler.py", line 1467, in query - check_status(response.status) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\utils.py", line 77, in check_status - raise MilvusException.from_status(status) -pymilvus.exceptions.MilvusException: -2026-09-11 16:19:37,338 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 206, in confirm - exists = await exists - ^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 34, in document_exists_in_milvus - rows = await milvus.query( - ^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\milvus_client\async_milvus_client.py", line 642, in query - return await conn.query( - ^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 489, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 486, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 556, in async_handler - return await func(self, *args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 370, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 332, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\async_grpc_handler.py", line 1467, in query - check_status(response.status) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\utils.py", line 77, in check_status - raise MilvusException.from_status(status) -pymilvus.exceptions.MilvusException: -2026-09-11 16:21:29,474 ERROR [a83edb036c014889] rag.embedding: embedding provider failed -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 -2026-09-11 16:21:29,478 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 224, in confirm - vectors = await self.embedder( - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\rag\embedding.py", line 25, in embed_texts - raise EmbeddingError("Embedding service unavailable") from exc -rag.embedding.EmbeddingError: Embedding service unavailable -2026-09-11 16:23:56,878 ERROR [f6a273b78c7d4843] rag.embedding: embedding provider failed -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 -2026-09-11 16:23:56,880 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 224, in confirm - vectors = await self.embedder( - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\rag\embedding.py", line 25, in embed_texts - raise EmbeddingError("Embedding service unavailable") from exc -rag.embedding.EmbeddingError: Embedding service unavailable -2026-09-11 16:24:47,041 ERROR [ed2fcc061b8b4461] rag.embedding: embedding provider failed -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 -2026-09-11 16:24:47,044 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 224, in confirm - vectors = await self.embedder( - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\rag\embedding.py", line 25, in embed_texts - raise EmbeddingError("Embedding service unavailable") from exc -rag.embedding.EmbeddingError: Embedding service unavailable -2026-09-11 16:40:05,491 ERROR [ff041f4e56dd45c9] rag.embedding: embedding provider failed -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 -2026-09-11 16:40:05,495 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 224, in confirm - vectors = await self.embedder( - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\rag\embedding.py", line 25, in embed_texts - raise EmbeddingError("Embedding service unavailable") from exc -rag.embedding.EmbeddingError: Embedding service unavailable -2026-09-11 16:41:22,853 ERROR [af03a1c5165340f1] rag.embedding: embedding provider failed -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 -2026-09-11 16:41:22,856 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 224, in confirm - vectors = await self.embedder( - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\rag\embedding.py", line 25, in embed_texts - raise EmbeddingError("Embedding service unavailable") from exc -rag.embedding.EmbeddingError: Embedding service unavailable -2026-09-11 16:50:56,366 ERROR [f38eae609cb84f12] service.knowledge_base.upload: knowledge update event publish failed for doc_id=公募基金操作知识 -Traceback (most recent call last): - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 284, in confirm - await publish_knowledge_update( - File "D:\Mutual_Fund\rag\events.py", line 19, in publish_knowledge_update - await publisher(KNOWLEDGE_UPDATE_EVENT, payload) - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 51, in publish_event - await redis.publish( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 929, in execute_command - conn = self.connection or await pool.get_connection() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\utils.py", line 249, in async_wrapper - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2824, in get_connection - await self.ensure_connection(connection) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2865, in ensure_connection - await connection.connect() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 819, in connect - await self.retry.call_with_retry( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 883, in connect_check_health - await self.on_connect_check_health(check_health=check_health) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1003, in on_connect_check_health - response = await self.read_response() - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1328, in read_response - raise response from None -redis.exceptions.ResponseError: unknown command `HELLO`, with args beginning with: `3`, -2026-09-11 16:50:56,787 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 284, in confirm - await publish_knowledge_update( - File "D:\Mutual_Fund\rag\events.py", line 19, in publish_knowledge_update - await publisher(KNOWLEDGE_UPDATE_EVENT, payload) - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 51, in publish_event - await redis.publish( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 929, in execute_command - conn = self.connection or await pool.get_connection() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\utils.py", line 249, in async_wrapper - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2824, in get_connection - await self.ensure_connection(connection) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2865, in ensure_connection - await connection.connect() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 819, in connect - await self.retry.call_with_retry( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 883, in connect_check_health - await self.on_connect_check_health(check_health=check_health) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1003, in on_connect_check_health - response = await self.read_response() - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1328, in read_response - raise response from None -redis.exceptions.ResponseError: unknown command `HELLO`, with args beginning with: `3`, -2026-09-11 16:51:18,924 ERROR [b3d3c87d09134d4b] service.knowledge_base.upload: knowledge update event publish failed for doc_id=公募基金操作知识 -Traceback (most recent call last): - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 284, in confirm - await publish_knowledge_update( - File "D:\Mutual_Fund\rag\events.py", line 19, in publish_knowledge_update - await publisher(KNOWLEDGE_UPDATE_EVENT, payload) - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 51, in publish_event - await redis.publish( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 929, in execute_command - conn = self.connection or await pool.get_connection() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\utils.py", line 249, in async_wrapper - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2824, in get_connection - await self.ensure_connection(connection) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2865, in ensure_connection - await connection.connect() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 819, in connect - await self.retry.call_with_retry( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 883, in connect_check_health - await self.on_connect_check_health(check_health=check_health) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1003, in on_connect_check_health - response = await self.read_response() - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1328, in read_response - raise response from None -redis.exceptions.ResponseError: unknown command `HELLO`, with args beginning with: `3`, -2026-09-11 16:51:19,384 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 284, in confirm - await publish_knowledge_update( - File "D:\Mutual_Fund\rag\events.py", line 19, in publish_knowledge_update - await publisher(KNOWLEDGE_UPDATE_EVENT, payload) - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 51, in publish_event - await redis.publish( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 929, in execute_command - conn = self.connection or await pool.get_connection() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\utils.py", line 249, in async_wrapper - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2824, in get_connection - await self.ensure_connection(connection) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2865, in ensure_connection - await connection.connect() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 819, in connect - await self.retry.call_with_retry( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 883, in connect_check_health - await self.on_connect_check_health(check_health=check_health) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1003, in on_connect_check_health - response = await self.read_response() - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1328, in read_response - raise response from None -redis.exceptions.ResponseError: unknown command `HELLO`, with args beginning with: `3`, -2026-09-11 17:22:54,820 ERROR [-] api: unhandled error on /api/knowledge/documents -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 32, in list_documents - return success(await _service(request).list_documents()) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 130, in list_documents - rows = await self.milvus_client.query( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\milvus_client\async_milvus_client.py", line 642, in query - return await conn.query( - ^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 489, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 486, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 556, in async_handler - return await func(self, *args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 370, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 332, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\async_grpc_handler.py", line 1467, in query - check_status(response.status) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\utils.py", line 77, in check_status - raise MilvusException.from_status(status) -pymilvus.exceptions.MilvusException: -2026-09-11 17:25:39,869 ERROR [-] api: unhandled error on /api/knowledge/documents -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 32, in list_documents - return success(await _service(request).list_documents()) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 130, in list_documents - rows = await self.milvus_client.query( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\milvus_client\async_milvus_client.py", line 642, in query - return await conn.query( - ^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 489, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 486, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 556, in async_handler - return await func(self, *args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 370, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 332, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\async_grpc_handler.py", line 1467, in query - check_status(response.status) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\utils.py", line 77, in check_status - raise MilvusException.from_status(status) -pymilvus.exceptions.MilvusException: -2026-09-11 17:26:22,071 ERROR [-] api: unhandled error on /api/knowledge/documents -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 32, in list_documents - return success(await _service(request).list_documents()) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 130, in list_documents - rows = await self.milvus_client.query( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\milvus_client\async_milvus_client.py", line 642, in query - return await conn.query( - ^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 489, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 486, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 556, in async_handler - return await func(self, *args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 370, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 332, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\async_grpc_handler.py", line 1467, in query - check_status(response.status) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\utils.py", line 77, in check_status - raise MilvusException.from_status(status) -pymilvus.exceptions.MilvusException: -2026-09-11 17:38:58,890 ERROR [-] api: unhandled error on /api/agent/customer/session/create -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\windows_events.py", line 462, in finish_socket_func - return ov.getresult() - ^^^^^^^^^^^^^^ -OSError: [WinError 64] 指定的网络名不再可用。 - -During handling of the above exception, another exception occurred: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1286, in read_response - response = await self._read_response_from_parser( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1338, in _read_response_from_parser - return await self._parser.read_response(disable_decoding=disable_decoding) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\_parsers\resp2.py", line 89, in read_response - response = await self._read_response(disable_decoding=disable_decoding) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\_parsers\resp2.py", line 97, in _read_response - raw = await self._readline() - ^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\_parsers\base.py", line 587, in _readline - data = await self._stream.readline() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\streams.py", line 568, in readline - line = await self.readuntil(sep) - ^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\streams.py", line 660, in readuntil - await self._wait_for_data('readuntil') - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\streams.py", line 545, in _wait_for_data - await self._waiter - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\proactor_events.py", line 286, in _loop_reading - length = fut.result() - ^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\windows_events.py", line 803, in _poll - value = callback(transferred, key, ov) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\windows_events.py", line 466, in finish_socket_func - raise ConnectionResetError(*exc.args) -ConnectionResetError: [WinError 64] 指定的网络名不再可用。 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\customer_agent.py", line 28, in create_session - session_id = await runtime.session_service.create_session() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\agent\customer_agent\session.py", line 34, in create_session - await self.redis.rpush(f"session:{session_id}:messages", "") - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 946, in execute_command - result = await conn.retry.call_with_retry( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 871, in _send_command_parse_response - return await self.parse_response(conn, command_name, **options) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 993, in parse_response - response = await connection.read_response() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1314, in read_response - raise ConnectionError(f"Error while reading from {host_error} : {e.args}") -redis.exceptions.ConnectionError: Error while reading from localhost:6379 : (22, '指定的网络名不再可用。', None, 64, None) diff --git a/logs/info.log b/logs/info.log deleted file mode 100644 index 610ae53..0000000 --- a/logs/info.log +++ /dev/null @@ -1,1457 +0,0 @@ -2026-09-11 15:07:01,773 ERROR [-] api: unhandled error on /api/knowledge/documents/preview -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 58, in preview_document_upload - form = await request.form() - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\requests.py", line 276, in _get_form - assert parse_options_header is not None, ( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -AssertionError: The `python-multipart` library must be installed to use form parsing. -2026-09-11 15:07:37,652 ERROR [-] api: unhandled error on /api/knowledge/documents/preview -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 58, in preview_document_upload - form = await request.form() - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\requests.py", line 276, in _get_form - assert parse_options_header is not None, ( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -AssertionError: The `python-multipart` library must be installed to use form parsing. -2026-09-11 15:08:14,610 ERROR [-] api: unhandled error on /api/knowledge/documents/preview -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 58, in preview_document_upload - form = await request.form() - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\requests.py", line 276, in _get_form - assert parse_options_header is not None, ( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -AssertionError: The `python-multipart` library must be installed to use form parsing. -2026-09-11 15:09:22,372 ERROR [-] api: unhandled error on /api/knowledge/documents/preview -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 62, in preview_document_upload - result = await _service(request).preview( - ^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 19, in _service - raise RuntimeError("knowledge upload service is not configured") -RuntimeError: knowledge upload service is not configured -2026-09-11 16:19:30,156 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 206, in confirm - exists = await exists - ^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 34, in document_exists_in_milvus - rows = await milvus.query( - ^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\milvus_client\async_milvus_client.py", line 642, in query - return await conn.query( - ^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 489, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 486, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 556, in async_handler - return await func(self, *args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 370, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 332, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\async_grpc_handler.py", line 1467, in query - check_status(response.status) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\utils.py", line 77, in check_status - raise MilvusException.from_status(status) -pymilvus.exceptions.MilvusException: -2026-09-11 16:19:37,338 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 206, in confirm - exists = await exists - ^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 34, in document_exists_in_milvus - rows = await milvus.query( - ^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\milvus_client\async_milvus_client.py", line 642, in query - return await conn.query( - ^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 489, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 486, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 556, in async_handler - return await func(self, *args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 370, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 332, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\async_grpc_handler.py", line 1467, in query - check_status(response.status) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\utils.py", line 77, in check_status - raise MilvusException.from_status(status) -pymilvus.exceptions.MilvusException: -2026-09-11 16:21:29,474 INFO [a83edb036c014889] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 502 Bad Gateway" -2026-09-11 16:21:29,474 ERROR [a83edb036c014889] rag.embedding: embedding provider failed -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 -2026-09-11 16:21:29,478 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 224, in confirm - vectors = await self.embedder( - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\rag\embedding.py", line 25, in embed_texts - raise EmbeddingError("Embedding service unavailable") from exc -rag.embedding.EmbeddingError: Embedding service unavailable -2026-09-11 16:23:56,878 INFO [f6a273b78c7d4843] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 502 Bad Gateway" -2026-09-11 16:23:56,878 ERROR [f6a273b78c7d4843] rag.embedding: embedding provider failed -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 -2026-09-11 16:23:56,880 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 224, in confirm - vectors = await self.embedder( - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\rag\embedding.py", line 25, in embed_texts - raise EmbeddingError("Embedding service unavailable") from exc -rag.embedding.EmbeddingError: Embedding service unavailable -2026-09-11 16:24:47,041 INFO [ed2fcc061b8b4461] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 502 Bad Gateway" -2026-09-11 16:24:47,041 ERROR [ed2fcc061b8b4461] rag.embedding: embedding provider failed -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 -2026-09-11 16:24:47,044 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 224, in confirm - vectors = await self.embedder( - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\rag\embedding.py", line 25, in embed_texts - raise EmbeddingError("Embedding service unavailable") from exc -rag.embedding.EmbeddingError: Embedding service unavailable -2026-09-11 16:40:05,491 INFO [ff041f4e56dd45c9] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 502 Bad Gateway" -2026-09-11 16:40:05,491 ERROR [ff041f4e56dd45c9] rag.embedding: embedding provider failed -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 -2026-09-11 16:40:05,495 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 224, in confirm - vectors = await self.embedder( - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\rag\embedding.py", line 25, in embed_texts - raise EmbeddingError("Embedding service unavailable") from exc -rag.embedding.EmbeddingError: Embedding service unavailable -2026-09-11 16:41:22,853 INFO [af03a1c5165340f1] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 502 Bad Gateway" -2026-09-11 16:41:22,853 ERROR [af03a1c5165340f1] rag.embedding: embedding provider failed -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 -2026-09-11 16:41:22,856 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Mutual_Fund\rag\embedding.py", line 22, in embed_texts - vectors = await provider.embed(texts) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\tool\llm.py", line 116, in embed - r.raise_for_status() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\httpx\_models.py", line 829, in raise_for_status - raise HTTPStatusError(message, request=request, response=self) -httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:11434/v1/embeddings' -For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 224, in confirm - vectors = await self.embedder( - ^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\rag\embedding.py", line 25, in embed_texts - raise EmbeddingError("Embedding service unavailable") from exc -rag.embedding.EmbeddingError: Embedding service unavailable -2026-09-11 16:50:56,234 INFO [f38eae609cb84f12] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 200 OK" -2026-09-11 16:50:56,366 ERROR [f38eae609cb84f12] service.knowledge_base.upload: knowledge update event publish failed for doc_id=公募基金操作知识 -Traceback (most recent call last): - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 284, in confirm - await publish_knowledge_update( - File "D:\Mutual_Fund\rag\events.py", line 19, in publish_knowledge_update - await publisher(KNOWLEDGE_UPDATE_EVENT, payload) - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 51, in publish_event - await redis.publish( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 929, in execute_command - conn = self.connection or await pool.get_connection() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\utils.py", line 249, in async_wrapper - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2824, in get_connection - await self.ensure_connection(connection) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2865, in ensure_connection - await connection.connect() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 819, in connect - await self.retry.call_with_retry( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 883, in connect_check_health - await self.on_connect_check_health(check_health=check_health) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1003, in on_connect_check_health - response = await self.read_response() - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1328, in read_response - raise response from None -redis.exceptions.ResponseError: unknown command `HELLO`, with args beginning with: `3`, -2026-09-11 16:50:56,787 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 284, in confirm - await publish_knowledge_update( - File "D:\Mutual_Fund\rag\events.py", line 19, in publish_knowledge_update - await publisher(KNOWLEDGE_UPDATE_EVENT, payload) - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 51, in publish_event - await redis.publish( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 929, in execute_command - conn = self.connection or await pool.get_connection() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\utils.py", line 249, in async_wrapper - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2824, in get_connection - await self.ensure_connection(connection) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2865, in ensure_connection - await connection.connect() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 819, in connect - await self.retry.call_with_retry( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 883, in connect_check_health - await self.on_connect_check_health(check_health=check_health) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1003, in on_connect_check_health - response = await self.read_response() - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1328, in read_response - raise response from None -redis.exceptions.ResponseError: unknown command `HELLO`, with args beginning with: `3`, -2026-09-11 16:51:18,892 INFO [b3d3c87d09134d4b] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 200 OK" -2026-09-11 16:51:18,924 ERROR [b3d3c87d09134d4b] service.knowledge_base.upload: knowledge update event publish failed for doc_id=公募基金操作知识 -Traceback (most recent call last): - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 284, in confirm - await publish_knowledge_update( - File "D:\Mutual_Fund\rag\events.py", line 19, in publish_knowledge_update - await publisher(KNOWLEDGE_UPDATE_EVENT, payload) - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 51, in publish_event - await redis.publish( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 929, in execute_command - conn = self.connection or await pool.get_connection() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\utils.py", line 249, in async_wrapper - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2824, in get_connection - await self.ensure_connection(connection) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2865, in ensure_connection - await connection.connect() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 819, in connect - await self.retry.call_with_retry( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 883, in connect_check_health - await self.on_connect_check_health(check_health=check_health) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1003, in on_connect_check_health - response = await self.read_response() - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1328, in read_response - raise response from None -redis.exceptions.ResponseError: unknown command `HELLO`, with args beginning with: `3`, -2026-09-11 16:51:19,384 ERROR [-] api: unhandled error on /api/knowledge/documents/confirm -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 85, in confirm_document_upload - result = await _service(request).confirm( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 284, in confirm - await publish_knowledge_update( - File "D:\Mutual_Fund\rag\events.py", line 19, in publish_knowledge_update - await publisher(KNOWLEDGE_UPDATE_EVENT, payload) - File "D:\Mutual_Fund\service\customer_agent\bootstrap.py", line 51, in publish_event - await redis.publish( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 929, in execute_command - conn = self.connection or await pool.get_connection() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\utils.py", line 249, in async_wrapper - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2824, in get_connection - await self.ensure_connection(connection) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 2865, in ensure_connection - await connection.connect() - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 819, in connect - await self.retry.call_with_retry( - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 883, in connect_check_health - await self.on_connect_check_health(check_health=check_health) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1003, in on_connect_check_health - response = await self.read_response() - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1328, in read_response - raise response from None -redis.exceptions.ResponseError: unknown command `HELLO`, with args beginning with: `3`, -2026-09-11 16:53:37,020 INFO [304b872873d747c4] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 200 OK" -2026-09-11 17:00:11,008 INFO [9f6c6252d294401c] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 200 OK" -2026-09-11 17:02:26,531 INFO [737b2ac781414711] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 200 OK" -2026-09-11 17:04:18,312 INFO [e36a83dc41644fae] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 200 OK" -2026-09-11 17:07:19,459 INFO [75c94c9d84d84ec6] httpx: HTTP Request: POST http://localhost:11434/v1/embeddings "HTTP/1.1 200 OK" -2026-09-11 17:22:54,820 ERROR [-] api: unhandled error on /api/knowledge/documents -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 32, in list_documents - return success(await _service(request).list_documents()) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 130, in list_documents - rows = await self.milvus_client.query( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\milvus_client\async_milvus_client.py", line 642, in query - return await conn.query( - ^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 489, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 486, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 556, in async_handler - return await func(self, *args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 370, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 332, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\async_grpc_handler.py", line 1467, in query - check_status(response.status) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\utils.py", line 77, in check_status - raise MilvusException.from_status(status) -pymilvus.exceptions.MilvusException: -2026-09-11 17:25:39,869 ERROR [-] api: unhandled error on /api/knowledge/documents -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 32, in list_documents - return success(await _service(request).list_documents()) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 130, in list_documents - rows = await self.milvus_client.query( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\milvus_client\async_milvus_client.py", line 642, in query - return await conn.query( - ^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 489, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 486, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 556, in async_handler - return await func(self, *args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 370, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 332, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\async_grpc_handler.py", line 1467, in query - check_status(response.status) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\utils.py", line 77, in check_status - raise MilvusException.from_status(status) -pymilvus.exceptions.MilvusException: -2026-09-11 17:26:22,071 ERROR [-] api: unhandled error on /api/knowledge/documents -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\knowledge.py", line 32, in list_documents - return success(await _service(request).list_documents()) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\service\knowledge_base\upload.py", line 130, in list_documents - rows = await self.milvus_client.query( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\milvus_client\async_milvus_client.py", line 642, in query - return await conn.query( - ^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 489, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 486, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 556, in async_handler - return await func(self, *args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 370, in async_handler - raise e from e - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\decorators.py", line 332, in async_handler - return await func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\async_grpc_handler.py", line 1467, in query - check_status(response.status) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\pymilvus\client\utils.py", line 77, in check_status - raise MilvusException.from_status(status) -pymilvus.exceptions.MilvusException: -2026-09-11 17:38:58,890 ERROR [-] api: unhandled error on /api/agent/customer/session/create -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\windows_events.py", line 462, in finish_socket_func - return ov.getresult() - ^^^^^^^^^^^^^^ -OSError: [WinError 64] 指定的网络名不再可用。 - -During handling of the above exception, another exception occurred: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1286, in read_response - response = await self._read_response_from_parser( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1338, in _read_response_from_parser - return await self._parser.read_response(disable_decoding=disable_decoding) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\_parsers\resp2.py", line 89, in read_response - response = await self._read_response(disable_decoding=disable_decoding) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\_parsers\resp2.py", line 97, in _read_response - raw = await self._readline() - ^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\_parsers\base.py", line 587, in _readline - data = await self._stream.readline() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\streams.py", line 568, in readline - line = await self.readuntil(sep) - ^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\streams.py", line 660, in readuntil - await self._wait_for_data('readuntil') - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\streams.py", line 545, in _wait_for_data - await self._waiter - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\proactor_events.py", line 286, in _loop_reading - length = fut.result() - ^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\windows_events.py", line 803, in _poll - value = callback(transferred, key, ov) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\asyncio\windows_events.py", line 466, in finish_socket_func - raise ConnectionResetError(*exc.args) -ConnectionResetError: [WinError 64] 指定的网络名不再可用。 - -The above exception was the direct cause of the following exception: - -Traceback (most recent call last): - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\errors.py", line 164, in __call__ - await self.app(scope, receive, _send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 193, in __call__ - response = await self.dispatch_func(request, call_next) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\utils\request_id.py", line 28, in dispatch - response: Response = await call_next(request) - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 168, in call_next - raise app_exc from app_exc.__cause__ or app_exc.__context__ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\base.py", line 144, in coro - await self.app(scope, receive_or_disconnect, send_no_error) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 63, in __call__ - await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__ - await self.app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\routing.py", line 670, in __call__ - await self.middleware_stack(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2734, in app - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1791, in _handle_selected - await route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1780, in handle - await self.original_router.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 2789, in handle - await included_router._handle_selected(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1800, in _handle_selected - await original_route.handle(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 1279, in handle - await app(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 158, in app - await wrap_app_handling_exceptions(app, request)(scope, receive, send) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app - raise exc - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app - await app(scope, receive, sender) - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 144, in app - response = await f(request) - ^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 706, in app - raw_response = await run_endpoint_function( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\fastapi\routing.py", line 352, in run_endpoint_function - return await dependant.call(**values) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\api\chat\customer_agent.py", line 28, in create_session - session_id = await runtime.session_service.create_session() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Mutual_Fund\agent\customer_agent\session.py", line 34, in create_session - await self.redis.rpush(f"session:{session_id}:messages", "") - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 946, in execute_command - result = await conn.retry.call_with_retry( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 871, in _send_command_parse_response - return await self.parse_response(conn, command_name, **options) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\client.py", line 993, in parse_response - response = await connection.read_response() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "D:\Projects\py_environment\test_py3.12\Lib\site-packages\redis\asyncio\connection.py", line 1314, in read_response - raise ConnectionError(f"Error while reading from {host_error} : {e.args}") -redis.exceptions.ConnectionError: Error while reading from localhost:6379 : (22, '指定的网络名不再可用。', None, 64, None) -2026-09-11 19:05:28,328 INFO [06a2204f886d4f00] httpx: HTTP Request: POST http://localhost:11434/v1/chat/completions "HTTP/1.1 200 OK" -2026-09-11 19:06:29,071 INFO [02c18211e6df4923] httpx: HTTP Request: POST http://localhost:11434/v1/chat/completions "HTTP/1.1 200 OK" -2026-09-11 19:07:25,590 INFO [1ae065ab5c224a8e] httpx: HTTP Request: POST http://localhost:11434/v1/chat/completions "HTTP/1.1 200 OK" diff --git a/rag/intent.py b/rag/intent.py index cf51eff..a10c44c 100644 --- a/rag/intent.py +++ b/rag/intent.py @@ -26,7 +26,17 @@ async def intent_recognize(query: str, *, llm_client) -> Intent: messages = [ { "role": "system", - "content": "仅返回一个意图枚举值,不要输出解释。", + "content": ( + "你是一个意图分类器。请根据用户输入,从以下选项中选择最匹配的意图," + "并仅输出对应的英文标签(不输出任何其他内容):\n" + "- guide_purchase: 用户询问如何购买基金、开户、注册等引导类问题\n" + "- want_advisor: 用户希望获得个性化基金推荐或投资顾问服务\n" + "- knowledge_qa: 用户询问基金相关的知识性问题,如净值、费率、风险等\n" + "- nl2sql_request: 用户要求查询具体数据或账户信息\n" + "- complain: 用户表达不满或投诉\n" + "- no_match: 以上都不匹配\n" + "仅输出一个小写英文标签,不要输出解释、标点或换行。" + ), }, {"role": "user", "content": query}, ] @@ -36,4 +46,4 @@ async def intent_recognize(query: str, *, llm_client) -> Intent: logger.exception("intent recognition failed") return Intent.NO_MATCH value = raw.strip().strip('`').lower() - return Intent(value) if value in INTENT_VALUES else Intent.NO_MATCH + return Intent(value) if value in INTENT_VALUES else Intent.NO_MATCH \ No newline at end of file diff --git a/rag/retrieve.py b/rag/retrieve.py index 8c7a02d..4fd41ae 100644 --- a/rag/retrieve.py +++ b/rag/retrieve.py @@ -11,9 +11,9 @@ logger = logging.getLogger("rag.retrieve") BUSINESS_RETRIEVAL = ( - ("fin_faq", "faq", 3, 0.75), - ("fin_fund_doc", "funddoc", 5, 0.70), - ("fin_policy", "policy", 5, 0.70), + ("fin_faq", "faq", 3, 0.40), + ("fin_fund_doc", "funddoc", 5, 0.35), + ("fin_policy", "policy", 5, 0.35), ) @@ -87,7 +87,12 @@ def _format_candidates(candidates) -> list[dict]: threshold = candidate["threshold"] for hit in _flatten_hits(candidate["results"]): entity = hit.get("entity") or hit - score = hit.get("distance", hit.get("score")) + distance = hit.get("distance") + raw_score = hit.get("score") + if distance is not None: + score = 1.0 - distance + else: + score = raw_score if score is None or score < threshold: continue sources.append( @@ -155,4 +160,4 @@ async def retrieve_with_status( except Exception: logger.exception("Milvus retrieval failed") return {"status": "milvus_unavailable", "sources": []} - return {"status": "ok", "sources": _format_candidates(candidates)} + return {"status": "ok", "sources": _format_candidates(candidates)} \ No newline at end of file diff --git a/tests/test_agent_context.py b/tests/test_agent_context.py deleted file mode 100644 index 2bf997c..0000000 --- a/tests/test_agent_context.py +++ /dev/null @@ -1,56 +0,0 @@ -import json -import unittest - -from agent.customer_agent.context import RedisConversationContext - - -class ContextRedis: - def __init__(self): - self.values = {} - - async def rpush(self, key, value): - self.values.setdefault(key, []).append(value) - - async def lrange(self, key, start, end): - values = self.values.get(key, [])[start:] - return values if end == -1 else values[: end - start + 1] - - async def ltrim(self, key, start, end): - values = self.values.get(key, [])[start:] - self.values[key] = values if end == -1 else values[: end - start + 1] - - async def expire(self, key, seconds): - pass - - -class ContextTests(unittest.IsolatedAsyncioTestCase): - async def test_appends_messages_and_trims_oldest_when_token_limit_is_exceeded(self): - redis = ContextRedis() - context = RedisConversationContext( - redis, - config_getter={ - "agent.customer.session_max_token": "5", - "agent.customer.session.ttl": "120", - }.get, - token_counter=lambda text: len(text), - ) - - await context.append("s1", "user", "123") - await context.append("s1", "assistant", "456") - await context.append("s1", "user", "789") - - messages = await context.get("s1") - self.assertEqual([item["content"] for item in messages], ["789"]) - - async def test_message_payload_is_structured_json(self): - redis = ContextRedis() - context = RedisConversationContext(redis, config_getter={}.get) - - await context.append("s1", "user", "基金是什么") - - raw = redis.values["session:s1:messages"][0] - self.assertEqual(json.loads(raw)["role"], "user") - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_agent_session.py b/tests/test_agent_session.py deleted file mode 100644 index f8f9d8e..0000000 --- a/tests/test_agent_session.py +++ /dev/null @@ -1,88 +0,0 @@ -import unittest - -from agent.customer_agent.session import AnonymousSessionService, SessionOwnershipError - - -class FakeRedis: - def __init__(self): - self.values = {} - self.lists = {} - self.sorted_sets = {} - self.expirations = {} - - async def set(self, key, value, ex=None): - self.values[key] = value - if ex is not None: - self.expirations[key] = ex - - async def exists(self, key): - return int(key in self.values or key in self.lists) - - async def rpush(self, key, value): - self.lists.setdefault(key, []).append(value) - return len(self.lists[key]) - - async def expire(self, key, seconds): - self.expirations[key] = seconds - - async def zremrangebyscore(self, key, minimum, maximum): - self.sorted_sets[key] = [item for item in self.sorted_sets.get(key, []) if item[0] > maximum] - - async def zadd(self, key, mapping): - self.sorted_sets.setdefault(key, []).extend((score, member) for member, score in mapping.items()) - - async def zcard(self, key): - return len(self.sorted_sets.get(key, [])) - - -class SessionTests(unittest.IsolatedAsyncioTestCase): - async def test_create_initializes_anonymous_session_and_message_list(self): - redis = FakeRedis() - service = AnonymousSessionService(redis, config_getter={"agent.customer.session.ttl": "120"}.get) - - session_id = await service.create_session() - - self.assertEqual(len(session_id), 32) - self.assertIn(f"session:{session_id}", redis.values) - self.assertIn(f"session:{session_id}:messages", redis.lists) - self.assertEqual(redis.expirations[f"session:{session_id}"], 120) - - async def test_missing_session_raises_not_found(self): - service = AnonymousSessionService(FakeRedis(), config_getter={}.get) - - with self.assertRaises(SessionOwnershipError) as ctx: - await service.verify_session_ownership("missing") - - self.assertEqual(ctx.exception.code, 404) - - async def test_authenticated_owner_mismatch_raises_forbidden(self): - redis = FakeRedis() - service = AnonymousSessionService(redis, config_getter={}.get) - session_id = await service.create_session() - - with self.assertRaises(SessionOwnershipError) as ctx: - await service.verify_session_ownership(session_id, customer_id="customer-1", session_customer_id="customer-2") - - self.assertEqual(ctx.exception.code, 403) - - async def test_rate_limit_uses_sliding_window_and_returns_retry_after(self): - redis = FakeRedis() - service = AnonymousSessionService( - redis, - config_getter={ - "agent.customer.rate_limit.window_sec": "60", - "agent.customer.rate_limit.max_requests": "1", - "agent.customer.session.ttl": "120", - }.get, - clock=lambda: 100.0, - ) - await service.create_session() - - self.assertEqual(await service.consume_chat_quota("s"), None) - retry_after = await service.consume_chat_quota("s") - - self.assertEqual(retry_after, 60) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_anonymous_agent_service.py b/tests/test_anonymous_agent_service.py deleted file mode 100644 index e6c727e..0000000 --- a/tests/test_anonymous_agent_service.py +++ /dev/null @@ -1,94 +0,0 @@ -import unittest -from unittest.mock import AsyncMock - -from rag.intent import Intent -from service.customer_agent.chat import AnonymousCustomerAgent, QueryTooLongError - - -class AnonymousAgentTests(unittest.IsolatedAsyncioTestCase): - def _build(self, intent, sources=None, answer="LLM answer"): - context = AsyncMock() - rag = AsyncMock(return_value=sources or []) - recognize = AsyncMock(return_value=intent) - generate = AsyncMock(return_value=answer) - audit = AsyncMock() - config = { - "agent.customer.template.guide_purchase": "请前往开户页面办理", - "agent.customer.template.guide_advisor": "如需推荐,请联系投顾", - "agent.customer.template.fallback_human": "请转人工客服", - } - service = AnonymousCustomerAgent( - context=context, - rag_retrieve=rag, - intent_recognize=recognize, - generate_answer=generate, - audit_writer=audit, - config_getter=config.get, - ) - return service, context, rag, recognize, generate, audit - - async def test_knowledge_question_uses_rag_without_customer_memory(self): - service, context, rag, _, generate, _ = self._build( - Intent.KNOWLEDGE_QA, - sources=[{"doc_id": "d1", "chunk_text": "基金正文", "score": 0.9}], - ) - - result = await service.handle("s1", "基金是什么", trace_id="trace-1") - - rag.assert_awaited_once_with("基金是什么", None) - generate.assert_awaited_once() - self.assertEqual(result["sources"][0]["doc_id"], "d1") - self.assertEqual(result["trace_id"], "trace-1") - self.assertEqual(context.append.await_count, 2) - - async def test_recommendation_returns_fixed_advisor_guidance_without_llm(self): - service, _, rag, _, generate, _ = self._build(Intent.WANT_ADVISOR) - - result = await service.handle("s1", "给我推荐一只基金", trace_id="trace-2") - - self.assertEqual(result["answer"], "如需推荐,请联系投顾") - rag.assert_not_awaited() - generate.assert_not_awaited() - self.assertEqual(result["sources"], []) - - async def test_sensitive_input_is_audited_and_no_private_data_is_loaded(self): - service, _, rag, _, generate, audit = self._build(Intent.KNOWLEDGE_QA, sources=[]) - - await service.handle("s1", "我的手机号是13812345678", trace_id="trace-3") - - audit.assert_awaited_once() - self.assertEqual(audit.await_args.kwargs["action"], "anon_sensitive_input") - self.assertEqual(audit.await_args.kwargs["trace_id"], "trace-3") - rag.assert_awaited_once_with("我的手机号是13812345678", None) - generate.assert_not_awaited() - - async def test_query_over_2000_characters_is_rejected(self): - service, *_ = self._build(Intent.KNOWLEDGE_QA) - - with self.assertRaises(QueryTooLongError): - await service.handle("s1", "x" * 2001, trace_id="trace-4") - - async def test_milvus_failure_returns_human_fallback(self): - service, _, rag, _, generate, _ = self._build(Intent.KNOWLEDGE_QA) - rag.side_effect = TimeoutError("Milvus down") - - result = await service.handle("s1", "基金是什么", trace_id="trace-5") - - self.assertEqual(result["answer"], "请转人工客服") - generate.assert_not_awaited() - - async def test_llm_failure_returns_human_fallback_without_fake_sources(self): - service, _, _, _, generate, _ = self._build( - Intent.KNOWLEDGE_QA, - sources=[{"doc_id": "d1", "chunk_text": "正文", "score": 0.8}], - ) - generate.side_effect = RuntimeError("LLM down") - - result = await service.handle("s1", "基金是什么", trace_id="trace-6") - - self.assertEqual(result["answer"], "请转人工客服") - self.assertEqual(result["sources"][0]["doc_id"], "d1") - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_chunk_config.py b/tests/test_chunk_config.py deleted file mode 100644 index a7841b8..0000000 --- a/tests/test_chunk_config.py +++ /dev/null @@ -1,29 +0,0 @@ -import unittest - -from rag.chunk_config import DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, resolve_chunk_config - - -class ChunkConfigTests(unittest.TestCase): - def test_uses_project_defaults_without_sys_config(self): - config = resolve_chunk_config() - - self.assertEqual(config.size, DEFAULT_CHUNK_SIZE) - self.assertEqual(config.overlap, DEFAULT_CHUNK_OVERLAP) - self.assertEqual((config.size, config.overlap), (512, 64)) - - def test_custom_values_override_defaults_independently(self): - config = resolve_chunk_config(chunk_size=256) - - self.assertEqual((config.size, config.overlap), (256, 64)) - - def test_rejects_invalid_chunk_values(self): - with self.assertRaises(ValueError): - resolve_chunk_config(chunk_size=0) - with self.assertRaises(ValueError): - resolve_chunk_config(chunk_size=64, chunk_overlap=64) - with self.assertRaises(ValueError): - resolve_chunk_config(chunk_overlap=-1) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_chunking.py b/tests/test_chunking.py deleted file mode 100644 index 017861d..0000000 --- a/tests/test_chunking.py +++ /dev/null @@ -1,88 +0,0 @@ -import unittest - -from rag.chunk_config import ChunkConfig -from rag.chunking import chunk_document - - -class DefaultChunkingTests(unittest.TestCase): - def test_keeps_short_paragraphs_as_separate_chunks(self): - result = chunk_document( - "第一段内容。\n\n第二段内容。", - "default", - config=ChunkConfig(size=64, overlap=4), - ) - - self.assertEqual([chunk.text for chunk in result.chunks], ["第一段内容。", "第二段内容。"]) - self.assertEqual(result.actual_strategy, "default") - self.assertFalse(result.degraded) - - def test_splits_long_paragraphs_with_overlap(self): - result = chunk_document( - "abcdefghij" * 3, - "default", - config=ChunkConfig(size=10, overlap=2), - ) - - self.assertGreater(len(result.chunks), 1) - self.assertTrue(all(len(chunk.text) <= 10 for chunk in result.chunks)) - self.assertEqual(result.chunks[0].text[-2:], result.chunks[1].text[:2]) - - -class QaPairChunkingTests(unittest.TestCase): - def test_keeps_each_question_and_answer_together(self): - result = chunk_document( - "Q: 什么是净值?\nA: 净值是基金单位价值。\nQ: 如何申购?\nA: 通过交易页面申购。", - "qa_pair", - config=ChunkConfig(size=64, overlap=4), - ) - - self.assertEqual(len(result.chunks), 2) - self.assertIn("question: 什么是净值?", result.chunks[0].text) - self.assertIn("answer: 净值是基金单位价值。", result.chunks[0].text) - - def test_rejects_missing_qa_markers(self): - with self.assertRaises(ValueError): - chunk_document("普通文本,没有问答标记", "qa_pair") - - def test_rejects_the_whole_document_when_one_pair_is_too_long(self): - text = "Q: 短问题\nA: 短答案\nQ: 长问题\nA: " + ("很长" * 20) - - with self.assertRaises(ValueError): - chunk_document(text, "qa_pair", config=ChunkConfig(size=20, overlap=2)) - - -class ChapterChunkingTests(unittest.TestCase): - def test_preserves_nested_heading_path(self): - result = chunk_document( - "# 产品说明\n## 风险揭示\n风险内容。", - "chapter_semantic", - config=ChunkConfig(size=64, overlap=4), - ) - - self.assertEqual(result.actual_strategy, "chapter_semantic") - self.assertEqual(result.chunks[0].section_title, "产品说明 > 风险揭示") - self.assertTrue(result.chunks[0].text.startswith("【章节:产品说明 > 风险揭示】")) - - def test_splits_only_inside_a_chapter(self): - result = chunk_document( - "# 第一章\n" + ("甲" * 20) + "\n# 第二章\n" + ("乙" * 20), - "chapter_semantic", - config=ChunkConfig(size=16, overlap=2), - ) - - self.assertTrue(all("甲" not in chunk.text or "乙" not in chunk.text for chunk in result.chunks)) - - def test_degrades_to_default_without_headings(self): - result = chunk_document( - "没有Markdown标题的普通内容。", - "chapter_semantic", - config=ChunkConfig(size=64, overlap=4), - ) - - self.assertEqual(result.actual_strategy, "default") - self.assertTrue(result.degraded) - self.assertTrue(result.warning) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_cleaning.py b/tests/test_cleaning.py deleted file mode 100644 index 610c703..0000000 --- a/tests/test_cleaning.py +++ /dev/null @@ -1,30 +0,0 @@ -import unittest - -from rag.cleaning import clean_document_text - - -class CleaningTests(unittest.TestCase): - def test_normalizes_bom_line_endings_whitespace_and_blank_lines(self): - result = clean_document_text("\ufeff标题\r\n\r\n\r\n段落\t 内容\x00") - - self.assertEqual(result.text, "标题\n\n段落 内容") - self.assertTrue(result.changed) - self.assertTrue(result.warnings) - - def test_removes_standalone_page_markers_but_keeps_business_numbers(self): - result = clean_document_text("产品代码 110011\n第 1 页\n年化收益率 3.5%\nPage 2") - - self.assertEqual(result.text, "产品代码 110011\n年化收益率 3.5%") - self.assertIn("110011", result.text) - - def test_does_not_remove_meaningful_content(self): - text = "基金名称:示例基金\n风险等级:R3\n申购费率:1.2%" - - result = clean_document_text(text) - - self.assertEqual(result.text, text) - self.assertFalse(result.changed) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_customer_agent_audit.py b/tests/test_customer_agent_audit.py deleted file mode 100644 index 2924533..0000000 --- a/tests/test_customer_agent_audit.py +++ /dev/null @@ -1,24 +0,0 @@ -import unittest -from unittest.mock import AsyncMock - -from service.customer_agent.audit import write_anonymous_sensitive_audit - - -class AuditTests(unittest.IsolatedAsyncioTestCase): - async def test_writes_sensitive_anonymous_action_with_trace_id(self): - db = AsyncMock() - - await write_anonymous_sensitive_audit( - db, session_id="s1", trace_id="trace-1" - ) - - db.execute.assert_awaited_once() - db.commit.assert_awaited_once() - params = db.execute.await_args.args[1] - self.assertEqual(params["action"], "anon_sensitive_input") - self.assertEqual(params["trace_id"], "trace-1") - self.assertEqual(params["target"], "s1") - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_customer_agent_bootstrap.py b/tests/test_customer_agent_bootstrap.py deleted file mode 100644 index d6b41cd..0000000 --- a/tests/test_customer_agent_bootstrap.py +++ /dev/null @@ -1,42 +0,0 @@ -import asyncio -import unittest -from unittest.mock import patch - -from service.customer_agent.bootstrap import build_default_runtime, document_exists_in_milvus - - -class BootstrapTests(unittest.TestCase): - def test_document_exists_checks_all_knowledge_collections(self): - class FakeMilvus: - def __init__(self): - self.calls = [] - - async def query(self, **kwargs): - self.calls.append(kwargs) - return [{"doc_id": "doc-1"}] if kwargs["collection_name"] == "fin_policy" else [] - - async def run(): - client = FakeMilvus() - self.assertTrue(await document_exists_in_milvus(client, "doc-1")) - self.assertEqual( - [call["collection_name"] for call in client.calls], - ["fin_faq", "fin_fund_doc", "fin_policy"], - ) - - asyncio.run(run()) - - def test_builds_runtime_from_project_clients_and_mysql_config(self): - with patch("service.customer_agent.bootstrap.redis_client", return_value="redis"), \ - patch("service.customer_agent.bootstrap.milvus_client", return_value="milvus"), \ - patch("service.customer_agent.bootstrap.llm_client", new="llm"), \ - patch("service.customer_agent.bootstrap.build_anonymous_runtime", return_value="runtime") as builder: - result = build_default_runtime() - - self.assertEqual(result, "runtime") - self.assertEqual(builder.call_args.kwargs["redis"], "redis") - self.assertEqual(builder.call_args.kwargs["milvus_client"], "milvus") - self.assertEqual(builder.call_args.kwargs["llm_client"], "llm") - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_customer_agent_config.py b/tests/test_customer_agent_config.py deleted file mode 100644 index 4c69d62..0000000 --- a/tests/test_customer_agent_config.py +++ /dev/null @@ -1,30 +0,0 @@ -import unittest -from unittest.mock import AsyncMock - -from service.customer_agent.config import DatabaseConfigProvider - - -class ConfigProviderTests(unittest.IsolatedAsyncioTestCase): - async def test_reads_sys_config_value_and_uses_default_when_missing(self): - repo = AsyncMock() - repo.get_value.side_effect = ["120", "fallback"] - - class SessionContext: - async def __aenter__(self): - return object() - - async def __aexit__(self, *args): - pass - - provider = DatabaseConfigProvider( - repo_factory=lambda session: repo, - session_factory=lambda: SessionContext(), - ) - - self.assertEqual(await provider.get("agent.customer.session.ttl", "60"), "120") - self.assertEqual(await provider.get("missing", "fallback"), "fallback") - self.assertEqual(repo.get_value.await_count, 2) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_customer_agent_packages.py b/tests/test_customer_agent_packages.py deleted file mode 100644 index c09d2e9..0000000 --- a/tests/test_customer_agent_packages.py +++ /dev/null @@ -1,14 +0,0 @@ -import unittest - - -class CustomerAgentPackageTests(unittest.TestCase): - def test_agent_and_service_customer_agent_packages_are_importable(self): - from agent.customer_agent import package_name as agent_package_name - from service.customer_agent import package_name as service_package_name - - self.assertEqual(agent_package_name, "customer_agent") - self.assertEqual(service_package_name, "customer_agent") - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_customer_agent_router.py b/tests/test_customer_agent_router.py deleted file mode 100644 index 20613f8..0000000 --- a/tests/test_customer_agent_router.py +++ /dev/null @@ -1,99 +0,0 @@ -import json -import unittest -from types import SimpleNamespace - -import httpx -from fastapi import FastAPI - -from api.chat.customer_agent import router -from rag.intent import Intent -from service.customer_agent.chat import AnonymousCustomerAgent -from agent.customer_agent.session import AnonymousSessionService -from tests.test_agent_session import FakeRedis - - -class RouterTests(unittest.IsolatedAsyncioTestCase): - async def asyncSetUp(self): - redis = FakeRedis() - config = { - "agent.customer.session.ttl": "120", - "agent.customer.rate_limit.window_sec": "60", - "agent.customer.rate_limit.max_requests": "1", - "agent.customer.template.fallback_human": "请转人工客服", - } - session = AnonymousSessionService(redis, config_getter=config.get) - - class Context: - async def append(self, *args): - pass - - async def get(self, *args): - return [] - - agent = AnonymousCustomerAgent( - context=Context(), - rag_retrieve=lambda query, customer_id: [], - intent_recognize=lambda query: Intent.NO_MATCH, - generate_answer=lambda messages: "answer", - audit_writer=lambda **kwargs: None, - config_getter=config.get, - ) - self.app = FastAPI() - self.app.state.customer_agent_runtime = SimpleNamespace( - redis=redis, session_service=session, agent=agent - ) - self.app.include_router(router, prefix="/api/agent/customer") - - async def test_create_chat_and_end_anonymous_session(self): - transport = httpx.ASGITransport(app=self.app) - async with httpx.AsyncClient(transport=transport, base_url="http://test") as client: - created = await client.post("/api/agent/customer/session/create") - self.assertEqual(created.status_code, 200) - session_id = created.json()["data"]["session_id"] - - chat = await client.get( - "/api/agent/customer/chat", - params={"session_id": session_id, "query": "你好"}, - headers={"X-Trace-Id": "trace-router"}, - ) - self.assertEqual(chat.status_code, 200) - event = json.loads(chat.text.removeprefix("data: ").strip()) - self.assertEqual(event["trace_id"], "trace-router") - - limited = await client.get( - "/api/agent/customer/chat", - params={"session_id": session_id, "query": "再次提问"}, - ) - self.assertEqual(limited.status_code, 429) - self.assertIn(int(limited.headers["Retry-After"]), range(1, 61)) - - ended = await client.post( - "/api/agent/customer/session/end", json={"session_id": session_id} - ) - self.assertEqual(ended.status_code, 200) - - async def test_query_over_2000_returns_400(self): - transport = httpx.ASGITransport(app=self.app) - async with httpx.AsyncClient(transport=transport, base_url="http://test") as client: - created = await client.post("/api/agent/customer/session/create") - session_id = created.json()["data"]["session_id"] - response = await client.get( - "/api/agent/customer/chat", - params={"session_id": session_id, "query": "x" * 2001}, - ) - self.assertEqual(response.status_code, 400) - self.assertEqual(response.json()["code"], 400) - - async def test_missing_session_returns_404(self): - transport = httpx.ASGITransport(app=self.app) - async with httpx.AsyncClient(transport=transport, base_url="http://test") as client: - response = await client.get( - "/api/agent/customer/chat", - params={"session_id": "missing", "query": "你好"}, - ) - self.assertEqual(response.status_code, 404) - self.assertEqual(response.json()["code"], 404) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_customer_agent_runtime.py b/tests/test_customer_agent_runtime.py deleted file mode 100644 index 2d1934b..0000000 --- a/tests/test_customer_agent_runtime.py +++ /dev/null @@ -1,25 +0,0 @@ -import unittest - -from service.customer_agent.runtime import build_anonymous_runtime -from agent.customer_agent.session import AnonymousSessionService -from agent.customer_agent.context import RedisConversationContext - - -class RuntimeTests(unittest.TestCase): - def test_runtime_wires_session_context_and_agent_components(self): - runtime = build_anonymous_runtime( - redis=object(), - milvus_client=object(), - llm_client=object(), - config_getter={}.get, - audit_writer=lambda **kwargs: None, - ) - - self.assertIsInstance(runtime.session_service, AnonymousSessionService) - self.assertIsInstance(runtime.context, RedisConversationContext) - self.assertIs(runtime.redis, runtime.session_service.redis) - self.assertIsNotNone(runtime.agent) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_document_parser.py b/tests/test_document_parser.py deleted file mode 100644 index 352eb98..0000000 --- a/tests/test_document_parser.py +++ /dev/null @@ -1,72 +0,0 @@ -import tempfile -import unittest -from pathlib import Path -from zipfile import ZIP_DEFLATED, ZipFile - -from pypdf import PdfWriter -from pypdf.generic import DecodedStreamObject, DictionaryObject, NameObject - -from rag.document_parser import parse_document - - -class DocumentParserTests(unittest.TestCase): - def test_parses_txt_and_md_as_utf8_text(self): - with tempfile.TemporaryDirectory() as tmp: - root = Path(tmp) - txt = root / "notice.txt" - md = root / "notice.md" - txt.write_text("基金风险提示", encoding="utf-8") - md.write_text("# 产品说明\n\n开放式基金", encoding="utf-8") - - self.assertEqual(parse_document(txt), "基金风险提示") - self.assertEqual(parse_document(md), "# 产品说明\n\n开放式基金") - - def test_extracts_text_from_docx(self): - with tempfile.TemporaryDirectory() as tmp: - docx = Path(tmp) / "notice.docx" - document_xml = ( - '' - '' - '基金产品说明' - '风险揭示' - ) - with ZipFile(docx, "w", ZIP_DEFLATED) as archive: - archive.writestr("word/document.xml", document_xml) - - self.assertEqual(parse_document(docx), "基金产品说明\n风险揭示") - - def test_extracts_text_from_pdf(self): - with tempfile.TemporaryDirectory() as tmp: - pdf = Path(tmp) / "notice.pdf" - writer = PdfWriter() - page = writer.add_blank_page(width=612, height=792) - font = writer._add_object( - DictionaryObject( - { - NameObject("/Type"): NameObject("/Font"), - NameObject("/Subtype"): NameObject("/Type1"), - NameObject("/BaseFont"): NameObject("/Helvetica"), - } - ) - ) - page[NameObject("/Resources")] = DictionaryObject( - {NameObject("/Font"): DictionaryObject({NameObject("/F1"): font})} - ) - page[NameObject("/Contents")] = DecodedStreamObject() - page[NameObject("/Contents")].set_data(b"BT /F1 12 Tf 72 720 Td (Fund FAQ) Tj ET") - with pdf.open("wb") as output: - writer.write(output) - - self.assertEqual(parse_document(pdf), "Fund FAQ") - - def test_rejects_unsupported_extension(self): - with tempfile.TemporaryDirectory() as tmp: - path = Path(tmp) / "notice.xlsx" - path.write_bytes(b"not supported") - - with self.assertRaises(ValueError): - parse_document(path) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_embedding.py b/tests/test_embedding.py deleted file mode 100644 index ae90315..0000000 --- a/tests/test_embedding.py +++ /dev/null @@ -1,35 +0,0 @@ -import unittest - -from rag.embedding import EMBEDDING_DIMENSION, EmbeddingError, embed_texts - - -class EmbeddingTests(unittest.IsolatedAsyncioTestCase): - async def test_returns_configured_dimension_vectors(self): - class Client: - async def embed(self, texts): - return [[0.1] * EMBEDDING_DIMENSION for _ in texts] - - vectors = await embed_texts(["基金知识"], client=Client()) - - self.assertEqual(len(vectors), 1) - self.assertEqual(len(vectors[0]), EMBEDDING_DIMENSION) - - async def test_rejects_wrong_embedding_dimension(self): - class Client: - async def embed(self, texts): - return [[0.1] * 3 for _ in texts] - - with self.assertRaises(EmbeddingError): - await embed_texts(["基金知识"], client=Client()) - - async def test_wraps_provider_failure(self): - class Client: - async def embed(self, texts): - raise TimeoutError("embedding timeout") - - with self.assertRaises(EmbeddingError): - await embed_texts(["基金知识"], client=Client()) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_events.py b/tests/test_events.py deleted file mode 100644 index eef92e3..0000000 --- a/tests/test_events.py +++ /dev/null @@ -1,22 +0,0 @@ -import unittest -from unittest.mock import AsyncMock - -from rag.events import publish_knowledge_update - - -class KnowledgeEventTests(unittest.IsolatedAsyncioTestCase): - async def test_publishes_update_event_after_successful_ingestion(self): - publisher = AsyncMock() - - await publish_knowledge_update( - publisher, doc_id="doc-1", collection_name="fin_faq", chunk_count=4 - ) - - publisher.assert_awaited_once_with( - "event:knowledge_update", - {"doc_id": "doc-1", "collection_name": "fin_faq", "chunk_count": 4}, - ) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_generation.py b/tests/test_generation.py deleted file mode 100644 index 8217c2e..0000000 --- a/tests/test_generation.py +++ /dev/null @@ -1,41 +0,0 @@ -import unittest -from unittest.mock import AsyncMock - -from rag.generation import generate_answer - - -class GenerationTests(unittest.IsolatedAsyncioTestCase): - async def test_switches_to_backup_model_after_primary_failure(self): - llm = AsyncMock() - llm.chat.side_effect = [RuntimeError("primary down"), "backup answer"] - config = { - "agent.customer.llm.fallback_model": "backup-model", - "agent.customer.template.system_busy": "系统繁忙,请稍后再试", - } - - result = await generate_answer( - [{"role": "user", "content": "基金是什么"}], - llm_client=llm, config_getter=config.get, primary_model="primary-model", - ) - - self.assertEqual(result, "backup answer") - self.assertEqual(llm.chat.await_args_list[1].kwargs["model"], "backup-model") - - async def test_returns_configured_system_busy_template_when_models_fail(self): - llm = AsyncMock() - llm.chat.side_effect = RuntimeError("down") - config = { - "agent.customer.llm.fallback_model": "backup-model", - "agent.customer.template.system_busy": "系统繁忙,请稍后再试", - } - - result = await generate_answer( - [{"role": "user", "content": "基金是什么"}], - llm_client=llm, config_getter=config.get, primary_model="primary-model", - ) - - self.assertEqual(result, "系统繁忙,请稍后再试") - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_ingestion.py b/tests/test_ingestion.py deleted file mode 100644 index 1e0918a..0000000 --- a/tests/test_ingestion.py +++ /dev/null @@ -1,85 +0,0 @@ -import unittest -from unittest.mock import AsyncMock - -from rag.embedding import EMBEDDING_DIMENSION -from rag.ingestion import ingest_document_atomic - - -class AtomicIngestionTests(unittest.IsolatedAsyncioTestCase): - async def test_validation_completes_before_embedding(self): - milvus = AsyncMock() - embedder = AsyncMock() - - with self.assertRaises(ValueError): - await ingest_document_atomic( - "Q: only a question", "doc-1", "FAQ", "fin_faq", "qa_pair", - milvus_client=milvus, embedder=embedder, - ) - - embedder.assert_not_awaited() - milvus.insert.assert_not_awaited() - - async def test_embedding_failure_cleans_up_document_rows(self): - milvus = AsyncMock() - embedder = AsyncMock(side_effect=RuntimeError("embedding down")) - - with self.assertRaises(RuntimeError): - await ingest_document_atomic( - "plain text", "doc-2", "Policy", "fin_policy", "default", - milvus_client=milvus, embedder=embedder, - ) - - milvus.delete.assert_awaited_once_with( - collection_name="fin_policy", filter='doc_id == "doc-2"' - ) - - async def test_milvus_failure_cleans_up_partial_document_rows(self): - milvus = AsyncMock() - milvus.insert.side_effect = RuntimeError("insert down") - embedder = AsyncMock(return_value=[[0.0] * EMBEDDING_DIMENSION]) - - with self.assertRaises(RuntimeError): - await ingest_document_atomic( - "plain text", "doc-3", "Policy", "fin_policy", "default", - milvus_client=milvus, embedder=embedder, - ) - - milvus.delete.assert_awaited_once_with( - collection_name="fin_policy", filter='doc_id == "doc-3"' - ) - - async def test_success_inserts_complete_document_rows(self): - milvus = AsyncMock() - embedder = AsyncMock(return_value=[[0.0] * EMBEDDING_DIMENSION]) - - result = await ingest_document_atomic( - "plain text", "doc-4", "Policy", "fin_policy", "default", - milvus_client=milvus, embedder=embedder, - ) - - self.assertEqual(result["doc_id"], "doc-4") - milvus.delete.assert_not_awaited() - milvus.insert.assert_awaited_once() - - async def test_cleans_text_before_embedding_and_milvus_insert(self): - milvus = AsyncMock() - embedder = AsyncMock(return_value=[[0.0] * EMBEDDING_DIMENSION, [0.0] * EMBEDDING_DIMENSION]) - - await ingest_document_atomic( - "\ufeff基金名称:示例基金\r\n\r\n\r\n风险等级:R3\t ", - "doc-clean", - "示例基金", - "fin_fund_doc", - "default", - milvus_client=milvus, - embedder=embedder, - ) - - self.assertEqual( - embedder.await_args.args[0], - ["基金名称:示例基金", "风险等级:R3"], - ) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_intent.py b/tests/test_intent.py deleted file mode 100644 index 1123767..0000000 --- a/tests/test_intent.py +++ /dev/null @@ -1,34 +0,0 @@ -import unittest -from unittest.mock import AsyncMock - -from rag.intent import Intent, intent_recognize - - -class IntentTests(unittest.IsolatedAsyncioTestCase): - async def test_returns_a_declared_intent_enum(self): - llm = AsyncMock() - llm.chat.return_value = "knowledge_qa" - - result = await intent_recognize("基金是什么", llm_client=llm) - - self.assertIs(result, Intent.KNOWLEDGE_QA) - - async def test_invalid_llm_output_returns_no_match(self): - llm = AsyncMock() - llm.chat.return_value = "made_up_intent" - - result = await intent_recognize("随便聊聊", llm_client=llm) - - self.assertIs(result, Intent.NO_MATCH) - - async def test_llm_failure_returns_no_match_for_handoff(self): - llm = AsyncMock() - llm.chat.side_effect = RuntimeError("LLM down") - - result = await intent_recognize("我要投诉", llm_client=llm) - - self.assertIs(result, Intent.NO_MATCH) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_knowledge_auth.py b/tests/test_knowledge_auth.py deleted file mode 100644 index c50fbc2..0000000 --- a/tests/test_knowledge_auth.py +++ /dev/null @@ -1,28 +0,0 @@ -import unittest -from types import SimpleNamespace - -from api.deps import require_knowledge_operator -from utils.exceptions import ForbiddenError - - -class KnowledgeAuthTests(unittest.IsolatedAsyncioTestCase): - async def test_allows_admin_or_knowledge_operator(self): - admin = SimpleNamespace(user_type="ADMIN", employee_role=None) - operator = SimpleNamespace(user_type="EMPLOYEE", employee_role="KNOWLEDGE_OPERATOR") - - self.assertIs(await require_knowledge_operator(admin), admin) - self.assertIs(await require_knowledge_operator(operator), operator) - - async def test_rejects_customer_and_unrelated_employee(self): - with self.assertRaises(ForbiddenError): - await require_knowledge_operator( - SimpleNamespace(user_type="CUSTOMER", employee_role=None) - ) - with self.assertRaises(ForbiddenError): - await require_knowledge_operator( - SimpleNamespace(user_type="EMPLOYEE", employee_role="ADVISOR") - ) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_knowledge_router.py b/tests/test_knowledge_router.py deleted file mode 100644 index 4e4fa76..0000000 --- a/tests/test_knowledge_router.py +++ /dev/null @@ -1,147 +0,0 @@ -import tempfile -import unittest -from unittest.mock import AsyncMock - -from api.chat.knowledge import ( - confirm_document_upload, - delete_document, - get_document, - list_documents, - preview_document_upload, -) -from rag.embedding import EMBEDDING_DIMENSION -from service.knowledge_base.upload import KnowledgeUploadService -from types import SimpleNamespace - - -class FakeUpload: - def __init__(self, filename, content): - self.filename = filename - self._content = content - - async def read(self): - return self._content - - -class FakeRequest: - def __init__(self, service, form_data=None, json_data=None): - self.app = SimpleNamespace(state=SimpleNamespace(knowledge_upload_service=service)) - self.form_data = form_data - self.json_data = json_data - - async def form(self): - return self.form_data - - async def json(self): - return self.json_data - - -class KnowledgeRouterTests(unittest.IsolatedAsyncioTestCase): - async def test_preview_endpoint_accepts_file_and_manual_strategy(self): - with tempfile.TemporaryDirectory() as tmp: - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=AsyncMock(), - embedder=AsyncMock(), - publisher=AsyncMock(), - ) - request = FakeRequest( - service, - { - "file": FakeUpload("faq.md", b"Q: Q\nA: A"), - "strategy": "qa_pair", - }, - ) - - response = await preview_document_upload( - request, - SimpleNamespace(user_type="ADMIN", employee_role=None), - ) - - self.assertEqual(response.code, 200) - self.assertEqual(response.data["strategy"], "qa_pair") - - async def test_confirm_endpoint_returns_ingestion_result(self): - with tempfile.TemporaryDirectory() as tmp: - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=AsyncMock(), - embedder=AsyncMock(return_value=[[0.0] * EMBEDDING_DIMENSION]), - publisher=AsyncMock(), - ) - request = FakeRequest( - service, - form_data={ - "file": FakeUpload("faq.md", b"Q: Q\nA: A"), - "title": "FAQ", - "doc_id": "doc-1", - "collection_name": "fin_faq", - "strategy": "qa_pair", - }, - ) - - response = await confirm_document_upload( - request, - SimpleNamespace(user_type="ADMIN", employee_role=None), - ) - - self.assertEqual(response.code, 200) - self.assertEqual(response.data["doc_id"], "doc-1") - - async def test_delete_endpoint_returns_deleted_document(self): - with tempfile.TemporaryDirectory() as tmp: - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=AsyncMock(), - embedder=AsyncMock(), - publisher=AsyncMock(), - ) - request = FakeRequest(service, json_data={"doc_id": "doc-delete-1"}) - - response = await delete_document( - request, - "doc-delete-1", - SimpleNamespace(user_type="ADMIN", employee_role=None), - ) - - self.assertEqual(response.code, 200) - self.assertEqual(response.data, {"doc_id": "doc-delete-1", "deleted": True}) - - async def test_list_endpoint_returns_documents(self): - with tempfile.TemporaryDirectory() as tmp: - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=AsyncMock(), - embedder=AsyncMock(), - publisher=AsyncMock(), - ) - service.list_documents = AsyncMock(return_value=[{"doc_id": "doc-1"}]) - response = await list_documents( - FakeRequest(service), - SimpleNamespace(user_type="ADMIN", employee_role=None), - ) - - self.assertEqual(response.code, 200) - self.assertEqual(response.data, [{"doc_id": "doc-1"}]) - - async def test_detail_endpoint_returns_document(self): - with tempfile.TemporaryDirectory() as tmp: - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=AsyncMock(), - embedder=AsyncMock(), - publisher=AsyncMock(), - ) - service.get_document = AsyncMock(return_value={"doc_id": "doc-1"}) - response = await get_document( - FakeRequest(service), - "doc-1", - SimpleNamespace(user_type="ADMIN", employee_role=None), - ) - - self.assertEqual(response.code, 200) - self.assertEqual(response.data, {"doc_id": "doc-1"}) - - -if __name__ == "__main__": - unittest.main() \ No newline at end of file diff --git a/tests/test_knowledge_upload.py b/tests/test_knowledge_upload.py deleted file mode 100644 index 4443551..0000000 --- a/tests/test_knowledge_upload.py +++ /dev/null @@ -1,281 +0,0 @@ -import tempfile -import unittest -import os -import time -from pathlib import Path -from unittest.mock import AsyncMock - -from rag.embedding import EMBEDDING_DIMENSION -from rag.events import KNOWLEDGE_UPDATE_EVENT -from service.knowledge_base.upload import KnowledgeUploadService, UploadValidationError - - -class KnowledgeUploadTests(unittest.IsolatedAsyncioTestCase): - async def test_preview_saves_upload_and_returns_cleaning_and_chunk_preview(self): - with tempfile.TemporaryDirectory() as tmp: - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=AsyncMock(), - embedder=AsyncMock(), - publisher=AsyncMock(), - ) - - result = await service.preview( - filename="notice.md", - content="\ufeff# Notice\r\n\r\n正文".encode(), - strategy="chapter_semantic", - ) - - self.assertTrue(result["upload_id"]) - self.assertTrue(result["chunks"]) - self.assertTrue(Path(tmp, result["stored_filename"]).is_file()) - self.assertIn("cleaning_warnings", result) - - async def test_confirm_ingests_then_publishes_update_and_removes_temp_file(self): - with tempfile.TemporaryDirectory() as tmp: - publisher = AsyncMock() - milvus = AsyncMock() - embedder = AsyncMock(return_value=[[0.0] * EMBEDDING_DIMENSION]) - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=milvus, - embedder=embedder, - publisher=publisher, - ) - - result = await service.confirm( - filename="faq.md", - content="Q: 什么是基金?\nA: 一种集合投资工具。".encode(), - title="FAQ", - doc_id="doc-upload-1", - collection_name="fin_faq", - strategy="qa_pair", - ) - - self.assertEqual(result["doc_id"], "doc-upload-1") - publisher.assert_awaited_once() - self.assertEqual(publisher.await_args.args[0], KNOWLEDGE_UPDATE_EVENT) - self.assertEqual(len(list(Path(tmp).glob("*.md"))), 0) - self.assertEqual(len(list(Path(tmp).glob("*.json"))), 0) - - async def test_confirm_passes_custom_chunk_config_to_ingestion(self): - with tempfile.TemporaryDirectory() as tmp: - milvus = AsyncMock() - embedder = AsyncMock(side_effect=lambda texts: [[0.0] * EMBEDDING_DIMENSION for _ in texts]) - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=milvus, - embedder=embedder, - publisher=AsyncMock(), - ) - - await service.confirm( - filename="doc.md", - content="一二三四五六七八九十十一十二".encode(), - title="Doc", - doc_id="doc-config", - collection_name="fin_fund_doc", - strategy="default", - chunk_size=10, - chunk_overlap=2, - ) - - self.assertEqual(len(embedder.await_args.args[0]), 2) - - async def test_confirm_removes_vectors_when_update_event_publish_fails(self): - with tempfile.TemporaryDirectory() as tmp: - milvus = AsyncMock() - publisher = AsyncMock(side_effect=RuntimeError("redis unavailable")) - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=milvus, - embedder=AsyncMock(return_value=[[0.0] * EMBEDDING_DIMENSION]), - publisher=publisher, - ) - - with self.assertRaises(RuntimeError): - await service.confirm( - filename="policy.md", - content=b"policy text", - title="Policy", - doc_id="doc-event-failure", - collection_name="fin_policy", - strategy="default", - ) - - self.assertEqual(milvus.delete.await_count, 3) - - async def test_rejects_unsupported_extension_and_oversized_file(self): - with tempfile.TemporaryDirectory() as tmp: - service = KnowledgeUploadService( - storage_dir=tmp, - max_upload_bytes=4, - milvus_client=AsyncMock(), - embedder=AsyncMock(), - publisher=AsyncMock(), - ) - - with self.assertRaises(UploadValidationError): - await service.preview("file.exe", b"ok", strategy="default") - with self.assertRaises(UploadValidationError): - await service.preview("file.md", b"12345", strategy="default") - - async def test_confirm_rejects_unknown_collection_or_strategy_mismatch(self): - with tempfile.TemporaryDirectory() as tmp: - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=AsyncMock(), - embedder=AsyncMock(), - publisher=AsyncMock(), - ) - - with self.assertRaises(UploadValidationError): - await service.confirm( - filename="faq.md", - content=b"Q: Q\nA: A", - title="FAQ", - doc_id="d1", - collection_name="evil_collection", - strategy="qa_pair", - ) - - async def test_confirm_rejects_duplicate_doc_id_before_embedding(self): - with tempfile.TemporaryDirectory() as tmp: - embedder = AsyncMock() - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=AsyncMock(), - embedder=embedder, - publisher=AsyncMock(), - document_exists=lambda doc_id: True, - ) - - with self.assertRaises(UploadValidationError): - await service.confirm( - filename="faq.md", - content=b"Q: Q\nA: A", - title="FAQ", - doc_id="d1", - collection_name="fin_faq", - strategy="qa_pair", - ) - embedder.assert_not_awaited() - - async def test_preview_storage_cleanup_removes_expired_upload_and_manifest(self): - with tempfile.TemporaryDirectory() as tmp: - service = KnowledgeUploadService( - storage_dir=tmp, - upload_ttl_seconds=60, - milvus_client=AsyncMock(), - embedder=AsyncMock(), - publisher=AsyncMock(), - ) - preview = await service.preview("faq.md", b"Q: Q\nA: A", strategy="qa_pair") - path = Path(tmp, preview["stored_filename"]) - manifest = Path(tmp, f"{preview['upload_id']}.json") - old = time.time() - 120 - os.utime(path, (old, old)) - os.utime(manifest, (old, old)) - - removed = service.cleanup_expired_uploads(now=time.time()) - - self.assertEqual(removed, 1) - self.assertFalse(path.exists()) - self.assertFalse(manifest.exists()) - - async def test_confirm_rejects_unsupported_extension(self): - with tempfile.TemporaryDirectory() as tmp: - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=AsyncMock(), - embedder=AsyncMock(), - publisher=AsyncMock(), - ) - - with self.assertRaises(UploadValidationError): - await service.confirm( - filename="script.exe", - content=b"bad", - title="Bad", - doc_id="bad-doc", - collection_name="fin_faq", - strategy="default", - ) - - async def test_delete_document_removes_vectors_and_publishes_update(self): - with tempfile.TemporaryDirectory() as tmp: - milvus = AsyncMock() - publisher = AsyncMock() - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=milvus, - embedder=AsyncMock(), - publisher=publisher, - ) - - result = await service.delete_document("doc-delete-1") - - self.assertEqual(result, {"doc_id": "doc-delete-1", "deleted": True}) - self.assertEqual(milvus.delete.await_count, 3) - publisher.assert_awaited_once() - self.assertEqual(publisher.await_args.args[0], KNOWLEDGE_UPDATE_EVENT) - self.assertEqual(publisher.await_args.args[1]["doc_id"], "doc-delete-1") - self.assertEqual(publisher.await_args.args[1]["chunk_count"], 0) - self.assertEqual(publisher.await_args.args[1]["action"], "deleted") - - async def test_list_documents_groups_chunks_across_collections(self): - with tempfile.TemporaryDirectory() as tmp: - milvus = AsyncMock() - - async def query(**kwargs): - if kwargs["collection_name"] == "fin_faq": - return [ - { - "doc_id": "doc-1", - "title": "FAQ", - "section_title": "基金基础", - "strategy": "qa_pair", - }, - { - "doc_id": "doc-1", - "title": "FAQ", - "section_title": "购买流程", - "strategy": "qa_pair", - }, - ] - return [] - - milvus.query.side_effect = query - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=milvus, - embedder=AsyncMock(), - publisher=AsyncMock(), - ) - - result = await service.list_documents() - - self.assertEqual(result, [{ - "doc_id": "doc-1", - "title": "FAQ", - "collection_name": "fin_faq", - "strategy": "qa_pair", - "chunk_count": 2, - }]) - - async def test_get_document_returns_not_found_when_doc_id_is_missing(self): - with tempfile.TemporaryDirectory() as tmp: - milvus = AsyncMock() - milvus.query.return_value = [] - service = KnowledgeUploadService( - storage_dir=tmp, - milvus_client=milvus, - embedder=AsyncMock(), - publisher=AsyncMock(), - ) - - self.assertIsNone(await service.get_document("missing-doc")) - - -if __name__ == "__main__": - unittest.main() \ No newline at end of file diff --git a/tests/test_milvus_collections.py b/tests/test_milvus_collections.py deleted file mode 100644 index c199b26..0000000 --- a/tests/test_milvus_collections.py +++ /dev/null @@ -1,69 +0,0 @@ -import unittest -from unittest.mock import AsyncMock, call -from unittest.mock import patch - -from rag.milvus_collections import ( - EMBEDDING_DIMENSION, - KNOWLEDGE_COLLECTIONS, - ensure_collections, -) - - -def _existing_client(dim: int) -> AsyncMock: - client = AsyncMock() - client.has_collection.return_value = True - client.describe_collection.return_value = { - "fields": [{"name": "vector", "params": {"dim": dim}}] - } - return client - - -class MilvusCollectionTests(unittest.IsolatedAsyncioTestCase): - async def test_creates_all_project_knowledge_collections(self): - client = AsyncMock() - client.has_collection.return_value = False - - await ensure_collections(client) - - self.assertEqual( - client.has_collection.await_args_list, - [call(name) for name in KNOWLEDGE_COLLECTIONS], - ) - self.assertEqual(client.create_collection.await_count, len(KNOWLEDGE_COLLECTIONS)) - - async def test_reuses_existing_collections(self): - client = _existing_client(EMBEDDING_DIMENSION) - - await ensure_collections(client) - - client.create_collection.assert_not_awaited() - - async def test_existing_collection_with_wrong_dimension_raises(self): - client = _existing_client(EMBEDDING_DIMENSION + 1) - - with self.assertRaises(RuntimeError): - await ensure_collections(client) - - async def test_collection_schema_contains_metadata_and_1024_vector(self): - client = AsyncMock() - client.has_collection.return_value = False - - await ensure_collections(client) - - schema = client.create_collection.await_args.kwargs["schema"] - fields = {field["name"] for field in schema.to_dict()["fields"]} - self.assertTrue({"chunk_id", "doc_id", "title", "section_title", "text", "strategy", "vector"} <= fields) - vector = next(field for field in schema.to_dict()["fields"] if field["name"] == "vector") - self.assertEqual(vector["params"]["dim"], 1024) - - async def test_default_path_uses_configured_milvus_client(self): - client = _existing_client(EMBEDDING_DIMENSION) - - with patch("rag.milvus_collections.configured_milvus_client", return_value=client): - await ensure_collections() - - self.assertEqual(client.has_collection.await_count, len(KNOWLEDGE_COLLECTIONS)) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_milvus_config.py b/tests/test_milvus_config.py deleted file mode 100644 index 1f4346c..0000000 --- a/tests/test_milvus_config.py +++ /dev/null @@ -1,34 +0,0 @@ -import unittest -from unittest.mock import AsyncMock - -from config.settings import settings -from config.database.milvus import ensure_database - - -class MilvusConfigTests(unittest.TestCase): - def test_uses_project_database_from_milvus_db_env(self): - self.assertEqual(settings.milvus.db_name, "mutual_fund") - - -class MilvusDatabaseTests(unittest.IsolatedAsyncioTestCase): - async def test_creates_project_database_only_when_missing(self): - client = AsyncMock() - client.list_databases.return_value = ["default"] - - await ensure_database(client) - - client.create_database.assert_awaited_once_with("mutual_fund") - client.drop_database.assert_not_called() - - async def test_reuses_existing_project_database_without_recreating_it(self): - client = AsyncMock() - client.list_databases.return_value = ["default", "mutual_fund"] - - await ensure_database(client) - - client.create_database.assert_not_called() - client.drop_database.assert_not_called() - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_mock_ingest.py b/tests/test_mock_ingest.py deleted file mode 100644 index aaa336b..0000000 --- a/tests/test_mock_ingest.py +++ /dev/null @@ -1,52 +0,0 @@ -import unittest -from pathlib import Path -from unittest.mock import AsyncMock - -from rag.mock_ingest import MOCK_DOCUMENTS, ingest_mock_documents -from rag.milvus_delete import delete_document_vectors - - -class MockIngestTests(unittest.IsolatedAsyncioTestCase): - async def test_mock_documents_are_chunked_embedded_and_inserted(self): - milvus = AsyncMock() - embedder = AsyncMock() - embedder.return_value = [[0.0] * 768] - - await ingest_mock_documents(milvus, embedder=embedder) - - self.assertEqual(len(MOCK_DOCUMENTS), 3) - self.assertEqual(embedder.await_count, len(MOCK_DOCUMENTS)) - self.assertEqual(milvus.insert.await_count, len(MOCK_DOCUMENTS)) - inserted = [call.kwargs for call in milvus.insert.await_args_list] - self.assertEqual( - {item["collection_name"] for item in inserted}, - {item.collection for item in MOCK_DOCUMENTS}, - ) - for call_args in inserted: - rows = call_args["data"] - self.assertTrue(rows) - self.assertTrue({"doc_id", "title", "section_title", "text", "strategy", "vector"} <= rows[0].keys()) - self.assertEqual(len(rows[0]["vector"]), 768) - - def test_mock_markdown_files_are_present(self): - for item in MOCK_DOCUMENTS: - self.assertTrue(Path(item.path).is_file()) - self.assertEqual(Path(item.path).suffix, ".md") - faq = next(item for item in MOCK_DOCUMENTS if item.collection == "fin_faq") - self.assertEqual( - sum(line.startswith("Q:") for line in Path(faq.path).read_text(encoding="utf-8").splitlines()), - 40, - ) - - async def test_deletes_document_rows_by_doc_id_from_all_knowledge_collections(self): - milvus = AsyncMock() - - await delete_document_vectors("doc-123", milvus_client=milvus) - - self.assertEqual(milvus.delete.await_count, 3) - for call_args in milvus.delete.await_args_list: - self.assertEqual(call_args.kwargs["filter"], 'doc_id == "doc-123"') - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_preview.py b/tests/test_preview.py deleted file mode 100644 index d51753b..0000000 --- a/tests/test_preview.py +++ /dev/null @@ -1,54 +0,0 @@ -import tempfile -import unittest -from pathlib import Path - -from rag.preview import preview_document - - -class PreviewTests(unittest.TestCase): - def test_previews_manually_selected_strategy_with_custom_config(self): - with tempfile.TemporaryDirectory() as tmp: - path = Path(tmp) / "faq.md" - path.write_text("Q: 什么是净值?\nA: 基金单位价值。", encoding="utf-8") - - preview = preview_document(path, strategy="qa_pair", chunk_size=64, chunk_overlap=4) - - self.assertEqual(preview["strategy"], "qa_pair") - self.assertEqual(preview["actual_strategy"], "qa_pair") - self.assertEqual(len(preview["chunks"]), 1) - self.assertEqual(preview["chunks"][0]["section_title"], None) - - def test_rejects_auto_strategy(self): - with tempfile.TemporaryDirectory() as tmp: - path = Path(tmp) / "faq.md" - path.write_text("普通文本", encoding="utf-8") - - with self.assertRaises(ValueError): - preview_document(path, strategy="auto") - - def test_preview_reports_chapter_fallback(self): - with tempfile.TemporaryDirectory() as tmp: - path = Path(tmp) / "notice.md" - path.write_text("没有标题的普通文本", encoding="utf-8") - - preview = preview_document(path, strategy="chapter_semantic") - - self.assertEqual(preview["actual_strategy"], "default") - self.assertTrue(preview["degraded"]) - self.assertTrue(preview["warning"]) - - def test_preview_exposes_cleaning_warnings_and_uses_cleaned_text(self): - with tempfile.TemporaryDirectory() as tmp: - path = Path(tmp) / "notice.md" - path.write_text("\ufeff第一段\r\n\r\n\r\n第二段\t内容", encoding="utf-8") - - preview = preview_document(path, strategy="default") - - self.assertTrue(preview["cleaning_changed"]) - self.assertTrue(preview["cleaning_warnings"]) - self.assertEqual(preview["chunks"][0]["text"], "第一段") - self.assertEqual(preview["chunks"][1]["text"], "第二段 内容") - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_retrieve.py b/tests/test_retrieve.py deleted file mode 100644 index 642043a..0000000 --- a/tests/test_retrieve.py +++ /dev/null @@ -1,102 +0,0 @@ -import unittest -from unittest.mock import AsyncMock - -from rag.retrieve import rag_retrieve, retrieve_candidates, retrieve_with_status - - -class RetrievalTests(unittest.IsolatedAsyncioTestCase): - async def test_reads_topk_threshold_and_searches_three_business_collections(self): - milvus = AsyncMock() - milvus.search.return_value = [ - [{"id": "chunk-1", "distance": 0.9, "entity": {"doc_id": "d1"}}] - ] - embedder = AsyncMock(return_value=[[0.0] * 768]) - values = { - "agent.customer.rag.topk.faq": "3", - "agent.customer.rag.threshold.faq": "0.75", - "agent.customer.rag.topk.funddoc": "5", - "agent.customer.rag.threshold.funddoc": "0.7", - "agent.customer.rag.topk.policy": "5", - "agent.customer.rag.threshold.policy": "0.7", - } - - await retrieve_candidates( - "基金是什么", None, milvus_client=milvus, embedder=embedder, - config_getter=values.get, - ) - - self.assertEqual(milvus.search.await_count, 3) - calls = {call.kwargs["collection_name"]: call.kwargs for call in milvus.search.await_args_list} - self.assertEqual(calls["fin_faq"]["limit"], 3) - self.assertEqual(calls["fin_faq"]["filter"], "") - self.assertEqual(calls["fin_faq"]["data"], [[0.0] * 768]) - - async def test_customer_memory_is_searched_only_for_a_customer(self): - milvus = AsyncMock() - milvus.search.return_value = [[]] - embedder = AsyncMock(return_value=[[0.0] * 768]) - values = {"agent.customer.rag.topk.memory": "5", "agent.customer.rag.threshold.memory": "0.6"} - - await retrieve_candidates( - "风险", "customer-7", milvus_client=milvus, embedder=embedder, - config_getter=values.get, - ) - - memory_call = milvus.search.await_args_list[-1].kwargs - self.assertEqual(memory_call["collection_name"], "customer_memory") - self.assertEqual(memory_call["filter"], 'customer_id == "customer-7"') - - async def test_public_retrieve_returns_milvus_sources_and_filters_low_scores(self): - milvus = AsyncMock() - milvus.search.side_effect = [ - [[ - {"id": "c1", "distance": 0.90, "entity": { - "doc_id": "doc-1", "title": "FAQ", "section_title": "", - "text": "基金正文", - }}, - {"id": "c2", "distance": 0.50, "entity": { - "doc_id": "doc-low", "title": "低分", "text": "不应返回", - }}, - ]], - [[]], - [[]], - ] - embedder = AsyncMock(return_value=[[0.0] * 768]) - - sources = await rag_retrieve( - "基金", None, milvus_client=milvus, embedder=embedder, - config_getter={}.get, - ) - - self.assertEqual(sources, [{ - "doc_id": "doc-1", "title": "FAQ", "section_title": None, - "chunk_text": "基金正文", "score": 0.90, - }]) - - async def test_milvus_failure_returns_empty_sources_without_fake_hit(self): - milvus = AsyncMock() - milvus.search.side_effect = TimeoutError("Milvus timeout") - embedder = AsyncMock(return_value=[[0.0] * 768]) - - result = await retrieve_with_status( - "基金", None, milvus_client=milvus, embedder=embedder, - config_getter={}.get, - ) - - self.assertEqual(result, {"status": "milvus_unavailable", "sources": []}) - - async def test_embedding_failure_returns_failed_status_without_mysql_fallback(self): - milvus = AsyncMock() - embedder = AsyncMock(side_effect=RuntimeError("embedding down")) - - result = await retrieve_with_status( - "基金", None, milvus_client=milvus, embedder=embedder, - config_getter={}.get, - ) - - self.assertEqual(result, {"status": "embedding_failed", "sources": []}) - milvus.search.assert_not_awaited() - - -if __name__ == "__main__": - unittest.main()