txcode-sdk 1.1.0__tar.gz → 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {txcode_sdk-1.1.0/src/txcode_sdk.egg-info → txcode_sdk-1.2.0}/PKG-INFO +1 -1
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/pyproject.toml +1 -1
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/__init__.py +1 -1
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/provider/deepseek_provider.py +125 -115
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/provider/openai_provider.py +97 -87
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/provider/txcode_ai.py +23 -10
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/__main__.py +44 -2
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0/src/txcode_sdk.egg-info}/PKG-INFO +1 -1
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk.egg-info/SOURCES.txt +3 -1
- txcode_sdk-1.2.0/tests/test_server_cli_logging.py +125 -0
- txcode_sdk-1.2.0/tests/test_txcode_ai.py +190 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/LICENSE +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/README.md +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/setup.cfg +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/setup.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/example/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/example/code_example.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/example/code_session.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/example/code_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/example/constants.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/example/query_session.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/example/ws_server.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/_compat/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/_compat/dataclasses.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/_compat/resources.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/base_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/chat/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/chat/agent_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/chat/chat_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/chat/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/chat/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/code/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/code/agent_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/code/code_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/code/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/code/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/common/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/common/common_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/common/prompt/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/common/prompt/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/compact_mixin.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/design/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/design/agent_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/design/design_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/design/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/design/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/discuss/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/discuss/agent_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/discuss/discuss_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/discuss/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/discuss/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/dream/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/dream/agent_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/dream/dream_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/dream/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/dream/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/factory.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/hook_mixin.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/mem/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/mem/agent_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/mem/mem_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/mem/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/mem/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/message_utils.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/name/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/name/name_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/name/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/name/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/plan/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/plan/agent_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/plan/plan_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/plan/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/plan/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/prompt_builder.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/shell/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/shell/agent_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/shell/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/shell/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/shell/shell_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/skill/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/skill/agent_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/skill/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/skill/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/skill/skill_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/step_utils.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/summarizer/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/summarizer/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/summarizer/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/summarizer/summarizer_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/task/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/task/agent_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/task/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/task/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/task/task_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/test/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/test/agent_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/test/prompts/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/test/prompts/role.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/test/test_agent.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/agent/tool_registry.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/client.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/compact/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/compact/compressor.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/config/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/config/context_config.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/hooks/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/hooks/handlers/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/hooks/handlers/base.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/hooks/handlers/memory.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/hooks/processor.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/hooks/queue.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/hooks/types.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/provider/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/provider/base.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/provider/router.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/config_store.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/git.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/handler.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/http/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/http/chat_routes.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/http/file_routes.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/http/git_routes.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/http/http_base.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/http/plan_code_routes.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/http/project_routes.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/http/session_routes.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/http/skill_routes.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/http/spec_routes.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/http/sys_config_routes.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/hub_client.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/json_store.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/plan_code.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/project_manager.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/provider_config.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/server.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/services/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/services/broadcaster.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/services/project_service.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/services/provider_service.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/skill_manager.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/spec_manager.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/websocket.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/server/zip_utils.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/session/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/session/manager.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/skills/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/specs/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/_util.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/bash.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/bash.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/code_search.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/code_search.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/edit_file.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/edit_file.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/edit_replacers.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/edit_similarity.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/email_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/email_tool.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/glob.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/glob.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/grep.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/grep.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/memory.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/memory.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/read_file.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/read_file.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/skill_tool.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/skill_tool.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/todo_read.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/todo_read.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/todo_write.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/todo_write.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/web_fetch.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/web_fetch.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/web_search.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/web_search.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/web_shell_exec.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/web_shell_exec.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/write_file.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/tools/write_file.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/types.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/utils/__init__.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/utils/format.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/utils/log.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/utils/path_util.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk/utils/time_util.py +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk.egg-info/dependency_links.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk.egg-info/entry_points.txt +0 -0
- {txcode_sdk-1.1.0 → txcode_sdk-1.2.0}/src/txcode_sdk.egg-info/top_level.txt +0 -0
|
@@ -1,127 +1,137 @@
|
|
|
1
|
-
"""DeepSeek Provider:对齐 TS 端 deepseek.provider.ts 行为,直接继承 BaseProvider。
|
|
2
|
-
|
|
3
|
-
- chat:开启思考模式(thinking.enabled + reasoning_effort: max),max_tokens 由 Provider 内部硬编码 65536
|
|
4
|
-
- chat_stream:关闭思考模式(thinking.disabled),max_tokens 由 Provider 内部硬编码 65536
|
|
5
|
-
- max_tokens 不接受外部覆盖:DeepSeek 思考模式要求 max_tokens ≥ 思考 + 回复预算,
|
|
6
|
-
由 Provider 全权决策;如需调整,直接修改本文件常量即可
|
|
7
|
-
- assistant 消息无 reasoning_content 时补 "null" 占位,规避 DeepSeek API 校验错误
|
|
8
|
-
- reasoning 提取优先级:msg.reasoning_content → msg.reasoning → response.reasoning → msg.content
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
from typing import Any, AsyncGenerator, Dict, List, Optional
|
|
12
|
-
|
|
13
|
-
from ..types import ChatMessage, ProviderResponse
|
|
14
|
-
from .base import BaseProvider
|
|
15
|
-
from .txcode_ai import TxCodeAI
|
|
16
|
-
|
|
17
|
-
# max_tokens 为 Provider 内部策略:DeepSeek 思考模式需预留思考 + 回复预算,
|
|
18
|
-
# 各厂商/模型上限差异显著,统一放在 Provider 内部硬编码,不暴露给上层。
|
|
19
|
-
_DEEPSEEK_MAX_TOKENS = 65536
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
"""DeepSeek Provider:对齐 TS 端 deepseek.provider.ts 行为,直接继承 BaseProvider。
|
|
2
|
+
|
|
3
|
+
- chat:开启思考模式(thinking.enabled + reasoning_effort: max),max_tokens 由 Provider 内部硬编码 65536
|
|
4
|
+
- chat_stream:关闭思考模式(thinking.disabled),max_tokens 由 Provider 内部硬编码 65536
|
|
5
|
+
- max_tokens 不接受外部覆盖:DeepSeek 思考模式要求 max_tokens ≥ 思考 + 回复预算,
|
|
6
|
+
由 Provider 全权决策;如需调整,直接修改本文件常量即可
|
|
7
|
+
- assistant 消息无 reasoning_content 时补 "null" 占位,规避 DeepSeek API 校验错误
|
|
8
|
+
- reasoning 提取优先级:msg.reasoning_content → msg.reasoning → response.reasoning → msg.content
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from typing import Any, AsyncGenerator, Dict, List, Optional
|
|
12
|
+
|
|
13
|
+
from ..types import ChatMessage, ProviderResponse
|
|
14
|
+
from .base import BaseProvider
|
|
15
|
+
from .txcode_ai import TxCodeAI
|
|
16
|
+
|
|
17
|
+
# max_tokens 为 Provider 内部策略:DeepSeek 思考模式需预留思考 + 回复预算,
|
|
18
|
+
# 各厂商/模型上限差异显著,统一放在 Provider 内部硬编码,不暴露给上层。
|
|
19
|
+
_DEEPSEEK_MAX_TOKENS = 65536
|
|
20
|
+
|
|
21
|
+
|
|
22
22
|
class DeepSeekProvider(BaseProvider):
|
|
23
23
|
def __init__(
|
|
24
24
|
self,
|
|
25
25
|
api_key: str,
|
|
26
26
|
base_url: str = "https://api.deepseek.com/v1",
|
|
27
27
|
model: str = "deepseek-chat",
|
|
28
|
+
connect_timeout: Optional[float] = None,
|
|
29
|
+
read_timeout: Optional[float] = None,
|
|
30
|
+
stream_interval_timeout: Optional[float] = None,
|
|
28
31
|
):
|
|
29
32
|
super().__init__(base_url=base_url, model=model)
|
|
30
|
-
|
|
31
|
-
api_key
|
|
32
|
-
base_url
|
|
33
|
-
default_headers
|
|
33
|
+
client_kwargs: Dict[str, Any] = {
|
|
34
|
+
"api_key": api_key,
|
|
35
|
+
"base_url": base_url,
|
|
36
|
+
"default_headers": {
|
|
34
37
|
"HTTP-Referer": "https://www.homecommunity.cn",
|
|
35
38
|
"X-Title": "txcode",
|
|
36
39
|
},
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
async def chat(
|
|
40
|
-
self,
|
|
41
|
-
messages: List[ChatMessage],
|
|
42
|
-
tools: Optional[List[dict]] = None,
|
|
43
|
-
abort_signal: Any = None,
|
|
44
|
-
log_context: Optional[dict] = None,
|
|
45
|
-
) -> ProviderResponse:
|
|
46
|
-
resolved = await self._resolve_messages(messages)
|
|
47
|
-
kwargs: Dict[str, Any] = {
|
|
48
|
-
"model": self._model,
|
|
49
|
-
"messages": resolved,
|
|
50
|
-
"max_tokens": _DEEPSEEK_MAX_TOKENS,
|
|
51
|
-
"thinking": {"type": "enabled"},
|
|
52
|
-
"reasoning_effort": "max",
|
|
53
|
-
}
|
|
54
|
-
if tools:
|
|
55
|
-
kwargs["tools"] = tools
|
|
56
|
-
kwargs["tool_choice"] = "auto"
|
|
57
|
-
|
|
58
|
-
if log_context:
|
|
59
|
-
self._write_log(log_context, "request", {
|
|
60
|
-
"model": self._model,
|
|
61
|
-
"messages": resolved,
|
|
62
|
-
"tools": tools or [],
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
response = await self._client.chat_completions(**kwargs)
|
|
66
|
-
parsed = self._parse_response(response)
|
|
67
|
-
|
|
68
|
-
if log_context:
|
|
69
|
-
self._write_log(log_context, "response", {
|
|
70
|
-
"model": self._model,
|
|
71
|
-
"finish_reason": parsed.finish_reason,
|
|
72
|
-
"content": parsed.content or "",
|
|
73
|
-
"tool_calls": parsed.tool_calls or [],
|
|
74
|
-
"usage": {
|
|
75
|
-
"prompt_tokens": parsed.usage.prompt_tokens,
|
|
76
|
-
"completion_tokens": parsed.usage.completion_tokens,
|
|
77
|
-
"total_tokens": parsed.usage.total_tokens,
|
|
78
|
-
} if parsed.usage else None,
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
return parsed
|
|
82
|
-
|
|
83
|
-
async def chat_stream(
|
|
84
|
-
self,
|
|
85
|
-
messages: List[ChatMessage],
|
|
86
|
-
tools: Optional[List[dict]] = None,
|
|
87
|
-
abort_signal: Any = None,
|
|
88
|
-
) -> AsyncGenerator[str, None]:
|
|
89
|
-
resolved = await self._resolve_messages(messages)
|
|
90
|
-
kwargs: Dict[str, Any] = {
|
|
91
|
-
"model": self._model,
|
|
92
|
-
"messages": resolved,
|
|
93
|
-
"max_tokens": _DEEPSEEK_MAX_TOKENS,
|
|
94
|
-
"stream": True,
|
|
95
|
-
"thinking": {"type": "disabled"},
|
|
96
40
|
}
|
|
97
|
-
if
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
41
|
+
if connect_timeout is not None:
|
|
42
|
+
client_kwargs["connect_timeout"] = connect_timeout
|
|
43
|
+
if read_timeout is not None:
|
|
44
|
+
client_kwargs["read_timeout"] = read_timeout
|
|
45
|
+
if stream_interval_timeout is not None:
|
|
46
|
+
client_kwargs["stream_interval_timeout"] = stream_interval_timeout
|
|
47
|
+
self._client = TxCodeAI(**client_kwargs)
|
|
48
|
+
|
|
49
|
+
async def chat(
|
|
50
|
+
self,
|
|
51
|
+
messages: List[ChatMessage],
|
|
52
|
+
tools: Optional[List[dict]] = None,
|
|
53
|
+
abort_signal: Any = None,
|
|
54
|
+
log_context: Optional[dict] = None,
|
|
55
|
+
) -> ProviderResponse:
|
|
56
|
+
resolved = await self._resolve_messages(messages)
|
|
57
|
+
kwargs: Dict[str, Any] = {
|
|
58
|
+
"model": self._model,
|
|
59
|
+
"messages": resolved,
|
|
60
|
+
"max_tokens": _DEEPSEEK_MAX_TOKENS,
|
|
61
|
+
"thinking": {"type": "enabled"},
|
|
62
|
+
"reasoning_effort": "max",
|
|
63
|
+
}
|
|
64
|
+
if tools:
|
|
65
|
+
kwargs["tools"] = tools
|
|
66
|
+
kwargs["tool_choice"] = "auto"
|
|
67
|
+
|
|
68
|
+
if log_context:
|
|
69
|
+
self._write_log(log_context, "request", {
|
|
70
|
+
"model": self._model,
|
|
71
|
+
"messages": resolved,
|
|
72
|
+
"tools": tools or [],
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
response = await self._client.chat_completions(**kwargs)
|
|
76
|
+
parsed = self._parse_response(response)
|
|
77
|
+
|
|
78
|
+
if log_context:
|
|
79
|
+
self._write_log(log_context, "response", {
|
|
80
|
+
"model": self._model,
|
|
81
|
+
"finish_reason": parsed.finish_reason,
|
|
82
|
+
"content": parsed.content or "",
|
|
83
|
+
"tool_calls": parsed.tool_calls or [],
|
|
84
|
+
"usage": {
|
|
85
|
+
"prompt_tokens": parsed.usage.prompt_tokens,
|
|
86
|
+
"completion_tokens": parsed.usage.completion_tokens,
|
|
87
|
+
"total_tokens": parsed.usage.total_tokens,
|
|
88
|
+
} if parsed.usage else None,
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
return parsed
|
|
92
|
+
|
|
93
|
+
async def chat_stream(
|
|
94
|
+
self,
|
|
95
|
+
messages: List[ChatMessage],
|
|
96
|
+
tools: Optional[List[dict]] = None,
|
|
97
|
+
abort_signal: Any = None,
|
|
98
|
+
) -> AsyncGenerator[str, None]:
|
|
99
|
+
resolved = await self._resolve_messages(messages)
|
|
100
|
+
kwargs: Dict[str, Any] = {
|
|
101
|
+
"model": self._model,
|
|
102
|
+
"messages": resolved,
|
|
103
|
+
"max_tokens": _DEEPSEEK_MAX_TOKENS,
|
|
104
|
+
"stream": True,
|
|
105
|
+
"thinking": {"type": "disabled"},
|
|
106
|
+
}
|
|
107
|
+
if tools:
|
|
108
|
+
kwargs["tools"] = tools
|
|
109
|
+
|
|
110
|
+
async for chunk in self._client.chat_completions_stream(**kwargs):
|
|
111
|
+
choices = chunk.get("choices") or []
|
|
112
|
+
if not choices:
|
|
113
|
+
continue
|
|
114
|
+
delta = choices[0].get("delta") or {}
|
|
115
|
+
content = delta.get("content")
|
|
116
|
+
if content:
|
|
117
|
+
yield content
|
|
118
|
+
|
|
119
|
+
def _format_message(self, msg: ChatMessage) -> dict:
|
|
120
|
+
formatted = super()._format_message(msg)
|
|
121
|
+
if msg.role == "assistant" and not formatted.get("reasoning_content"):
|
|
122
|
+
formatted["reasoning_content"] = "null"
|
|
123
|
+
return formatted
|
|
124
|
+
|
|
125
|
+
def _parse_response(self, response: dict) -> ProviderResponse:
|
|
126
|
+
result = super()._parse_response(response)
|
|
127
|
+
choice = (response.get("choices") or [{}])[0]
|
|
128
|
+
msg = choice.get("message") or {}
|
|
129
|
+
reasoning = (
|
|
130
|
+
msg.get("reasoning_content")
|
|
131
|
+
or msg.get("reasoning")
|
|
132
|
+
or response.get("reasoning")
|
|
133
|
+
or (msg.get("content") or "")
|
|
134
|
+
)
|
|
135
|
+
if reasoning:
|
|
136
|
+
result.reasoning = reasoning
|
|
137
|
+
return result
|
|
@@ -1,99 +1,109 @@
|
|
|
1
|
-
"""OpenAI Provider:基于自研 TxCodeAI(urllib)实现,零 openai SDK 依赖。
|
|
2
|
-
|
|
3
|
-
max_tokens 由 Provider 内部硬编码 65536,不接受外部覆盖。
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
from typing import Any, AsyncGenerator, Dict, List, Optional
|
|
7
|
-
|
|
8
|
-
from ..types import ChatMessage, ProviderResponse
|
|
9
|
-
from .base import BaseProvider
|
|
10
|
-
from .txcode_ai import TxCodeAI
|
|
11
|
-
|
|
12
|
-
_OPENAI_MAX_TOKENS = 65536
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
"""OpenAI Provider:基于自研 TxCodeAI(urllib)实现,零 openai SDK 依赖。
|
|
2
|
+
|
|
3
|
+
max_tokens 由 Provider 内部硬编码 65536,不接受外部覆盖。
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from typing import Any, AsyncGenerator, Dict, List, Optional
|
|
7
|
+
|
|
8
|
+
from ..types import ChatMessage, ProviderResponse
|
|
9
|
+
from .base import BaseProvider
|
|
10
|
+
from .txcode_ai import TxCodeAI
|
|
11
|
+
|
|
12
|
+
_OPENAI_MAX_TOKENS = 65536
|
|
13
|
+
|
|
14
|
+
|
|
15
15
|
class OpenAIProvider(BaseProvider):
|
|
16
16
|
def __init__(
|
|
17
17
|
self,
|
|
18
18
|
api_key: str,
|
|
19
19
|
base_url: str = "https://api.openai.com/v1",
|
|
20
20
|
model: str = "gpt-4",
|
|
21
|
+
connect_timeout: Optional[float] = None,
|
|
22
|
+
read_timeout: Optional[float] = None,
|
|
23
|
+
stream_interval_timeout: Optional[float] = None,
|
|
21
24
|
):
|
|
22
25
|
super().__init__(base_url=base_url, model=model)
|
|
23
|
-
|
|
24
|
-
api_key
|
|
25
|
-
base_url
|
|
26
|
-
default_headers
|
|
26
|
+
client_kwargs: Dict[str, Any] = {
|
|
27
|
+
"api_key": api_key,
|
|
28
|
+
"base_url": base_url,
|
|
29
|
+
"default_headers": {
|
|
27
30
|
"HTTP-Referer": "https://www.homecommunity.cn",
|
|
28
31
|
"X-Title": "txcode",
|
|
29
32
|
},
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
async def chat(
|
|
33
|
-
self,
|
|
34
|
-
messages: List[ChatMessage],
|
|
35
|
-
tools: Optional[List[dict]] = None,
|
|
36
|
-
abort_signal: Any = None,
|
|
37
|
-
log_context: Optional[dict] = None,
|
|
38
|
-
) -> ProviderResponse:
|
|
39
|
-
resolved = await self._resolve_messages(messages)
|
|
40
|
-
kwargs: Dict[str, Any] = {
|
|
41
|
-
"model": self._model,
|
|
42
|
-
"messages": resolved,
|
|
43
|
-
"temperature": 0.7,
|
|
44
|
-
"max_tokens": _OPENAI_MAX_TOKENS,
|
|
45
|
-
}
|
|
46
|
-
if tools:
|
|
47
|
-
kwargs["tools"] = tools
|
|
48
|
-
kwargs["tool_choice"] = "auto"
|
|
49
|
-
|
|
50
|
-
if log_context:
|
|
51
|
-
self._write_log(log_context, "request", {
|
|
52
|
-
"model": self._model,
|
|
53
|
-
"messages": resolved,
|
|
54
|
-
"tools": tools or [],
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
response = await self._client.chat_completions(**kwargs)
|
|
58
|
-
parsed = self._parse_response(response)
|
|
59
|
-
|
|
60
|
-
if log_context:
|
|
61
|
-
self._write_log(log_context, "response", {
|
|
62
|
-
"model": self._model,
|
|
63
|
-
"finish_reason": parsed.finish_reason,
|
|
64
|
-
"content": parsed.content or "",
|
|
65
|
-
"tool_calls": parsed.tool_calls or [],
|
|
66
|
-
"usage": {
|
|
67
|
-
"prompt_tokens": parsed.usage.prompt_tokens,
|
|
68
|
-
"completion_tokens": parsed.usage.completion_tokens,
|
|
69
|
-
"total_tokens": parsed.usage.total_tokens,
|
|
70
|
-
} if parsed.usage else None,
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
return parsed
|
|
74
|
-
|
|
75
|
-
async def chat_stream(
|
|
76
|
-
self,
|
|
77
|
-
messages: List[ChatMessage],
|
|
78
|
-
tools: Optional[List[dict]] = None,
|
|
79
|
-
abort_signal: Any = None,
|
|
80
|
-
) -> AsyncGenerator[str, None]:
|
|
81
|
-
resolved = await self._resolve_messages(messages)
|
|
82
|
-
kwargs: Dict[str, Any] = {
|
|
83
|
-
"model": self._model,
|
|
84
|
-
"messages": resolved,
|
|
85
|
-
"temperature": 0.7,
|
|
86
|
-
"max_tokens": _OPENAI_MAX_TOKENS,
|
|
87
|
-
"stream": True,
|
|
88
33
|
}
|
|
89
|
-
if
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
34
|
+
if connect_timeout is not None:
|
|
35
|
+
client_kwargs["connect_timeout"] = connect_timeout
|
|
36
|
+
if read_timeout is not None:
|
|
37
|
+
client_kwargs["read_timeout"] = read_timeout
|
|
38
|
+
if stream_interval_timeout is not None:
|
|
39
|
+
client_kwargs["stream_interval_timeout"] = stream_interval_timeout
|
|
40
|
+
self._client = TxCodeAI(**client_kwargs)
|
|
41
|
+
|
|
42
|
+
async def chat(
|
|
43
|
+
self,
|
|
44
|
+
messages: List[ChatMessage],
|
|
45
|
+
tools: Optional[List[dict]] = None,
|
|
46
|
+
abort_signal: Any = None,
|
|
47
|
+
log_context: Optional[dict] = None,
|
|
48
|
+
) -> ProviderResponse:
|
|
49
|
+
resolved = await self._resolve_messages(messages)
|
|
50
|
+
kwargs: Dict[str, Any] = {
|
|
51
|
+
"model": self._model,
|
|
52
|
+
"messages": resolved,
|
|
53
|
+
"temperature": 0.7,
|
|
54
|
+
"max_tokens": _OPENAI_MAX_TOKENS,
|
|
55
|
+
}
|
|
56
|
+
if tools:
|
|
57
|
+
kwargs["tools"] = tools
|
|
58
|
+
kwargs["tool_choice"] = "auto"
|
|
59
|
+
|
|
60
|
+
if log_context:
|
|
61
|
+
self._write_log(log_context, "request", {
|
|
62
|
+
"model": self._model,
|
|
63
|
+
"messages": resolved,
|
|
64
|
+
"tools": tools or [],
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
response = await self._client.chat_completions(**kwargs)
|
|
68
|
+
parsed = self._parse_response(response)
|
|
69
|
+
|
|
70
|
+
if log_context:
|
|
71
|
+
self._write_log(log_context, "response", {
|
|
72
|
+
"model": self._model,
|
|
73
|
+
"finish_reason": parsed.finish_reason,
|
|
74
|
+
"content": parsed.content or "",
|
|
75
|
+
"tool_calls": parsed.tool_calls or [],
|
|
76
|
+
"usage": {
|
|
77
|
+
"prompt_tokens": parsed.usage.prompt_tokens,
|
|
78
|
+
"completion_tokens": parsed.usage.completion_tokens,
|
|
79
|
+
"total_tokens": parsed.usage.total_tokens,
|
|
80
|
+
} if parsed.usage else None,
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
return parsed
|
|
84
|
+
|
|
85
|
+
async def chat_stream(
|
|
86
|
+
self,
|
|
87
|
+
messages: List[ChatMessage],
|
|
88
|
+
tools: Optional[List[dict]] = None,
|
|
89
|
+
abort_signal: Any = None,
|
|
90
|
+
) -> AsyncGenerator[str, None]:
|
|
91
|
+
resolved = await self._resolve_messages(messages)
|
|
92
|
+
kwargs: Dict[str, Any] = {
|
|
93
|
+
"model": self._model,
|
|
94
|
+
"messages": resolved,
|
|
95
|
+
"temperature": 0.7,
|
|
96
|
+
"max_tokens": _OPENAI_MAX_TOKENS,
|
|
97
|
+
"stream": True,
|
|
98
|
+
}
|
|
99
|
+
if tools:
|
|
100
|
+
kwargs["tools"] = tools
|
|
101
|
+
|
|
102
|
+
async for chunk in self._client.chat_completions_stream(**kwargs):
|
|
103
|
+
choices = chunk.get("choices") or []
|
|
104
|
+
if not choices:
|
|
105
|
+
continue
|
|
106
|
+
delta = choices[0].get("delta") or {}
|
|
107
|
+
content = delta.get("content")
|
|
108
|
+
if content:
|
|
109
|
+
yield content
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
- ``chat_completions``:POST ``{base_url}/chat/completions`` 普通对话
|
|
6
6
|
- ``chat_completions_stream``:SSE 流式对话(逐行解析 ``data:`` 事件,``[DONE]`` 终止)
|
|
7
7
|
- 429 / 5xx 指数退避重试(默认 3 次)
|
|
8
|
-
- connect / read 双级超时(默认 30s /
|
|
8
|
+
- connect / read 双级超时(默认 30s / 600s)
|
|
9
|
+
- 流式间隔超时(默认 120s):两次收到 chunk 之间的最大间隔,而非总时长
|
|
9
10
|
- JSON 解析容错与错误信息透传
|
|
10
11
|
|
|
11
12
|
所有网络操作均为同步实现,异步侧通过 ``loop.run_in_executor`` 避免阻塞事件循环
|
|
@@ -20,7 +21,8 @@ import urllib.error
|
|
|
20
21
|
import urllib.request
|
|
21
22
|
|
|
22
23
|
DEFAULT_CONNECT_TIMEOUT = 30
|
|
23
|
-
DEFAULT_READ_TIMEOUT =
|
|
24
|
+
DEFAULT_READ_TIMEOUT = 600
|
|
25
|
+
DEFAULT_STREAM_INTERVAL_TIMEOUT = 120
|
|
24
26
|
DEFAULT_MAX_RETRIES = 3
|
|
25
27
|
|
|
26
28
|
_RETRYABLE_HTTP_CODES = (408, 409, 429)
|
|
@@ -41,6 +43,7 @@ class TxCodeAI(object):
|
|
|
41
43
|
default_headers=None,
|
|
42
44
|
connect_timeout=DEFAULT_CONNECT_TIMEOUT,
|
|
43
45
|
read_timeout=DEFAULT_READ_TIMEOUT,
|
|
46
|
+
stream_interval_timeout=DEFAULT_STREAM_INTERVAL_TIMEOUT,
|
|
44
47
|
max_retries=DEFAULT_MAX_RETRIES,
|
|
45
48
|
):
|
|
46
49
|
self._api_key = api_key
|
|
@@ -48,6 +51,7 @@ class TxCodeAI(object):
|
|
|
48
51
|
self._default_headers = dict(default_headers or {})
|
|
49
52
|
self._connect_timeout = connect_timeout
|
|
50
53
|
self._read_timeout = read_timeout
|
|
54
|
+
self._stream_interval_timeout = stream_interval_timeout
|
|
51
55
|
self._max_retries = max_retries
|
|
52
56
|
|
|
53
57
|
# ------------------------------------------------------------------
|
|
@@ -120,13 +124,17 @@ class TxCodeAI(object):
|
|
|
120
124
|
headers.update(self._default_headers)
|
|
121
125
|
return urllib.request.Request(url, data=body, headers=headers, method="POST")
|
|
122
126
|
|
|
123
|
-
def _open(self, req):
|
|
124
|
-
"""发送请求并返回响应;429/5xx 与网络错误按指数退避重试。
|
|
127
|
+
def _open(self, req, read_timeout=None):
|
|
128
|
+
"""发送请求并返回响应;429/5xx 与网络错误按指数退避重试。
|
|
129
|
+
|
|
130
|
+
read_timeout 为 None 时使用非流式读取超时(self._read_timeout),
|
|
131
|
+
流式调用方传入 self._stream_interval_timeout 以区分"两次 chunk 间最大间隔"语义。
|
|
132
|
+
"""
|
|
125
133
|
last_error = None
|
|
126
134
|
for attempt in range(self._max_retries):
|
|
127
135
|
try:
|
|
128
136
|
resp = urllib.request.urlopen(req, timeout=self._connect_timeout)
|
|
129
|
-
self._apply_read_timeout(resp)
|
|
137
|
+
self._apply_read_timeout(resp, read_timeout)
|
|
130
138
|
return resp
|
|
131
139
|
except urllib.error.HTTPError as e:
|
|
132
140
|
last_error = e
|
|
@@ -142,11 +150,16 @@ class TxCodeAI(object):
|
|
|
142
150
|
time.sleep(self._backoff_delay(attempt))
|
|
143
151
|
raise TxCodeAIError("Request failed: %s" % last_error)
|
|
144
152
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
153
|
+
def _apply_read_timeout(self, resp, timeout=None):
|
|
154
|
+
"""读取阶段使用独立超时(connect 30s / read 600s 双级)。
|
|
155
|
+
|
|
156
|
+
timeout 为 None 时使用实例超时 self._read_timeout(非流式整响应读取);
|
|
157
|
+
流式调用方传入 self._stream_interval_timeout(两次 chunk 间最大间隔)。
|
|
158
|
+
"""
|
|
159
|
+
if timeout is None:
|
|
160
|
+
timeout = self._read_timeout
|
|
148
161
|
try:
|
|
149
|
-
resp.fp.raw._sock.settimeout(
|
|
162
|
+
resp.fp.raw._sock.settimeout(timeout)
|
|
150
163
|
except Exception: # noqa: BLE001
|
|
151
164
|
pass
|
|
152
165
|
|
|
@@ -166,7 +179,7 @@ class TxCodeAI(object):
|
|
|
166
179
|
# ------------------------------------------------------------------
|
|
167
180
|
def _iter_sse_chunks(self, kwargs):
|
|
168
181
|
req = self._build_request("/chat/completions", kwargs)
|
|
169
|
-
resp = self._open(req)
|
|
182
|
+
resp = self._open(req, read_timeout=self._stream_interval_timeout)
|
|
170
183
|
data_lines = []
|
|
171
184
|
try:
|
|
172
185
|
for raw_line in resp:
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
import argparse
|
|
20
|
+
import logging
|
|
20
21
|
import os
|
|
21
22
|
import sys
|
|
22
23
|
|
|
@@ -27,6 +28,13 @@ DEFAULT_PORT = 41000
|
|
|
27
28
|
DEFAULT_BASE_URL = "https://api.openai.com/v1"
|
|
28
29
|
DEFAULT_MODEL = "gpt-4"
|
|
29
30
|
|
|
31
|
+
LOG_LEVELS = {
|
|
32
|
+
"debug": logging.DEBUG,
|
|
33
|
+
"info": logging.INFO,
|
|
34
|
+
"warning": logging.WARNING,
|
|
35
|
+
"error": logging.ERROR,
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
|
|
31
39
|
def _user_config_dir() -> str:
|
|
32
40
|
"""用户层配置目录 ~/.txcode(providers.json / projects.json 存放处)。"""
|
|
@@ -67,6 +75,16 @@ def _add_serve_args(parser: argparse.ArgumentParser):
|
|
|
67
75
|
parser.add_argument("--host", default=argparse.SUPPRESS, help="监听地址(默认 %s)" % DEFAULT_HOST)
|
|
68
76
|
parser.add_argument("--port", type=int, default=argparse.SUPPRESS, help="监听端口(默认 %d)" % DEFAULT_PORT)
|
|
69
77
|
parser.add_argument("--agent-type", default=argparse.SUPPRESS, help="Agent 类型(默认 code)")
|
|
78
|
+
parser.add_argument(
|
|
79
|
+
"--log-level",
|
|
80
|
+
default=argparse.SUPPRESS,
|
|
81
|
+
help="日志级别 debug/info/warning/error(默认 info)",
|
|
82
|
+
)
|
|
83
|
+
parser.add_argument(
|
|
84
|
+
"--log-file",
|
|
85
|
+
default=argparse.SUPPRESS,
|
|
86
|
+
help="日志文件路径(可选,UTF-8 追加写入)",
|
|
87
|
+
)
|
|
70
88
|
parser.add_argument(
|
|
71
89
|
"--models",
|
|
72
90
|
default=argparse.SUPPRESS,
|
|
@@ -100,11 +118,12 @@ class MissingApiKeyError(Exception):
|
|
|
100
118
|
pass
|
|
101
119
|
|
|
102
120
|
|
|
103
|
-
async def build_components(args, user_dir: str = None):
|
|
121
|
+
async def build_components(args, user_dir: str = None, log_enabled: bool = False):
|
|
104
122
|
"""启动装配(JSON 为权威源):返回 (client, provider_config, project_manager, work_dir)。
|
|
105
123
|
|
|
106
124
|
0.4.1 起无激活供应商时不再抛 MissingApiKeyError,以占位 client(api_key 为空)
|
|
107
125
|
空配置启动,等待桌面端 WS 添加供应商;环境变量不再参与装配。
|
|
126
|
+
log_enabled 透传 TxCodeClient:info/debug 级别时开启 Agent 循环日志。
|
|
108
127
|
"""
|
|
109
128
|
from txcode_sdk import TxCodeClient
|
|
110
129
|
from .provider_config import ProviderConfigManager
|
|
@@ -137,6 +156,7 @@ async def build_components(args, user_dir: str = None):
|
|
|
137
156
|
model=DEFAULT_MODEL,
|
|
138
157
|
work_dir=work_dir,
|
|
139
158
|
agent_type=getattr(args, "agent_type", None) or "code",
|
|
159
|
+
log_enabled=log_enabled,
|
|
140
160
|
)
|
|
141
161
|
sys.stderr.write(
|
|
142
162
|
"[txcode-sdk] WARN: No active provider configured, "
|
|
@@ -153,10 +173,31 @@ async def build_components(args, user_dir: str = None):
|
|
|
153
173
|
model=model,
|
|
154
174
|
work_dir=work_dir,
|
|
155
175
|
agent_type=getattr(args, "agent_type", None) or "code",
|
|
176
|
+
log_enabled=log_enabled,
|
|
156
177
|
)
|
|
157
178
|
return client, provider_config, project_manager, work_dir
|
|
158
179
|
|
|
159
180
|
|
|
181
|
+
def setup_logging(args) -> bool:
|
|
182
|
+
"""装配 root logger(stdout + 可选文件 handler),返回 log_enabled。
|
|
183
|
+
|
|
184
|
+
--log-level 为 debug/info 时开启 Agent 循环日志(log_enabled=True);
|
|
185
|
+
warning/error 时关闭高频 INFO,仅保留 WARNING/ERROR。
|
|
186
|
+
"""
|
|
187
|
+
log_level = getattr(args, "log_level", None) or "info"
|
|
188
|
+
level = LOG_LEVELS.get(log_level.lower(), logging.INFO)
|
|
189
|
+
handlers = [logging.StreamHandler(sys.stdout)]
|
|
190
|
+
log_file = getattr(args, "log_file", None)
|
|
191
|
+
if log_file:
|
|
192
|
+
handlers.append(logging.FileHandler(log_file, encoding="utf-8"))
|
|
193
|
+
logging.basicConfig(
|
|
194
|
+
level=level,
|
|
195
|
+
format="%(asctime)s %(levelname)s %(name)s | %(message)s",
|
|
196
|
+
handlers=handlers,
|
|
197
|
+
)
|
|
198
|
+
return level <= logging.INFO
|
|
199
|
+
|
|
200
|
+
|
|
160
201
|
def main(argv=None) -> int:
|
|
161
202
|
parser = build_parser()
|
|
162
203
|
args = parser.parse_args(argv)
|
|
@@ -168,11 +209,12 @@ def main(argv=None) -> int:
|
|
|
168
209
|
|
|
169
210
|
host = getattr(args, "host", None) or DEFAULT_HOST
|
|
170
211
|
port = getattr(args, "port", None) or DEFAULT_PORT
|
|
212
|
+
log_enabled = setup_logging(args)
|
|
171
213
|
|
|
172
214
|
loop = _get_event_loop()
|
|
173
215
|
try:
|
|
174
216
|
client, provider_config, project_manager, work_dir = loop.run_until_complete(
|
|
175
|
-
build_components(args)
|
|
217
|
+
build_components(args, log_enabled=log_enabled)
|
|
176
218
|
)
|
|
177
219
|
except MissingApiKeyError as exc:
|
|
178
220
|
sys.stderr.write("[txcode-sdk] ERROR: %s\n" % exc)
|