diff --git a/README.md b/README.md index 731cfdf..b663539 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ RAG_BASE_URL – RAG 嵌入与重排序服务地址(可选) cd ./Agent export PYTHONPATH=src:$PYTHONPATH # Linux/macOS # 或 Windows PowerShell: $env:PYTHONPATH="src;$env:PYTHONPATH" -uvicorn agent.web.server:app --host 127.0.0.1 --port 8765 +uvicorn web.server:app --host 0.0.0.0 --port 8765 # (可选)通过 Cloudflare Tunnel 暴露公网 cloudflared tunnel --url http://localhost:8765 diff --git a/src/agent/__pycache__/__init__.cpython-312.pyc b/src/agent/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..54b9c69 Binary files /dev/null and b/src/agent/__pycache__/__init__.cpython-312.pyc differ diff --git a/src/agent/__pycache__/chatbot_agent.cpython-312.pyc b/src/agent/__pycache__/chatbot_agent.cpython-312.pyc new file mode 100644 index 0000000..75ed37c Binary files /dev/null and b/src/agent/__pycache__/chatbot_agent.cpython-312.pyc differ diff --git a/src/agent/__pycache__/llm.cpython-312.pyc b/src/agent/__pycache__/llm.cpython-312.pyc new file mode 100644 index 0000000..b0d46de Binary files /dev/null and b/src/agent/__pycache__/llm.cpython-312.pyc differ diff --git a/src/agent/chatbot_agent.py b/src/agent/chatbot_agent.py index 9bd627f..380e29d 100644 --- a/src/agent/chatbot_agent.py +++ b/src/agent/chatbot_agent.py @@ -13,7 +13,7 @@ from agent.utils.agent_utils import ( get_session_meta, update_session_meta, ) -from agent.web.ui_session import ( +from web.ui_session import ( rewrite_user_message_files_to_session_dir, session_dir, sync_manifest_from_chat_history, diff --git a/src/agent/history/data_base/chat_history.db b/src/agent/history/data_base/chat_history.db new file mode 100644 index 0000000..fbf8476 Binary files /dev/null and b/src/agent/history/data_base/chat_history.db differ diff --git a/src/agent/history/multi_inputs/20260519_144316/ui_messages.json b/src/agent/history/multi_inputs/20260519_144316/ui_messages.json new file mode 100644 index 0000000..9721091 --- /dev/null +++ b/src/agent/history/multi_inputs/20260519_144316/ui_messages.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "turns": [ + { + "user": { + "content": [ + { + "type": "text", + "text": "你好" + } + ] + }, + "assistant": { + "text": "你好!很高兴能帮到你。\n\n如果你有图片、文件需要解读,或者有任何问题想要咨询,随时可以发给我或告诉我。请问有什么我可以帮你的吗?", + "output_type": "text", + "autoplay": false, + "audio_duration_seconds": null, + "audio_relpath": null + } + } + ] +} \ No newline at end of file diff --git a/src/agent/llm.py b/src/agent/llm.py index 7c31435..800cac0 100644 --- a/src/agent/llm.py +++ b/src/agent/llm.py @@ -316,6 +316,7 @@ class ChatQwen(ChatOpenAI): lc_msg.content = merged elif raw_content: lc_msg.content = raw_content + # print(f"raw_content={raw_content!r}, merged={merged!r}, final={lc_msg.content!r}") content_text = lc_msg.content if isinstance(lc_msg.content, str) else "" pattern = re.compile(r'\s*(.*?)\s*', re.DOTALL) matches = pattern.findall(content_text) diff --git a/src/agent/memory/__pycache__/__init__.cpython-312.pyc b/src/agent/memory/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..318af58 Binary files /dev/null and b/src/agent/memory/__pycache__/__init__.cpython-312.pyc differ diff --git a/src/agent/memory/__pycache__/system_prompt.cpython-312.pyc b/src/agent/memory/__pycache__/system_prompt.cpython-312.pyc new file mode 100644 index 0000000..0bfd68a Binary files /dev/null and b/src/agent/memory/__pycache__/system_prompt.cpython-312.pyc differ diff --git a/src/agent/tools/__pycache__/__init__.cpython-312.pyc b/src/agent/tools/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..e386175 Binary files /dev/null and b/src/agent/tools/__pycache__/__init__.cpython-312.pyc differ diff --git a/src/agent/tools/__pycache__/tool.cpython-312.pyc b/src/agent/tools/__pycache__/tool.cpython-312.pyc new file mode 100644 index 0000000..8d69275 Binary files /dev/null and b/src/agent/tools/__pycache__/tool.cpython-312.pyc differ diff --git a/src/agent/tools/__pycache__/tool_rag.cpython-312.pyc b/src/agent/tools/__pycache__/tool_rag.cpython-312.pyc new file mode 100644 index 0000000..23609a6 Binary files /dev/null and b/src/agent/tools/__pycache__/tool_rag.cpython-312.pyc differ diff --git a/src/agent/utils/__pycache__/__init__.cpython-312.pyc b/src/agent/utils/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..c72cf9f Binary files /dev/null and b/src/agent/utils/__pycache__/__init__.cpython-312.pyc differ diff --git a/src/agent/utils/__pycache__/agent_utils.cpython-312.pyc b/src/agent/utils/__pycache__/agent_utils.cpython-312.pyc new file mode 100644 index 0000000..cb78161 Binary files /dev/null and b/src/agent/utils/__pycache__/agent_utils.cpython-312.pyc differ diff --git a/src/agent/utils/__pycache__/env_utils.cpython-312.pyc b/src/agent/utils/__pycache__/env_utils.cpython-312.pyc new file mode 100644 index 0000000..7c78584 Binary files /dev/null and b/src/agent/utils/__pycache__/env_utils.cpython-312.pyc differ diff --git a/src/agent/utils/__pycache__/image_utils.cpython-312.pyc b/src/agent/utils/__pycache__/image_utils.cpython-312.pyc new file mode 100644 index 0000000..46cf7dc Binary files /dev/null and b/src/agent/utils/__pycache__/image_utils.cpython-312.pyc differ diff --git a/src/agent/utils/agent_utils.py b/src/agent/utils/agent_utils.py index a449fd7..e9b4ee1 100644 --- a/src/agent/utils/agent_utils.py +++ b/src/agent/utils/agent_utils.py @@ -279,4 +279,5 @@ def assistant_text(value) -> str: return json.dumps(value, ensure_ascii=False) except TypeError: return str(value).strip() - return str(value).strip() \ No newline at end of file + return str(value).strip() + diff --git a/src/agent/web/__init__.py b/src/web/__init__.py similarity index 100% rename from src/agent/web/__init__.py rename to src/web/__init__.py diff --git a/src/web/__pycache__/__init__.cpython-312.pyc b/src/web/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..0065abe Binary files /dev/null and b/src/web/__pycache__/__init__.cpython-312.pyc differ diff --git a/src/web/__pycache__/server.cpython-312.pyc b/src/web/__pycache__/server.cpython-312.pyc new file mode 100644 index 0000000..6fd3311 Binary files /dev/null and b/src/web/__pycache__/server.cpython-312.pyc differ diff --git a/src/web/__pycache__/ui_session.cpython-312.pyc b/src/web/__pycache__/ui_session.cpython-312.pyc new file mode 100644 index 0000000..e70b30c Binary files /dev/null and b/src/web/__pycache__/ui_session.cpython-312.pyc differ diff --git a/src/agent/web/app.css b/src/web/app.css similarity index 100% rename from src/agent/web/app.css rename to src/web/app.css diff --git a/src/agent/web/app.js b/src/web/app.js similarity index 99% rename from src/agent/web/app.js rename to src/web/app.js index 354db3a..060e9cf 100644 --- a/src/agent/web/app.js +++ b/src/web/app.js @@ -1366,6 +1366,6 @@ bootstrap().catch((e) => { chatPlaceholder.hidden = false; - chatPlaceholder.innerHTML = `

无法连接服务

${escapeHtml(e.message)}

请从 Agent 目录执行:uvicorn agent.web.server:app --reload --host 127.0.0.1 --port 8765,并保证 PYTHONPATH 包含 src。

`; + chatPlaceholder.innerHTML = `

无法连接服务

${escapeHtml(e.message)}

请从 Agent 目录执行:uvicorn web.server:app --reload --host 127.0.0.1 --port 8765,并保证 PYTHONPATH 包含 src。

`; }); })(); \ No newline at end of file diff --git a/src/agent/web/image/background.jpg b/src/web/image/background.jpg similarity index 100% rename from src/agent/web/image/background.jpg rename to src/web/image/background.jpg diff --git a/src/agent/web/image/favicon.svg b/src/web/image/favicon.svg similarity index 100% rename from src/agent/web/image/favicon.svg rename to src/web/image/favicon.svg diff --git a/src/agent/web/image/microphone.svg b/src/web/image/microphone.svg similarity index 100% rename from src/agent/web/image/microphone.svg rename to src/web/image/microphone.svg diff --git a/src/agent/web/index.html b/src/web/index.html similarity index 100% rename from src/agent/web/index.html rename to src/web/index.html diff --git a/src/agent/web/server.py b/src/web/server.py similarity index 99% rename from src/agent/web/server.py rename to src/web/server.py index 6b830ce..3227878 100644 --- a/src/agent/web/server.py +++ b/src/web/server.py @@ -25,7 +25,7 @@ if str(_SRC) not in sys.path: sys.path.insert(0, str(_SRC)) from agent import chatbot_agent as ca # noqa: E402 -from agent.web import ui_session as ui # noqa: E402 +from web import ui_session as ui # noqa: E402 from agent.utils.image_utils import IMAGE_FILE_EXTENSIONS # noqa: E402 _WEB_DIR = Path(__file__).resolve().parent diff --git a/src/agent/web/ui_session.py b/src/web/ui_session.py similarity index 100% rename from src/agent/web/ui_session.py rename to src/web/ui_session.py