sycommon-python-lib 0.2.3a11__tar.gz → 0.2.4a0__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.
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/PKG-INFO +8 -6
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/pyproject.toml +8 -6
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/__init__.py +26 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/deep_agent.py +21 -2
- sycommon_python_lib-0.2.4a0/src/sycommon/agent/mcp/__init__.py +30 -0
- sycommon_python_lib-0.2.4a0/src/sycommon/agent/mcp/models.py +56 -0
- sycommon_python_lib-0.2.4a0/src/sycommon/agent/mcp/tool_loader.py +174 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/multi_agent_team.py +6 -2
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/summarization_utils.py +72 -29
- sycommon_python_lib-0.2.4a0/src/sycommon/config/PgConfig.py +54 -0
- sycommon_python_lib-0.2.4a0/src/sycommon/database/pg_checkpoint_service.py +124 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/get_llm.py +4 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/services.py +18 -2
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon_python_lib.egg-info/PKG-INFO +8 -6
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon_python_lib.egg-info/SOURCES.txt +5 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon_python_lib.egg-info/requires.txt +7 -5
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/README.md +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/setup.cfg +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/cli.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/core/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/core/console.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/core/models.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/core/project.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/core/utils.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/README.md.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/agent/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/agent/main_agent.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/agent/nodes/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/agent/nodes/example_node.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/agent/states/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/agent/states/agent_state.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/api/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/api/query.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/api/sse/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/api/sse/agent.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/app.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/client/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/db/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/db/model/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/db/model/entity.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/db/service.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/model/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/model/parse.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/tools/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/agent/tools/mq.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/.env.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/.gitignore.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/Dockerfile.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/README.md.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/app.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/app.yaml.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/client/FileServiceClient.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/client/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/model/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/model/file_info.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/base/requirements.txt.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/cli/README.md.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/cli/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/cli/app.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/cli/commands/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/cli/commands/hello.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/cli/pyproject.toml.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/cli/tools/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/web/README.md.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/web/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/web/api/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/web/api/echo.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/web/api/sse/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/web/api/sse/echo.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/web/app.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/web/client/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/web/model/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/web/tools/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/command/templates/web/tools/mq.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/nexus/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/__main__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/agents/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/agents/factory.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/agents/prompts.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/browser.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/capabilities/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/capabilities/console.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/capabilities/dom.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/capabilities/network.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/capabilities/page_errors.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/capabilities/performance.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/capabilities/screenshot.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/client.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/protocol.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cdp/repl.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/cli.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/commands/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/commands/cdp_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/commands/chat_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/commands/create_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/commands/evaluate_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/commands/init_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/commands/memory_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/commands/resume_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/commands/rollback_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/commands/run_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/core/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/core/backend.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/core/config.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/core/display.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/core/git_integration.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/core/llm.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/core/state.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/evaluate/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/evaluate/api_evaluator.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/memory/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/memory/compressor.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/memory/full.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/memory/hot.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/memory/manager.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/memory/warm.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/mode/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/mode/create.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/mode/optimize.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/models/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/models/config_models.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/baseline_tests.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/checkpoint.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/convergence.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/diagnosis.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/engine.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/environment.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/experience.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/harness_prompts.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/history.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/optimization_logger.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/pre_validation.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/reward.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/strategy_bandit.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/strategy_generator.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/rl/strategy_prompts.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycli/skills/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/agent_manager.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/chat_events.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/sandbox/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/sandbox/file_ops.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/sandbox/http_sandbox_backend.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/sandbox/minio_sync.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/sandbox/sandbox_pool.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/sandbox/sandbox_recovery.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/sandbox/session.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/auth/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/auth/ldap_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/auth/wecom_ldap_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/Config.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/DatabaseConfig.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/ElasticsearchConfig.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/EmbeddingConfig.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/LLMConfig.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/LangfuseConfig.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/MQConfig.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/RedisConfig.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/RerankerConfig.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/SentryConfig.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/XxlJobConfig.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/config/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/database/async_base_db_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/database/async_database_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/database/base_db_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/database/database_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/database/elasticsearch_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/database/redis_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/database/token_usage_db_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/health/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/health/health_check.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/health/metrics.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/health/ping.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/heartbeat_process/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/heartbeat_process/heartbeat_config.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/heartbeat_process/heartbeat_process_manager.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/heartbeat_process/heartbeat_process_worker.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/embedding.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/llm_logger.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/llm_tokens.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/llm_with_token_tracking.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/native_with_fallback_runnable.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/output_fixing_runnable.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/struct_token.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/sy_langfuse.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/token_usage_es_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/token_usage_mysql_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/llm/usage_token.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/logging/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/logging/async_sql_logger.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/logging/kafka_log.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/logging/logger_levels.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/logging/logger_wrapper.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/logging/process_logger.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/logging/sql_logger.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/background_execution.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/context.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/cors.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/docs.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/exception.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/middleware.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/monitor_memory.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/mq.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/sandbox.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/timeout.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/token_tracking.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/tool_result_truncation.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/middleware/traceid.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/models/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/models/base_http.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/models/log.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/models/mqlistener_config.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/models/mqmsg_model.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/models/mqsend_config.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/models/sandbox.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/models/sso_user.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/models/token_usage.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/models/token_usage_mysql.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/models/xxljob_handler_config.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/notice/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/notice/uvicorn_monitor.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/notice/wecom_message.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/rabbitmq/process_pool_consumer.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/rabbitmq/rabbitmq_client.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/rabbitmq/rabbitmq_pool.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/rabbitmq/rabbitmq_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/rabbitmq/rabbitmq_service_client_manager.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/rabbitmq/rabbitmq_service_connection_monitor.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/rabbitmq/rabbitmq_service_consumer_manager.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/rabbitmq/rabbitmq_service_core.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/rabbitmq/rabbitmq_service_producer_manager.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/sentry/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/sentry/sy_sentry.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/sse/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/sse/event.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/sse/sse.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/example.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/example2.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/feign.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/feign_client.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/nacos_client_base.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/nacos_config_manager.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/nacos_heartbeat_manager.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/nacos_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/nacos_service_discovery.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/nacos_service_registration.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/synacos/param.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tests/deep_agent_server.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tests/test_deep_agent.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tests/test_email.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tests/test_mq.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tests/test_real_summarization.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tests/test_summarization_config.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tests/test_summarization_real.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tools/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tools/async_utils.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tools/docs.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tools/env.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tools/merge_headers.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tools/snowflake.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tools/syemail.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/tools/timing.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/xxljob/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/xxljob/xxljob_service.py +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon_python_lib.egg-info/dependency_links.txt +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon_python_lib.egg-info/entry_points.txt +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon_python_lib.egg-info/top_level.txt +0 -0
- {sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/tests/test_sycli.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sycommon-python-lib
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4a0
|
|
4
4
|
Summary: Add your description here
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -8,17 +8,18 @@ Requires-Dist: aio-pika>=9.6.2
|
|
|
8
8
|
Requires-Dist: aiohttp>=3.13.5
|
|
9
9
|
Requires-Dist: aiomysql>=0.3.2
|
|
10
10
|
Requires-Dist: anyio>=4.12.1
|
|
11
|
-
Requires-Dist: decorator>=5.
|
|
11
|
+
Requires-Dist: decorator>=5.3.0
|
|
12
12
|
Requires-Dist: deepagents>=0.6.1
|
|
13
13
|
Requires-Dist: elasticsearch>=9.4.0
|
|
14
14
|
Requires-Dist: fastapi>=0.136.1
|
|
15
15
|
Requires-Dist: jinja2>=3.1.6
|
|
16
16
|
Requires-Dist: kafka-python>=2.3.1
|
|
17
|
-
Requires-Dist: langchain>=1.3.
|
|
17
|
+
Requires-Dist: langchain>=1.3.1
|
|
18
18
|
Requires-Dist: langchain-core>=1.4.0
|
|
19
19
|
Requires-Dist: langchain-openai>=1.2.1
|
|
20
20
|
Requires-Dist: langfuse>=4.6.1
|
|
21
21
|
Requires-Dist: langgraph>=1.2.0
|
|
22
|
+
Requires-Dist: langgraph-checkpoint-postgres>=3.1.0
|
|
22
23
|
Requires-Dist: langgraph-checkpoint-redis>=0.4.1
|
|
23
24
|
Requires-Dist: ldap3>=2.9.1
|
|
24
25
|
Requires-Dist: loguru>=0.7.3
|
|
@@ -28,17 +29,18 @@ Requires-Dist: psutil>=7.2.2
|
|
|
28
29
|
Requires-Dist: pyxxl>=0.4.6
|
|
29
30
|
Requires-Dist: pydantic>=2.13.4
|
|
30
31
|
Requires-Dist: python-dotenv>=1.2.2
|
|
31
|
-
Requires-Dist: python-multipart>=0.0.
|
|
32
|
+
Requires-Dist: python-multipart>=0.0.29
|
|
32
33
|
Requires-Dist: pyyaml>=6.0.3
|
|
33
34
|
Requires-Dist: redis>=7.3.0
|
|
34
35
|
Requires-Dist: sentry-sdk[fastapi]>=2.60.0
|
|
35
36
|
Requires-Dist: sqlalchemy[asyncio]>=2.0.48
|
|
36
37
|
Requires-Dist: starlette[full]>=1.0.0
|
|
37
|
-
Requires-Dist: tiktoken>=0.
|
|
38
|
-
Requires-Dist: uvicorn>=0.
|
|
38
|
+
Requires-Dist: tiktoken>=0.13.0
|
|
39
|
+
Requires-Dist: uvicorn>=0.47.0
|
|
39
40
|
Requires-Dist: wecom-aibot-python-sdk>=1.0.2
|
|
40
41
|
Requires-Dist: twine>=6.2.0
|
|
41
42
|
Requires-Dist: minio>=7.2.20
|
|
43
|
+
Requires-Dist: langchain-mcp-adapters>=0.2.2
|
|
42
44
|
|
|
43
45
|
# sycommon-python-lib
|
|
44
46
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sycommon-python-lib"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.4a0"
|
|
4
4
|
description = "Add your description here"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
@@ -9,17 +9,18 @@ dependencies = [
|
|
|
9
9
|
"aiohttp>=3.13.5",
|
|
10
10
|
"aiomysql>=0.3.2",
|
|
11
11
|
"anyio>=4.12.1",
|
|
12
|
-
"decorator>=5.
|
|
12
|
+
"decorator>=5.3.0",
|
|
13
13
|
"deepagents>=0.6.1",
|
|
14
14
|
"elasticsearch>=9.4.0",
|
|
15
15
|
"fastapi>=0.136.1",
|
|
16
16
|
"jinja2>=3.1.6",
|
|
17
17
|
"kafka-python>=2.3.1",
|
|
18
|
-
"langchain>=1.3.
|
|
18
|
+
"langchain>=1.3.1",
|
|
19
19
|
"langchain-core>=1.4.0",
|
|
20
20
|
"langchain-openai>=1.2.1",
|
|
21
21
|
"langfuse>=4.6.1",
|
|
22
22
|
"langgraph>=1.2.0",
|
|
23
|
+
"langgraph-checkpoint-postgres>=3.1.0",
|
|
23
24
|
"langgraph-checkpoint-redis>=0.4.1",
|
|
24
25
|
"ldap3>=2.9.1",
|
|
25
26
|
"loguru>=0.7.3",
|
|
@@ -29,17 +30,18 @@ dependencies = [
|
|
|
29
30
|
"pyxxl>=0.4.6",
|
|
30
31
|
"pydantic>=2.13.4",
|
|
31
32
|
"python-dotenv>=1.2.2",
|
|
32
|
-
"python-multipart>=0.0.
|
|
33
|
+
"python-multipart>=0.0.29",
|
|
33
34
|
"pyyaml>=6.0.3",
|
|
34
35
|
"redis>=7.3.0",
|
|
35
36
|
"sentry-sdk[fastapi]>=2.60.0",
|
|
36
37
|
"sqlalchemy[asyncio]>=2.0.48",
|
|
37
38
|
"starlette[full]>=1.0.0",
|
|
38
|
-
"tiktoken>=0.
|
|
39
|
-
"uvicorn>=0.
|
|
39
|
+
"tiktoken>=0.13.0",
|
|
40
|
+
"uvicorn>=0.47.0",
|
|
40
41
|
"wecom-aibot-python-sdk>=1.0.2",
|
|
41
42
|
"twine>=6.2.0",
|
|
42
43
|
"minio>=7.2.20",
|
|
44
|
+
"langchain-mcp-adapters>=0.2.2",
|
|
43
45
|
]
|
|
44
46
|
|
|
45
47
|
[tool.setuptools]
|
|
@@ -105,6 +105,18 @@ from sycommon.agent.chat_events import (
|
|
|
105
105
|
error_event,
|
|
106
106
|
cancelled_event,
|
|
107
107
|
)
|
|
108
|
+
from sycommon.agent.mcp import (
|
|
109
|
+
MCPToolStatus,
|
|
110
|
+
MCPServerConfig,
|
|
111
|
+
MCPServerCreateRequest,
|
|
112
|
+
MCPServerUpdateRequest,
|
|
113
|
+
MCPServerTestRequest,
|
|
114
|
+
MCPServerTestResult,
|
|
115
|
+
load_mcp_tools,
|
|
116
|
+
test_mcp_connection,
|
|
117
|
+
sanitize_name,
|
|
118
|
+
)
|
|
119
|
+
from sycommon.database.pg_checkpoint_service import PgCheckpointService
|
|
108
120
|
|
|
109
121
|
__all__ = [
|
|
110
122
|
# 沙箱
|
|
@@ -147,4 +159,18 @@ __all__ = [
|
|
|
147
159
|
"done_event",
|
|
148
160
|
"error_event",
|
|
149
161
|
"cancelled_event",
|
|
162
|
+
|
|
163
|
+
# MCP 工具集成
|
|
164
|
+
"MCPToolStatus",
|
|
165
|
+
"MCPServerConfig",
|
|
166
|
+
"MCPServerCreateRequest",
|
|
167
|
+
"MCPServerUpdateRequest",
|
|
168
|
+
"MCPServerTestRequest",
|
|
169
|
+
"MCPServerTestResult",
|
|
170
|
+
"load_mcp_tools",
|
|
171
|
+
"test_mcp_connection",
|
|
172
|
+
"sanitize_name",
|
|
173
|
+
|
|
174
|
+
# PG Checkpoint 服务
|
|
175
|
+
"PgCheckpointService",
|
|
150
176
|
]
|
{sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/deep_agent.py
RENAMED
|
@@ -168,6 +168,7 @@ class DeepAgent:
|
|
|
168
168
|
"""
|
|
169
169
|
current_tool_calls = []
|
|
170
170
|
ai_chunk_buffer = ""
|
|
171
|
+
ai_text_content = ""
|
|
171
172
|
seen_tool_call_ids = set()
|
|
172
173
|
stream_step = 0
|
|
173
174
|
# 兜底:累积流式 chunk 中的 usage_metadata(middleware 在流式场景可能拿不到)
|
|
@@ -211,6 +212,12 @@ class DeepAgent:
|
|
|
211
212
|
if usage_meta:
|
|
212
213
|
total_input_tokens += usage_meta.get("input_tokens", 0)
|
|
213
214
|
total_output_tokens += usage_meta.get("output_tokens", 0)
|
|
215
|
+
if usage_meta.get("input_tokens", 0) > 0:
|
|
216
|
+
SYLogger.debug(
|
|
217
|
+
f"[DeepAgent] usage_metadata | input={usage_meta.get('input_tokens', 0)} "
|
|
218
|
+
f"output={usage_meta.get('output_tokens', 0)} "
|
|
219
|
+
f"total={usage_meta.get('total_tokens', 0)} "
|
|
220
|
+
f"cumulative_input={total_input_tokens} step={stream_step}")
|
|
214
221
|
|
|
215
222
|
if msg_type == "AIMessageChunk":
|
|
216
223
|
tool_calls_log = getattr(msg, "tool_calls", [])
|
|
@@ -397,6 +404,7 @@ class DeepAgent:
|
|
|
397
404
|
|
|
398
405
|
if content:
|
|
399
406
|
ai_chunk_buffer += content
|
|
407
|
+
ai_text_content += content
|
|
400
408
|
event = ChatEventBuilder.ai_chunk(
|
|
401
409
|
content, id=getattr(msg, "id", None),
|
|
402
410
|
agent=DEFAULT_AGENT_NAME)
|
|
@@ -453,6 +461,13 @@ class DeepAgent:
|
|
|
453
461
|
print(
|
|
454
462
|
f"[DeepAgent] AI chunk done | {repr(ai_chunk_buffer[:100])}...")
|
|
455
463
|
|
|
464
|
+
# 空响应检测:模型被调用但没有产出任何文本
|
|
465
|
+
if not ai_text_content and not ai_chunk_buffer:
|
|
466
|
+
SYLogger.warning(
|
|
467
|
+
f"[DeepAgent] 空响应警告:模型未返回任何文本内容。"
|
|
468
|
+
f"stream_step={stream_step}, tool_calls={len(current_tool_calls)}, "
|
|
469
|
+
f"input_tokens={total_input_tokens}, output_tokens={total_output_tokens}")
|
|
470
|
+
|
|
456
471
|
# 兜底:如果 middleware 没有成功记录(流式场景),在这里补充记录
|
|
457
472
|
if total_input_tokens > 0 or total_output_tokens > 0:
|
|
458
473
|
try:
|
|
@@ -598,8 +613,12 @@ async def create_deep_agent(
|
|
|
598
613
|
|
|
599
614
|
# 创建 checkpointer
|
|
600
615
|
if checkpointer is None:
|
|
601
|
-
from
|
|
602
|
-
|
|
616
|
+
from sycommon.database.pg_checkpoint_service import PgCheckpointService
|
|
617
|
+
if PgCheckpointService.is_initialized():
|
|
618
|
+
checkpointer = await PgCheckpointService.get_checkpointer()
|
|
619
|
+
else:
|
|
620
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
621
|
+
checkpointer = MemorySaver()
|
|
603
622
|
|
|
604
623
|
tid = thread_id or user_id
|
|
605
624
|
agent_config = {"configurable": {"thread_id": tid}}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""MCP 工具集成模块
|
|
2
|
+
|
|
3
|
+
提供 MCP 服务器连接、工具发现和加载功能。
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from sycommon.agent.mcp.models import (
|
|
7
|
+
MCPToolStatus,
|
|
8
|
+
MCPServerConfig,
|
|
9
|
+
MCPServerCreateRequest,
|
|
10
|
+
MCPServerUpdateRequest,
|
|
11
|
+
MCPServerTestRequest,
|
|
12
|
+
MCPServerTestResult,
|
|
13
|
+
)
|
|
14
|
+
from sycommon.agent.mcp.tool_loader import (
|
|
15
|
+
load_mcp_tools,
|
|
16
|
+
test_mcp_connection,
|
|
17
|
+
sanitize_name,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"MCPToolStatus",
|
|
22
|
+
"MCPServerConfig",
|
|
23
|
+
"MCPServerCreateRequest",
|
|
24
|
+
"MCPServerUpdateRequest",
|
|
25
|
+
"MCPServerTestRequest",
|
|
26
|
+
"MCPServerTestResult",
|
|
27
|
+
"load_mcp_tools",
|
|
28
|
+
"test_mcp_connection",
|
|
29
|
+
"sanitize_name",
|
|
30
|
+
]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""MCP 服务器配置数据模型"""
|
|
2
|
+
|
|
3
|
+
from typing import Optional, List
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class MCPToolStatus(BaseModel):
|
|
8
|
+
"""MCP 工具可用状态"""
|
|
9
|
+
tool_name: str
|
|
10
|
+
description: Optional[str] = None
|
|
11
|
+
available: bool = True
|
|
12
|
+
last_check_at: Optional[str] = None
|
|
13
|
+
last_error: Optional[str] = None
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MCPServerConfig(BaseModel):
|
|
17
|
+
id: str
|
|
18
|
+
user_id: Optional[str] = None
|
|
19
|
+
name: str
|
|
20
|
+
server_url: str
|
|
21
|
+
description: Optional[str] = None
|
|
22
|
+
headers: Optional[dict] = None
|
|
23
|
+
enabled: bool = True
|
|
24
|
+
sanitized_name: str = ""
|
|
25
|
+
created_at: str
|
|
26
|
+
updated_at: str
|
|
27
|
+
tools: Optional[List[MCPToolStatus]] = None
|
|
28
|
+
server_status: Optional[str] = None
|
|
29
|
+
server_error: Optional[str] = None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class MCPServerCreateRequest(BaseModel):
|
|
33
|
+
name: str
|
|
34
|
+
server_url: str
|
|
35
|
+
description: Optional[str] = None
|
|
36
|
+
headers: Optional[dict] = None
|
|
37
|
+
enabled: bool = True
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class MCPServerUpdateRequest(BaseModel):
|
|
41
|
+
name: Optional[str] = None
|
|
42
|
+
server_url: Optional[str] = None
|
|
43
|
+
description: Optional[str] = None
|
|
44
|
+
headers: Optional[dict] = None
|
|
45
|
+
enabled: Optional[bool] = None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class MCPServerTestRequest(BaseModel):
|
|
49
|
+
server_url: str
|
|
50
|
+
headers: Optional[dict] = None
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class MCPServerTestResult(BaseModel):
|
|
54
|
+
success: bool
|
|
55
|
+
tools: Optional[list] = None
|
|
56
|
+
error: Optional[str] = None
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""MCP 工具加载器
|
|
2
|
+
|
|
3
|
+
使用 langchain-mcp-adapters 官方库连接远程 MCP 服务器,
|
|
4
|
+
发现工具并作为 LangChain BaseTool 注入 Agent。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import re
|
|
8
|
+
import hashlib
|
|
9
|
+
from typing import List, Optional, Callable, Awaitable
|
|
10
|
+
|
|
11
|
+
from langchain_core.tools import BaseTool
|
|
12
|
+
|
|
13
|
+
from sycommon.logging.kafka_log import SYLogger
|
|
14
|
+
from sycommon.agent.mcp.models import MCPServerConfig
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def sanitize_name(name: str) -> str:
|
|
18
|
+
"""将名称转为合法的标识符,中文等非ASCII字符做 transliterate"""
|
|
19
|
+
sanitized = re.sub(r'[^a-zA-Z0-9_]', '_', name).strip('_')
|
|
20
|
+
if not sanitized:
|
|
21
|
+
h = hashlib.md5(name.encode()).hexdigest()[:8]
|
|
22
|
+
sanitized = f"mcp_{h}"
|
|
23
|
+
return sanitized
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def wrap_tool_with_error_handler(
|
|
27
|
+
tool: BaseTool,
|
|
28
|
+
server_config_id: str,
|
|
29
|
+
server_name: str,
|
|
30
|
+
original_tool_name: str,
|
|
31
|
+
on_tool_success: Optional[Callable[[str, str], Awaitable[None]]] = None,
|
|
32
|
+
on_tool_error: Optional[Callable[[str, str, str], Awaitable[None]]] = None,
|
|
33
|
+
) -> BaseTool:
|
|
34
|
+
"""包装 MCP 工具的 coroutine,捕获连接/超时等异常,返回友好的错误信息而非抛出异常。
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
on_tool_success: 异步回调 (server_config_id, tool_name) -> None
|
|
38
|
+
on_tool_error: 异步回调 (server_config_id, tool_name, error_msg) -> None
|
|
39
|
+
"""
|
|
40
|
+
original_coroutine = tool.coroutine
|
|
41
|
+
tool_name = tool.name
|
|
42
|
+
|
|
43
|
+
async def _safe_coroutine(*args, **kwargs):
|
|
44
|
+
try:
|
|
45
|
+
result = await original_coroutine(*args, **kwargs)
|
|
46
|
+
if on_tool_success:
|
|
47
|
+
try:
|
|
48
|
+
await on_tool_success(server_config_id, original_tool_name)
|
|
49
|
+
except Exception:
|
|
50
|
+
pass
|
|
51
|
+
return result
|
|
52
|
+
except Exception as e:
|
|
53
|
+
err_type = type(e).__name__
|
|
54
|
+
err_msg = str(e)[:500]
|
|
55
|
+
SYLogger.warning(f"[MCP] 工具 '{tool_name}' 调用失败 ({err_type}): {err_msg}")
|
|
56
|
+
|
|
57
|
+
if on_tool_error:
|
|
58
|
+
try:
|
|
59
|
+
await on_tool_error(server_config_id, original_tool_name, f"{err_type}: {err_msg}")
|
|
60
|
+
except Exception:
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
friendly_msg = (
|
|
64
|
+
f"MCP 工具调用失败:工具 '{tool_name}' (服务器: {server_name}) 当前不可用。\n"
|
|
65
|
+
f"错误类型: {err_type}\n"
|
|
66
|
+
f"可能原因: MCP 服务器未启动、网络不可达或连接超时。\n"
|
|
67
|
+
f"请尝试不使用该工具继续完成任务,或联系管理员检查 MCP 服务 '{server_name}'。"
|
|
68
|
+
)
|
|
69
|
+
return [friendly_msg]
|
|
70
|
+
|
|
71
|
+
tool.coroutine = _safe_coroutine
|
|
72
|
+
return tool
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
async def load_mcp_tools(
|
|
76
|
+
configs: List[MCPServerConfig],
|
|
77
|
+
on_tool_success: Optional[Callable[[str, str], Awaitable[None]]] = None,
|
|
78
|
+
on_tool_error: Optional[Callable[[str, str, str], Awaitable[None]]] = None,
|
|
79
|
+
on_batch_available: Optional[Callable[[str, list], Awaitable[None]]] = None,
|
|
80
|
+
on_server_failure: Optional[Callable[[str, str], Awaitable[None]]] = None,
|
|
81
|
+
) -> List[BaseTool]:
|
|
82
|
+
"""加载 MCP 工具列表
|
|
83
|
+
|
|
84
|
+
接受 MCPServerConfig 列表,逐个服务器连接并加载工具。
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
configs: MCP 服务器配置列表(仅 enabled 的会被处理)
|
|
88
|
+
on_tool_success: 单个工具调用成功回调
|
|
89
|
+
on_tool_error: 单个工具调用失败回调
|
|
90
|
+
on_batch_available: 服务器连接成功后批量标记工具可用回调 (config_id, tool_names)
|
|
91
|
+
on_server_failure: 服务器连接失败回调 (config_id, error_msg)
|
|
92
|
+
"""
|
|
93
|
+
enabled_configs = [c for c in configs if c.enabled]
|
|
94
|
+
if not enabled_configs:
|
|
95
|
+
return []
|
|
96
|
+
|
|
97
|
+
all_tools = []
|
|
98
|
+
for config in enabled_configs:
|
|
99
|
+
try:
|
|
100
|
+
from langchain_mcp_adapters.client import MultiServerMCPClient
|
|
101
|
+
|
|
102
|
+
key = sanitize_name(config.name)
|
|
103
|
+
client_config = {
|
|
104
|
+
key: {
|
|
105
|
+
"url": config.server_url,
|
|
106
|
+
"transport": "streamable_http",
|
|
107
|
+
**({"headers": config.headers} if config.headers else {}),
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
client = MultiServerMCPClient(client_config)
|
|
112
|
+
tools = await client.get_tools()
|
|
113
|
+
|
|
114
|
+
original_names = []
|
|
115
|
+
for tool in tools:
|
|
116
|
+
original_name = tool.name
|
|
117
|
+
original_names.append(original_name)
|
|
118
|
+
tool.name = f"mcp__{key}__{original_name}"
|
|
119
|
+
if tool.description and not tool.description.startswith("[MCP"):
|
|
120
|
+
tool.description = f"[MCP:{config.name}] {tool.description}"
|
|
121
|
+
wrap_tool_with_error_handler(
|
|
122
|
+
tool, config.id, config.name, original_name,
|
|
123
|
+
on_tool_success=on_tool_success,
|
|
124
|
+
on_tool_error=on_tool_error,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
all_tools.extend(tools)
|
|
128
|
+
|
|
129
|
+
if on_batch_available:
|
|
130
|
+
try:
|
|
131
|
+
await on_batch_available(config.id, original_names)
|
|
132
|
+
except Exception as e:
|
|
133
|
+
SYLogger.warning(f"[MCP] 写入工具状态失败: {e}")
|
|
134
|
+
|
|
135
|
+
SYLogger.info(f"[MCP] 服务器 '{config.name}' 加载了 {len(tools)} 个工具")
|
|
136
|
+
|
|
137
|
+
except Exception as e:
|
|
138
|
+
SYLogger.warning(f"[MCP] 服务器 '{config.name}' ({config.server_url}) 连接失败,跳过: {e}")
|
|
139
|
+
if on_server_failure:
|
|
140
|
+
try:
|
|
141
|
+
await on_server_failure(config.id, str(e)[:300])
|
|
142
|
+
except Exception:
|
|
143
|
+
pass
|
|
144
|
+
|
|
145
|
+
if all_tools:
|
|
146
|
+
SYLogger.info(f"[MCP] 共加载 {len(all_tools)} 个 MCP 工具")
|
|
147
|
+
return all_tools
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
async def test_mcp_connection(server_url: str, headers: dict = None) -> dict:
|
|
151
|
+
"""测试 MCP 服务器连接,返回发现的工具列表"""
|
|
152
|
+
try:
|
|
153
|
+
from langchain_mcp_adapters.client import MultiServerMCPClient
|
|
154
|
+
|
|
155
|
+
client_config = {
|
|
156
|
+
"test": {
|
|
157
|
+
"url": server_url,
|
|
158
|
+
"transport": "streamable_http",
|
|
159
|
+
**({"headers": headers} if headers else {}),
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
client = MultiServerMCPClient(client_config)
|
|
164
|
+
tools = await client.get_tools()
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
"success": True,
|
|
168
|
+
"tools": [{"name": t.name, "description": t.description or ""} for t in tools],
|
|
169
|
+
}
|
|
170
|
+
except Exception as e:
|
|
171
|
+
return {
|
|
172
|
+
"success": False,
|
|
173
|
+
"error": str(e),
|
|
174
|
+
}
|
{sycommon_python_lib-0.2.3a11 → sycommon_python_lib-0.2.4a0}/src/sycommon/agent/multi_agent_team.py
RENAMED
|
@@ -574,8 +574,12 @@ async def create_multi_agent_team(
|
|
|
574
574
|
|
|
575
575
|
# 创建 checkpointer
|
|
576
576
|
if checkpointer is None:
|
|
577
|
-
from
|
|
578
|
-
|
|
577
|
+
from sycommon.database.pg_checkpoint_service import PgCheckpointService
|
|
578
|
+
if PgCheckpointService.is_initialized():
|
|
579
|
+
checkpointer = await PgCheckpointService.get_checkpointer()
|
|
580
|
+
else:
|
|
581
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
582
|
+
checkpointer = MemorySaver()
|
|
579
583
|
|
|
580
584
|
tid = thread_id or user_id
|
|
581
585
|
agent_config = {"configurable": {"thread_id": tid}}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"""上下文压缩 middleware 构建工具。
|
|
2
2
|
|
|
3
3
|
根据 nacos 中配置的模型 maxTokens,用绝对 token 数设置压缩阈值。
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
优先使用模型 API 返回的 usage_metadata.total_tokens(真实 token 数),
|
|
5
|
+
无 metadata 时回退到 chars_per_token=2.0 的估算值。
|
|
6
|
+
同时增加基于消息数的安全阈值,防止估算偏低导致压缩不触发。
|
|
6
7
|
"""
|
|
7
8
|
|
|
8
9
|
from __future__ import annotations
|
|
@@ -24,17 +25,28 @@ if TYPE_CHECKING:
|
|
|
24
25
|
|
|
25
26
|
logger = logging.getLogger(__name__)
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
def _extract_last_usage_total_tokens(messages) -> int:
|
|
30
|
+
"""从消息历史中提取最后一条 AIMessage 的 usage_metadata.total_tokens。
|
|
31
|
+
|
|
32
|
+
返回 0 表示无数据(需回退到估算)。
|
|
33
|
+
"""
|
|
34
|
+
from langchain_core.messages import AIMessage
|
|
35
|
+
for msg in reversed(messages):
|
|
36
|
+
if isinstance(msg, AIMessage):
|
|
37
|
+
meta = getattr(msg, 'usage_metadata', None)
|
|
38
|
+
if meta and isinstance(meta, dict):
|
|
39
|
+
total = meta.get('total_tokens', 0)
|
|
40
|
+
if isinstance(total, int) and total > 0:
|
|
41
|
+
return total
|
|
42
|
+
return 0
|
|
30
43
|
|
|
31
44
|
|
|
32
45
|
def _patched_compute_summarization_defaults(model):
|
|
33
46
|
"""覆盖 deepagents 默认值,返回中文场景修正后的绝对 token 阈值。
|
|
34
47
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
直接返回修正后的绝对 token 数。
|
|
48
|
+
同时增加基于消息数的安全阈值:即使 token 估算偏低,
|
|
49
|
+
消息数超过 200 条时也会触发压缩(覆盖工具 schema 等未计入的开销)。
|
|
38
50
|
"""
|
|
39
51
|
try:
|
|
40
52
|
from sycommon.config.Config import Config
|
|
@@ -48,10 +60,12 @@ def _patched_compute_summarization_defaults(model):
|
|
|
48
60
|
except Exception:
|
|
49
61
|
max_tokens = 72000
|
|
50
62
|
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
# 60% 触发(120K/200K):实测模型在 input≈137K 时开始退化,
|
|
64
|
+
# 在 120K 触发压缩留 ~17K 安全余量给工具 schema 等未计入开销
|
|
65
|
+
trigger = int(max_tokens * 0.60)
|
|
66
|
+
keep = int(max_tokens * 0.10)
|
|
53
67
|
return {
|
|
54
|
-
"trigger": ("tokens", trigger),
|
|
68
|
+
"trigger": [("tokens", trigger), ("messages", 200)],
|
|
55
69
|
"keep": ("tokens", keep),
|
|
56
70
|
"truncate_args_settings": {
|
|
57
71
|
"trigger": ("tokens", trigger),
|
|
@@ -63,10 +77,14 @@ def _patched_compute_summarization_defaults(model):
|
|
|
63
77
|
# monkey-patch:替换 deepagents 的默认计算函数
|
|
64
78
|
_summ_mod.compute_summarization_defaults = _patched_compute_summarization_defaults
|
|
65
79
|
|
|
66
|
-
# monkey-patch:在内置 middleware 的 awrap_model_call
|
|
80
|
+
# monkey-patch:在内置 middleware 的 awrap_model_call 中注入真实 token + 日志
|
|
67
81
|
_OrigDeepAgentsSumm = _summ_mod._DeepAgentsSummarizationMiddleware
|
|
68
82
|
_orig_awrap_model_call = _OrigDeepAgentsSumm.awrap_model_call
|
|
69
83
|
|
|
84
|
+
# 基础估算函数,用于日志对比
|
|
85
|
+
_approx_counter = functools.partial(
|
|
86
|
+
count_tokens_approximately, chars_per_token=2.0)
|
|
87
|
+
|
|
70
88
|
|
|
71
89
|
async def _patched_awrap_model_call(self, request, handler):
|
|
72
90
|
effective_messages = self._get_effective_messages(request)
|
|
@@ -75,15 +93,43 @@ async def _patched_awrap_model_call(self, request, handler):
|
|
|
75
93
|
)
|
|
76
94
|
counted_messages = [request.system_message, *
|
|
77
95
|
truncated_messages] if request.system_message is not None else truncated_messages
|
|
96
|
+
|
|
97
|
+
# 从截断前的 effective_messages 提取真实 token(截断会丢失 usage_metadata)
|
|
98
|
+
real_tokens = _extract_last_usage_total_tokens(effective_messages)
|
|
99
|
+
|
|
100
|
+
# 估算值(用于日志对比)
|
|
78
101
|
try:
|
|
79
|
-
|
|
80
|
-
counted_messages, tools=request.tools)
|
|
102
|
+
estimated = _approx_counter(counted_messages, tools=request.tools)
|
|
81
103
|
except TypeError:
|
|
82
|
-
|
|
83
|
-
|
|
104
|
+
estimated = _approx_counter(counted_messages)
|
|
105
|
+
|
|
106
|
+
# 如果有真实 token,临时替换 token_counter 使 _orig 内部判断也用真实值
|
|
107
|
+
# 这样 _should_summarize 和 _determine_cutoff_index 都能拿到正确的 token 数
|
|
108
|
+
if real_tokens > 0:
|
|
109
|
+
original_counter = self.token_counter
|
|
110
|
+
|
|
111
|
+
def _real_counter(msgs, **kwargs):
|
|
112
|
+
# 优先从当前消息中提取真实值(压缩后的消息可能有新的 metadata)
|
|
113
|
+
r = _extract_last_usage_total_tokens(msgs)
|
|
114
|
+
return r if r > 0 else real_tokens
|
|
115
|
+
|
|
116
|
+
self._lc_helper.token_counter = _real_counter
|
|
117
|
+
try:
|
|
118
|
+
result = await _orig_awrap_model_call(self, request, handler)
|
|
119
|
+
finally:
|
|
120
|
+
self._lc_helper.token_counter = original_counter
|
|
121
|
+
else:
|
|
122
|
+
result = await _orig_awrap_model_call(self, request, handler)
|
|
123
|
+
|
|
124
|
+
# 日志
|
|
125
|
+
source = 'real' if real_tokens > 0 else 'estimated'
|
|
126
|
+
should = self._should_summarize(truncated_messages, real_tokens if real_tokens > 0 else estimated)
|
|
84
127
|
print(
|
|
85
|
-
f"[TokenCount]
|
|
86
|
-
|
|
128
|
+
f"[TokenCount] real={real_tokens} estimated={estimated} "
|
|
129
|
+
f"source={source} msgs={len(counted_messages)} "
|
|
130
|
+
f"should_summarize={should} "
|
|
131
|
+
f"trigger={getattr(self._lc_helper, 'trigger', '?')}")
|
|
132
|
+
return result
|
|
87
133
|
|
|
88
134
|
|
|
89
135
|
_OrigDeepAgentsSumm.awrap_model_call = _patched_awrap_model_call
|
|
@@ -94,25 +140,21 @@ def build_summarization_middleware(
|
|
|
94
140
|
model_name: str,
|
|
95
141
|
backend: "BACKEND_TYPES",
|
|
96
142
|
*,
|
|
97
|
-
trigger_fraction: float = 0.
|
|
98
|
-
keep_fraction: float = 0.
|
|
143
|
+
trigger_fraction: float = 0.60,
|
|
144
|
+
keep_fraction: float = 0.10,
|
|
99
145
|
default_max_tokens: int = 200000,
|
|
100
146
|
) -> SummarizationToolMiddleware:
|
|
101
147
|
"""根据模型上下文窗口大小构建 compact_conversation 工具 middleware。
|
|
102
148
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
计算压缩阈值。
|
|
106
|
-
|
|
107
|
-
此处创建的 SummarizationToolMiddleware 仅提供 compact_conversation 手动压缩工具,
|
|
108
|
-
使用 nacos 配置的 maxTokens 作为其内部 SummarizationMiddleware 的阈值参数。
|
|
149
|
+
优先使用模型返回的 usage_metadata 真实 token 数进行压缩判断,
|
|
150
|
+
无 usage_metadata 时回退到 chars_per_token=2.0 估算。
|
|
109
151
|
|
|
110
152
|
Args:
|
|
111
153
|
model: LLM 实例。
|
|
112
154
|
model_name: 模型名称(用于从 nacos 读取配置)。
|
|
113
155
|
backend: 后端实例。
|
|
114
|
-
trigger_fraction: 触发压缩占有效输入的比例,默认
|
|
115
|
-
keep_fraction: 压缩后保留占有效输入的比例,默认
|
|
156
|
+
trigger_fraction: 触发压缩占有效输入的比例,默认 60%。
|
|
157
|
+
keep_fraction: 压缩后保留占有效输入的比例,默认 10%。
|
|
116
158
|
default_max_tokens: 无法从配置读取时的默认上下文窗口大小。
|
|
117
159
|
|
|
118
160
|
Returns:
|
|
@@ -134,7 +176,8 @@ def build_summarization_middleware(
|
|
|
134
176
|
backend=backend,
|
|
135
177
|
trigger=("tokens", trigger_tokens),
|
|
136
178
|
keep=("tokens", keep_tokens),
|
|
137
|
-
token_counter=
|
|
179
|
+
token_counter=functools.partial(
|
|
180
|
+
count_tokens_approximately, chars_per_token=2.0),
|
|
138
181
|
trim_tokens_to_summarize=None,
|
|
139
182
|
truncate_args_settings={
|
|
140
183
|
"trigger": ("tokens", trigger_tokens),
|