quantnodes 3.0.0__py3-none-any.whl
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.
- QuantNodes/__init__.py +15 -0
- QuantNodes/__main__.py +14 -0
- QuantNodes/agent/__init__.py +158 -0
- QuantNodes/agent/agents/__init__.py +13 -0
- QuantNodes/agent/agents/definition.py +180 -0
- QuantNodes/agent/agents/manager.py +73 -0
- QuantNodes/agent/config/__init__.py +34 -0
- QuantNodes/agent/config/executor.py +958 -0
- QuantNodes/agent/config/loader.py +427 -0
- QuantNodes/agent/config/templates/bollinger_bands.yaml +84 -0
- QuantNodes/agent/config/templates/dual_ma.yaml +72 -0
- QuantNodes/agent/config/templates/empty.yaml +56 -0
- QuantNodes/agent/config/templates/mean_reversion.yaml +47 -0
- QuantNodes/agent/config/templates/mean_reversion_zscore.yaml +90 -0
- QuantNodes/agent/config/templates/momentum.yaml +81 -0
- QuantNodes/agent/config/templates/momentum_breakout.yaml +84 -0
- QuantNodes/agent/config/templates/rsi_strategy.yaml +72 -0
- QuantNodes/agent/config/templates/volume_price.yaml +86 -0
- QuantNodes/agent/config/types.py +156 -0
- QuantNodes/agent/config_mapper.py +293 -0
- QuantNodes/agent/core/__init__.py +19 -0
- QuantNodes/agent/core/dream.py +47 -0
- QuantNodes/agent/core/quant_dream.py +274 -0
- QuantNodes/agent/cron_jobs.py +314 -0
- QuantNodes/agent/nanobot_bridge.py +242 -0
- QuantNodes/agent/permission/__init__.py +30 -0
- QuantNodes/agent/permission/defaults.py +36 -0
- QuantNodes/agent/permission/evaluate.py +41 -0
- QuantNodes/agent/permission/models.py +59 -0
- QuantNodes/agent/permission/service.py +133 -0
- QuantNodes/agent/providers/__init__.py +11 -0
- QuantNodes/agent/providers/base.py +102 -0
- QuantNodes/agent/providers/quantnodes.py +610 -0
- QuantNodes/agent/providers/rate_limiter.py +326 -0
- QuantNodes/agent/providers/registry.py +163 -0
- QuantNodes/agent/skills/__init__.py +20 -0
- QuantNodes/agent/skills/base.py +118 -0
- QuantNodes/agent/skills/bridge.py +73 -0
- QuantNodes/agent/skills/factor/__init__.py +14 -0
- QuantNodes/agent/skills/factor/correlation.py +99 -0
- QuantNodes/agent/skills/factor/group_backtest.py +114 -0
- QuantNodes/agent/skills/factor/ic_analysis.py +106 -0
- QuantNodes/agent/skills/loader.py +107 -0
- QuantNodes/agent/skills/registry.py +105 -0
- QuantNodes/agent/skills/strategy/__init__.py +16 -0
- QuantNodes/agent/skills/strategy/bollinger.py +86 -0
- QuantNodes/agent/skills/strategy/dual_ma.py +82 -0
- QuantNodes/agent/skills/strategy/momentum.py +74 -0
- QuantNodes/agent/skills/strategy/rsi_reversal.py +99 -0
- QuantNodes/agent/skills_quant/__init__.py +14 -0
- QuantNodes/agent/skills_quant/backtest-analyze/SKILL.md +42 -0
- QuantNodes/agent/skills_quant/config-driven/SKILL.md +72 -0
- QuantNodes/agent/skills_quant/factor-research/SKILL.md +40 -0
- QuantNodes/agent/skills_quant/quant-dream/SKILL.md +55 -0
- QuantNodes/agent/skills_quant/risk-management/SKILL.md +45 -0
- QuantNodes/agent/skills_quant/strategy-design/SKILL.md +43 -0
- QuantNodes/agent/templates/__init__.py +4 -0
- QuantNodes/agent/tools/__init__.py +173 -0
- QuantNodes/agent/tools/_workspace.py +51 -0
- QuantNodes/agent/tools/alpha_backtest.py +328 -0
- QuantNodes/agent/tools/alpha_evaluate.py +493 -0
- QuantNodes/agent/tools/backtest.py +226 -0
- QuantNodes/agent/tools/base.py +133 -0
- QuantNodes/agent/tools/code_search.py +207 -0
- QuantNodes/agent/tools/config_backtest.py +401 -0
- QuantNodes/agent/tools/context.py +97 -0
- QuantNodes/agent/tools/dream_skill.py +77 -0
- QuantNodes/agent/tools/echo.py +38 -0
- QuantNodes/agent/tools/factor.py +231 -0
- QuantNodes/agent/tools/file_ops.py +201 -0
- QuantNodes/agent/tools/git_ops.py +190 -0
- QuantNodes/agent/tools/operator_lookup.py +218 -0
- QuantNodes/agent/tools/output_truncation.py +77 -0
- QuantNodes/agent/tools/path_check.py +43 -0
- QuantNodes/agent/tools/pipeline.py +62 -0
- QuantNodes/agent/tools/registry.py +150 -0
- QuantNodes/agent/tools/sandbox.py +62 -0
- QuantNodes/agent/tools/shell_safety.py +63 -0
- QuantNodes/agent/tools/strategy.py +106 -0
- QuantNodes/agent/tools/task.py +171 -0
- QuantNodes/agent/tools/web_fetch.py +142 -0
- QuantNodes/agent/tools/web_search.py +114 -0
- QuantNodes/agent/tools/wiki.py +370 -0
- QuantNodes/agent/utils/__init__.py +11 -0
- QuantNodes/agent/utils/helpers.py +43 -0
- QuantNodes/agent/utils/prompt_templates.py +30 -0
- QuantNodes/agent/workflows/__init__.py +20 -0
- QuantNodes/agent/workflows/implementations/__init__.py +8 -0
- QuantNodes/agent/workflows/implementations/alpha_gpt.py +508 -0
- QuantNodes/agent/workflows/implementations/mcts.py +442 -0
- QuantNodes/agent/workflows/parsers.py +44 -0
- QuantNodes/agent/workflows/registry.py +119 -0
- QuantNodes/agent/workflows/step_agent.py +219 -0
- QuantNodes/agent/workflows/tool.py +198 -0
- QuantNodes/ai/__init__.py +93 -0
- QuantNodes/ai/llm/__init__.py +75 -0
- QuantNodes/ai/llm/base.py +233 -0
- QuantNodes/ai/llm/decorators.py +281 -0
- QuantNodes/ai/llm/gateway.py +571 -0
- QuantNodes/ai/llm/null.py +76 -0
- QuantNodes/ai/llm/openai.py +435 -0
- QuantNodes/ai/optimizer.py +405 -0
- QuantNodes/ai/prompts/__init__.py +229 -0
- QuantNodes/ai/sandbox.py +371 -0
- QuantNodes/ai/sandbox_pandas_bridge.py +150 -0
- QuantNodes/ai/strategy_gen.py +396 -0
- QuantNodes/backtest/__init__.py +64 -0
- QuantNodes/backtest/backtest_node.py +188 -0
- QuantNodes/backtest/broker_node.py +378 -0
- QuantNodes/backtest/config_runner.py +397 -0
- QuantNodes/backtest/config_strategy.py +64 -0
- QuantNodes/backtest/risk_node.py +360 -0
- QuantNodes/backtest/strategy_node.py +268 -0
- QuantNodes/cache_node/__init__.py +19 -0
- QuantNodes/cache_node/base.py +244 -0
- QuantNodes/cache_node/cache_store.py +99 -0
- QuantNodes/cache_node/metadata.py +100 -0
- QuantNodes/cli/__init__.py +109 -0
- QuantNodes/cli/_helpers.py +511 -0
- QuantNodes/cli/command.py +110 -0
- QuantNodes/cli/commands/__init__.py +69 -0
- QuantNodes/cli/commands/agent.py +158 -0
- QuantNodes/cli/commands/alpha.py +951 -0
- QuantNodes/cli/commands/chat.py +38 -0
- QuantNodes/cli/commands/evolve.py +120 -0
- QuantNodes/cli/commands/factor.py +569 -0
- QuantNodes/cli/commands/init.py +190 -0
- QuantNodes/cli/commands/run.py +259 -0
- QuantNodes/cli/commands/serve.py +398 -0
- QuantNodes/cli/commands/version.py +120 -0
- QuantNodes/cli/enhanced.py +146 -0
- QuantNodes/conf_node/__init__.py +37 -0
- QuantNodes/conf_node/base.py +120 -0
- QuantNodes/conf_node/env_config.py +132 -0
- QuantNodes/conf_node/ini_config.py +70 -0
- QuantNodes/conf_node/json_config.py +69 -0
- QuantNodes/conf_node/yaml_config.py +78 -0
- QuantNodes/constants.py +17 -0
- QuantNodes/core/__init__.py +196 -0
- QuantNodes/core/_lookback_helpers.py +49 -0
- QuantNodes/core/ast_parser.py +198 -0
- QuantNodes/core/base.py +61 -0
- QuantNodes/core/cache_manager.py +344 -0
- QuantNodes/core/cache_utils.py +150 -0
- QuantNodes/core/cond_builder.py +53 -0
- QuantNodes/core/config.py +170 -0
- QuantNodes/core/constants.py +48 -0
- QuantNodes/core/control.py +412 -0
- QuantNodes/core/data_preprocessing.py +453 -0
- QuantNodes/core/data_source.py +46 -0
- QuantNodes/core/events.py +178 -0
- QuantNodes/core/evolution/__init__.py +22 -0
- QuantNodes/core/evolution/loop.py +583 -0
- QuantNodes/core/evolution/operators.py +289 -0
- QuantNodes/core/evolution/settings.py +44 -0
- QuantNodes/core/expression.py +841 -0
- QuantNodes/core/feedback/__init__.py +38 -0
- QuantNodes/core/feedback/channels.py +182 -0
- QuantNodes/core/feedback/collector.py +91 -0
- QuantNodes/core/feedback/dataclass.py +239 -0
- QuantNodes/core/feedback/llm_judge.py +138 -0
- QuantNodes/core/knowledge/__init__.py +69 -0
- QuantNodes/core/knowledge/knowledge_base.py +217 -0
- QuantNodes/core/knowledge/lineage_compress.py +196 -0
- QuantNodes/core/knowledge/lineage_expand.py +123 -0
- QuantNodes/core/knowledge/metrics/__init__.py +43 -0
- QuantNodes/core/knowledge/metrics/evaluator.py +176 -0
- QuantNodes/core/knowledge/metrics/metrics.py +220 -0
- QuantNodes/core/knowledge/rag_prompt.py +196 -0
- QuantNodes/core/knowledge/retriever.py +209 -0
- QuantNodes/core/lambda_node.py +81 -0
- QuantNodes/core/monitoring/__init__.py +22 -0
- QuantNodes/core/monitoring/collector.py +292 -0
- QuantNodes/core/monitoring/dashboard.py +365 -0
- QuantNodes/core/node.py +375 -0
- QuantNodes/core/pandas_utils.py +504 -0
- QuantNodes/core/parallel/__init__.py +15 -0
- QuantNodes/core/parallel/worker.py +140 -0
- QuantNodes/core/parallel/worker_process.py +265 -0
- QuantNodes/core/path_utils.py +73 -0
- QuantNodes/core/pipeline.py +328 -0
- QuantNodes/core/plugin.py +135 -0
- QuantNodes/core/quality_gate/__init__.py +32 -0
- QuantNodes/core/quality_gate/complexity.py +94 -0
- QuantNodes/core/quality_gate/consistency.py +26 -0
- QuantNodes/core/quality_gate/node.py +97 -0
- QuantNodes/core/quality_gate/redundancy.py +51 -0
- QuantNodes/core/quality_gate/settings.py +43 -0
- QuantNodes/core/quality_gate/zoo.py +98 -0
- QuantNodes/core/serializable.py +116 -0
- QuantNodes/core/serialization.py +673 -0
- QuantNodes/core/tools.py +333 -0
- QuantNodes/core/trajectory/__init__.py +25 -0
- QuantNodes/core/trajectory/entry.py +116 -0
- QuantNodes/core/trajectory/lineage.py +67 -0
- QuantNodes/core/trajectory/pool.py +211 -0
- QuantNodes/core/trajectory/selector.py +140 -0
- QuantNodes/core/visualization/__init__.py +33 -0
- QuantNodes/core/visualization/builder.py +233 -0
- QuantNodes/core/visualization/gate_breakdown.py +140 -0
- QuantNodes/core/visualization/lineage_dag.py +203 -0
- QuantNodes/core/visualization/metric_distribution.py +125 -0
- QuantNodes/core/visualization/report.py +68 -0
- QuantNodes/database_node/__init__.py +69 -0
- QuantNodes/database_node/base.py +135 -0
- QuantNodes/database_node/clickhouse_node.py +272 -0
- QuantNodes/database_node/csv_node.py +83 -0
- QuantNodes/database_node/duckdb_node.py +86 -0
- QuantNodes/database_node/factory.py +83 -0
- QuantNodes/database_node/mysql_node.py +100 -0
- QuantNodes/database_node/parquet_node.py +75 -0
- QuantNodes/database_node/sqlite_node.py +67 -0
- QuantNodes/factor_node/__init__.py +50 -0
- QuantNodes/factor_node/factor.py +563 -0
- QuantNodes/factor_node/factor_db.py +421 -0
- QuantNodes/factor_node/factor_functions/__init__.py +252 -0
- QuantNodes/factor_node/factor_functions/_helpers.py +358 -0
- QuantNodes/factor_node/factor_functions/_helpers_debug.py +317 -0
- QuantNodes/factor_node/factor_functions/composite_ops.py +136 -0
- QuantNodes/factor_node/factor_functions/math_ops.py +433 -0
- QuantNodes/factor_node/factor_functions/section_ops.py +290 -0
- QuantNodes/factor_node/factor_functions/talib_ops.py +1293 -0
- QuantNodes/factor_node/factor_functions/time_ops.py +535 -0
- QuantNodes/factor_node/factor_operation.py +1115 -0
- QuantNodes/factor_node/factor_table.py +1073 -0
- QuantNodes/factor_node/quant_nodes_object.py +60 -0
- QuantNodes/mcp_server/__init__.py +27 -0
- QuantNodes/mcp_server/__main__.py +4 -0
- QuantNodes/mcp_server/server.py +272 -0
- QuantNodes/methods/__init__.py +28 -0
- QuantNodes/methods/pipeline.py +100 -0
- QuantNodes/methods/sandbox.py +102 -0
- QuantNodes/monitor/__init__.py +27 -0
- QuantNodes/monitor/agent_tools/__init__.py +5 -0
- QuantNodes/monitor/agent_tools/monitor_tool.py +98 -0
- QuantNodes/monitor/agent_tools/schedule_tool.py +98 -0
- QuantNodes/monitor/agent_tools/version_tool.py +133 -0
- QuantNodes/monitor/monitor/__init__.py +6 -0
- QuantNodes/monitor/monitor/alerter.py +60 -0
- QuantNodes/monitor/monitor/collector.py +164 -0
- QuantNodes/monitor/monitor/dashboard.py +115 -0
- QuantNodes/monitor/monitor/drift.py +190 -0
- QuantNodes/monitor/scheduler/__init__.py +4 -0
- QuantNodes/monitor/scheduler/runner.py +133 -0
- QuantNodes/monitor/scheduler/scheduler.py +184 -0
- QuantNodes/monitor/storage/__init__.py +16 -0
- QuantNodes/monitor/storage/models.py +70 -0
- QuantNodes/monitor/storage/repository.py +407 -0
- QuantNodes/monitor/version/__init__.py +4 -0
- QuantNodes/monitor/version/diff.py +81 -0
- QuantNodes/monitor/version/version_manager.py +182 -0
- QuantNodes/operator_node/__init__.py +28 -0
- QuantNodes/operator_node/base.py +97 -0
- QuantNodes/operator_node/query_node.py +129 -0
- QuantNodes/operator_node/sql_builder.py +125 -0
- QuantNodes/operator_node/sql_utils.py +172 -0
- QuantNodes/operator_node/transform.py +130 -0
- QuantNodes/operators/__init__.py +90 -0
- QuantNodes/operators/_engine.py +108 -0
- QuantNodes/operators/composite.py +161 -0
- QuantNodes/operators/composite_dag.py +667 -0
- QuantNodes/operators/composite_dag_ops.py +343 -0
- QuantNodes/operators/composite_dag_pandas_ops.py +382 -0
- QuantNodes/operators/custom.py +408 -0
- QuantNodes/operators/facade.py +164 -0
- QuantNodes/operators/math.py +163 -0
- QuantNodes/operators/proxy.py +29 -0
- QuantNodes/operators/registry.py +144 -0
- QuantNodes/operators/section.py +99 -0
- QuantNodes/operators/talib.py +757 -0
- QuantNodes/operators/templates.py +95 -0
- QuantNodes/operators/time_series.py +136 -0
- QuantNodes/prompts/__init__.py +20 -0
- QuantNodes/prompts/backtest/__init__.py +12 -0
- QuantNodes/prompts/backtest/factor_based.py +86 -0
- QuantNodes/prompts/backtest/standard.py +73 -0
- QuantNodes/prompts/factor/__init__.py +14 -0
- QuantNodes/prompts/factor/correlation.py +77 -0
- QuantNodes/prompts/factor/group_backtest.py +86 -0
- QuantNodes/prompts/factor/ic_analysis.py +91 -0
- QuantNodes/prompts/strategy/__init__.py +18 -0
- QuantNodes/prompts/strategy/market_neutral.py +96 -0
- QuantNodes/prompts/strategy/mean_reversion.py +107 -0
- QuantNodes/prompts/strategy/momentum.py +160 -0
- QuantNodes/prompts/strategy/pairs_trading.py +107 -0
- QuantNodes/prompts/strategy/trend_following.py +96 -0
- QuantNodes/research/README.md +106 -0
- QuantNodes/research/__init__.py +154 -0
- QuantNodes/research/_legacy_3c/__init__.py +61 -0
- QuantNodes/research/_legacy_3c/auto_researcher.py +289 -0
- QuantNodes/research/_legacy_3c/factor_evaluator.py +560 -0
- QuantNodes/research/_legacy_3c/factor_miner.py +318 -0
- QuantNodes/research/_legacy_3c/mcts_search.py +324 -0
- QuantNodes/research/factor_test/__init__.py +25 -0
- QuantNodes/research/factor_test/config.py +184 -0
- QuantNodes/research/factor_test/config_builder.py +276 -0
- QuantNodes/research/factor_test/e2e/data_prep.py +163 -0
- QuantNodes/research/factor_test/e2e/run_evolution_e2e.py +309 -0
- QuantNodes/research/factor_test/evolution_adapter.py +231 -0
- QuantNodes/research/factor_test/feedback_wrapper.py +102 -0
- QuantNodes/research/factor_test/ifind_db/__init__.py +7 -0
- QuantNodes/research/factor_test/ifind_db/fetcher.py +224 -0
- QuantNodes/research/factor_test/ifind_db/ifind_database.py +689 -0
- QuantNodes/research/factor_test/nodes/__init__.py +1 -0
- QuantNodes/research/factor_test/nodes/_base.py +91 -0
- QuantNodes/research/factor_test/nodes/adjust_date_node.py +48 -0
- QuantNodes/research/factor_test/nodes/configs.py +240 -0
- QuantNodes/research/factor_test/nodes/factor_neutralize_node.py +87 -0
- QuantNodes/research/factor_test/nodes/factor_preprocess_node.py +222 -0
- QuantNodes/research/factor_test/nodes/factor_score_node.py +141 -0
- QuantNodes/research/factor_test/nodes/factor_test_report_node.py +153 -0
- QuantNodes/research/factor_test/nodes/group_analyzer_node.py +317 -0
- QuantNodes/research/factor_test/nodes/ic_analyzer_node.py +112 -0
- QuantNodes/research/factor_test/nodes/load_data_node.py +100 -0
- QuantNodes/research/factor_test/nodes/long_short_node.py +93 -0
- QuantNodes/research/factor_test/nodes/neutralizers.py +222 -0
- QuantNodes/research/factor_test/nodes/preprocess_strategies.py +277 -0
- QuantNodes/research/factor_test/nodes/risk_correlation_node.py +112 -0
- QuantNodes/research/factor_test/nodes/sample_pool_filter_node.py +110 -0
- QuantNodes/research/factor_test/nodes/tradability_filter_node.py +92 -0
- QuantNodes/research/factor_test/pipeline_runner.py +305 -0
- QuantNodes/research/factor_test/pipeline_spec.py +216 -0
- QuantNodes/research/factor_test/utils/__init__.py +26 -0
- QuantNodes/research/factor_test/utils/constants.py +86 -0
- QuantNodes/research/factor_test/utils/data_loader.py +141 -0
- QuantNodes/research/factor_test/utils/date_utils.py +232 -0
- QuantNodes/research/factor_test/utils/file_loaders.py +150 -0
- QuantNodes/research/factor_test/utils/labels.py +37 -0
- QuantNodes/research/factor_test/utils/metrics_extractor.py +55 -0
- QuantNodes/research/factor_test/utils/performance_metrics.py +175 -0
- QuantNodes/research/factor_test/utils/safe_load.py +106 -0
- QuantNodes/research/quant_alpha/CHANGELOG.md +80 -0
- QuantNodes/research/quant_alpha/README.md +142 -0
- QuantNodes/research/quant_alpha/__init__.py +45 -0
- QuantNodes/research/quant_alpha/adapters/__init__.py +99 -0
- QuantNodes/research/quant_alpha/adapters/calculator.py +503 -0
- QuantNodes/research/quant_alpha/adapters/expression.py +387 -0
- QuantNodes/research/quant_alpha/alpha101_design/__init__.py +50 -0
- QuantNodes/research/quant_alpha/alpha101_design/few_shot_examples.py +243 -0
- QuantNodes/research/quant_alpha/alpha101_design/philosophy.py +474 -0
- QuantNodes/research/quant_alpha/alpha158_design/__init__.py +63 -0
- QuantNodes/research/quant_alpha/alpha158_design/few_shot_examples.py +219 -0
- QuantNodes/research/quant_alpha/alpha158_design/philosophy.py +240 -0
- QuantNodes/research/quant_alpha/evaluation/__init__.py +47 -0
- QuantNodes/research/quant_alpha/evaluation/baselines/__init__.py +8 -0
- QuantNodes/research/quant_alpha/evaluation/baselines/g1_handcrafted.py +135 -0
- QuantNodes/research/quant_alpha/evaluation/baselines/g2_llm_only.py +269 -0
- QuantNodes/research/quant_alpha/evaluation/baselines/g3_alpha_gpt.py +152 -0
- QuantNodes/research/quant_alpha/evaluation/clickhouse_data_loader.py +227 -0
- QuantNodes/research/quant_alpha/evaluation/contracts.py +376 -0
- QuantNodes/research/quant_alpha/evaluation/evaluators/__init__.py +6 -0
- QuantNodes/research/quant_alpha/evaluation/evaluators/polars_evaluator.py +545 -0
- QuantNodes/research/quant_alpha/evaluation/mock_data_loader.py +226 -0
- QuantNodes/research/quant_alpha/evaluation/runner.py +243 -0
- QuantNodes/research/quant_alpha/llm/__init__.py +38 -0
- QuantNodes/research/quant_alpha/llm/parser.py +681 -0
- QuantNodes/research/quant_alpha/logic_driven_pipeline.py +411 -0
- QuantNodes/research/quant_alpha/logic_mining/__init__.py +74 -0
- QuantNodes/research/quant_alpha/logic_mining/compiler.py +457 -0
- QuantNodes/research/quant_alpha/logic_mining/generator.py +366 -0
- QuantNodes/research/quant_alpha/logic_mining/models.py +252 -0
- QuantNodes/research/quant_alpha/logic_mining/parser.py +287 -0
- QuantNodes/research/quant_alpha/logic_mining/pipelines.py +297 -0
- QuantNodes/research/quant_alpha/logic_mining/sources.py +149 -0
- QuantNodes/research/quant_alpha/mcts/__init__.py +66 -0
- QuantNodes/research/quant_alpha/mcts/cache.py +262 -0
- QuantNodes/research/quant_alpha/mcts/extension_ops.py +320 -0
- QuantNodes/research/quant_alpha/mcts/feedback.py +825 -0
- QuantNodes/research/quant_alpha/mcts/op_prior.py +180 -0
- QuantNodes/research/quant_alpha/mcts/search.py +540 -0
- QuantNodes/research/quant_alpha/mcts/tree.py +201 -0
- QuantNodes/research/quant_alpha/operator_vocab/__init__.py +50 -0
- QuantNodes/research/quant_alpha/operator_vocab/config.py +54 -0
- QuantNodes/research/quant_alpha/operator_vocab/metadata.py +263 -0
- QuantNodes/research/quant_alpha/operator_vocab/vocabulary.py +481 -0
- QuantNodes/research/quant_alpha/pipeline.py +1027 -0
- QuantNodes/research/quant_alpha/types/__init__.py +27 -0
- QuantNodes/research/quant_alpha/types/constants.py +28 -0
- QuantNodes/research/quant_alpha/types/state.py +205 -0
- QuantNodes/research/quant_alpha/workflow/__init__.py +32 -0
- QuantNodes/research/quant_alpha/workflow/alpha_gpt.py +911 -0
- QuantNodes/research/quant_alpha/workflow/alpha_logics.py +416 -0
- QuantNodes/research/quant_alpha/workflow/state.py +27 -0
- QuantNodes/research/report_reproducer.py +485 -0
- QuantNodes/research/wiki.py +1155 -0
- QuantNodes/symbolic/__init__.py +51 -0
- QuantNodes/symbolic/compiler.py +113 -0
- QuantNodes/symbolic/dialect.py +260 -0
- QuantNodes/symbolic/executor.py +147 -0
- QuantNodes/symbolic/expression.py +234 -0
- QuantNodes/symbolic/functions.py +433 -0
- QuantNodes/symbolic/optimizer.py +165 -0
- QuantNodes/ui_node/__init__.py +30 -0
- QuantNodes/ui_node/base.py +222 -0
- quantnodes-3.0.0.dist-info/METADATA +463 -0
- quantnodes-3.0.0.dist-info/RECORD +399 -0
- quantnodes-3.0.0.dist-info/WHEEL +5 -0
- quantnodes-3.0.0.dist-info/entry_points.txt +24 -0
- quantnodes-3.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
WikiTool - Wiki Knowledge Base Tool for Agent
|
|
4
|
+
|
|
5
|
+
Phase 3: Wiki Tool Integration
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
from .base import Tool
|
|
12
|
+
from ...research.wiki import (
|
|
13
|
+
WikiFactorProxy,
|
|
14
|
+
WikiFactor,
|
|
15
|
+
WikiLogic,
|
|
16
|
+
WikiStrategy,
|
|
17
|
+
WikiReproduction,
|
|
18
|
+
FactorSource,
|
|
19
|
+
FactorCategory,
|
|
20
|
+
LogicSource,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class WikiTool(Tool):
|
|
25
|
+
"""Wiki Knowledge Base Operation Tool"""
|
|
26
|
+
|
|
27
|
+
name = "wiki"
|
|
28
|
+
description = "QuantNodes Wiki 知识库 - 因子/逻辑/策略的存取与查询"
|
|
29
|
+
read_only = False
|
|
30
|
+
|
|
31
|
+
STORE_FACTOR_SCHEMA = {
|
|
32
|
+
"name": "store_factor",
|
|
33
|
+
"description": "将验证通过的因子存储到 Wiki 知识库",
|
|
34
|
+
"parameters": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"properties": {
|
|
37
|
+
"name": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "因子名称(唯一标识)",
|
|
40
|
+
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
|
|
41
|
+
},
|
|
42
|
+
"formula": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "因子公式(如 ts_mean(close, 20) / ts_mean(close, 60) - 1)",
|
|
45
|
+
},
|
|
46
|
+
"source": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"enum": ["research_report", "auto_research", "manual", "derived", "imported"],
|
|
49
|
+
"description": "因子来源",
|
|
50
|
+
},
|
|
51
|
+
"category": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"enum": [
|
|
54
|
+
"momentum", "value", "quality",
|
|
55
|
+
"volatility", "size", "growth", "other",
|
|
56
|
+
],
|
|
57
|
+
"description": "因子分类",
|
|
58
|
+
},
|
|
59
|
+
"ic_mean": {"type": "number", "description": "IC 均值"},
|
|
60
|
+
"ic_std": {"type": "number", "description": "IC 标准差"},
|
|
61
|
+
"icir": {"type": "number", "description": "IC IR"},
|
|
62
|
+
"rank_ic_mean": {"type": "number", "description": "Rank IC 均值"},
|
|
63
|
+
"turnover": {"type": "number", "description": "换手率"},
|
|
64
|
+
"tags": {
|
|
65
|
+
"type": "array",
|
|
66
|
+
"items": {"type": "string"},
|
|
67
|
+
"description": "标签列表",
|
|
68
|
+
},
|
|
69
|
+
"description": {"type": "string", "description": "因子描述"},
|
|
70
|
+
},
|
|
71
|
+
"required": ["name", "formula", "source", "category"],
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
GET_FACTOR_SCHEMA = {
|
|
76
|
+
"name": "get_factor",
|
|
77
|
+
"description": "获取因子详情",
|
|
78
|
+
"parameters": {
|
|
79
|
+
"type": "object",
|
|
80
|
+
"properties": {
|
|
81
|
+
"name": {"type": "string", "description": "因子名称"},
|
|
82
|
+
},
|
|
83
|
+
"required": ["name"],
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
SEARCH_FACTORS_SCHEMA = {
|
|
88
|
+
"name": "search_factors",
|
|
89
|
+
"description": "全文搜索 Wiki 中的因子",
|
|
90
|
+
"parameters": {
|
|
91
|
+
"type": "object",
|
|
92
|
+
"properties": {
|
|
93
|
+
"query": {"type": "string", "description": "搜索关键词"},
|
|
94
|
+
"limit": {"type": "integer", "default": 10, "description": "返回数量"},
|
|
95
|
+
},
|
|
96
|
+
"required": ["query"],
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
LIST_FACTORS_SCHEMA = {
|
|
101
|
+
"name": "list_factors",
|
|
102
|
+
"description": "列举因子(支持过滤)",
|
|
103
|
+
"parameters": {
|
|
104
|
+
"type": "object",
|
|
105
|
+
"properties": {
|
|
106
|
+
"source": {"type": "string", "description": "来源过滤"},
|
|
107
|
+
"category": {"type": "string", "description": "分类过滤"},
|
|
108
|
+
"tags": {"type": "array", "items": {"type": "string"}, "description": "标签过滤"},
|
|
109
|
+
"limit": {"type": "integer", "default": 50},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
STORE_LOGIC_SCHEMA = {
|
|
115
|
+
"name": "store_logic",
|
|
116
|
+
"description": "存储研报逻辑",
|
|
117
|
+
"parameters": {
|
|
118
|
+
"type": "object",
|
|
119
|
+
"properties": {
|
|
120
|
+
"name": {"type": "string", "description": "逻辑名称"},
|
|
121
|
+
"content": {"type": "string", "description": "逻辑内容"},
|
|
122
|
+
"source": {"type": "string", "enum": ["research_report", "manual"]},
|
|
123
|
+
"extracted_formula": {"type": "string", "description": "提取的公式"},
|
|
124
|
+
},
|
|
125
|
+
"required": ["name", "content", "source"],
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
STORE_STRATEGY_SCHEMA = {
|
|
130
|
+
"name": "store_strategy",
|
|
131
|
+
"description": "存储策略配置到 Wiki",
|
|
132
|
+
"parameters": {
|
|
133
|
+
"type": "object",
|
|
134
|
+
"properties": {
|
|
135
|
+
"name": {"type": "string", "description": "策略名称"},
|
|
136
|
+
"strategy_yaml": {"type": "string", "description": "策略 YAML 配置"},
|
|
137
|
+
"description": {"type": "string", "description": "策略描述"},
|
|
138
|
+
"category": {"type": "string", "default": "general"},
|
|
139
|
+
"tags": {"type": "array", "items": {"type": "string"}},
|
|
140
|
+
"backtest_result": {"type": "object", "description": "回测结果"},
|
|
141
|
+
},
|
|
142
|
+
"required": ["name", "strategy_yaml"],
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
GET_STRATEGY_SCHEMA = {
|
|
147
|
+
"name": "get_strategy",
|
|
148
|
+
"description": "获取策略详情",
|
|
149
|
+
"parameters": {
|
|
150
|
+
"type": "object",
|
|
151
|
+
"properties": {
|
|
152
|
+
"name": {"type": "string", "description": "策略名称"},
|
|
153
|
+
},
|
|
154
|
+
"required": ["name"],
|
|
155
|
+
},
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
LIST_STRATEGIES_SCHEMA = {
|
|
159
|
+
"name": "list_strategies",
|
|
160
|
+
"description": "列举策略",
|
|
161
|
+
"parameters": {
|
|
162
|
+
"type": "object",
|
|
163
|
+
"properties": {
|
|
164
|
+
"category": {"type": "string"},
|
|
165
|
+
"tags": {"type": "array", "items": {"type": "string"}},
|
|
166
|
+
"limit": {"type": "integer", "default": 50},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
ADD_RELATION_SCHEMA = {
|
|
172
|
+
"name": "add_relation",
|
|
173
|
+
"description": "建立知识图谱关系",
|
|
174
|
+
"parameters": {
|
|
175
|
+
"type": "object",
|
|
176
|
+
"properties": {
|
|
177
|
+
"source_name": {"type": "string", "description": "源节点(如 Factor/xxx)"},
|
|
178
|
+
"target_name": {
|
|
179
|
+
"type": "string",
|
|
180
|
+
"description": "目标节点(如 Strategy/yyy)",
|
|
181
|
+
},
|
|
182
|
+
"relation": {
|
|
183
|
+
"type": "string",
|
|
184
|
+
"enum": [
|
|
185
|
+
"uses", "correlates_with", "derived_from",
|
|
186
|
+
"outperforms", "similar_to",
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
"required": ["source_name", "target_name", "relation"],
|
|
191
|
+
},
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
PING_SCHEMA = {
|
|
195
|
+
"name": "ping",
|
|
196
|
+
"description": "检查 Wiki 可用性",
|
|
197
|
+
"parameters": {"type": "object", "properties": {}},
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
STATUS_SCHEMA = {
|
|
201
|
+
"name": "status",
|
|
202
|
+
"description": "获取 Wiki 状态统计",
|
|
203
|
+
"parameters": {"type": "object", "properties": {}},
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
SEARCH_SCHEMA = {
|
|
207
|
+
"name": "search",
|
|
208
|
+
"description": "全文搜索 Wiki",
|
|
209
|
+
"parameters": {
|
|
210
|
+
"type": "object",
|
|
211
|
+
"properties": {
|
|
212
|
+
"query": {"type": "string"},
|
|
213
|
+
"limit": {"type": "integer", "default": 10},
|
|
214
|
+
},
|
|
215
|
+
"required": ["query"],
|
|
216
|
+
},
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
def __init__(self, wiki_path: str, **kwargs):
|
|
220
|
+
self.proxy = WikiFactorProxy(wiki_path)
|
|
221
|
+
self._logger = logging.getLogger(f"tools.{self.name}")
|
|
222
|
+
|
|
223
|
+
@property
|
|
224
|
+
def parameters(self) -> Dict[str, Any]:
|
|
225
|
+
return {"type": "object", "properties": {}}
|
|
226
|
+
|
|
227
|
+
async def execute(self, action: str, **kwargs: Any) -> Any:
|
|
228
|
+
action_map = {
|
|
229
|
+
"store_factor": self._store_factor,
|
|
230
|
+
"get_factor": self._get_factor,
|
|
231
|
+
"search_factors": self._search_factors,
|
|
232
|
+
"list_factors": self._list_factors,
|
|
233
|
+
"store_logic": self._store_logic,
|
|
234
|
+
"get_logic": self._get_logic,
|
|
235
|
+
"store_strategy": self._store_strategy,
|
|
236
|
+
"get_strategy": self._get_strategy,
|
|
237
|
+
"list_strategies": self._list_strategies,
|
|
238
|
+
"store_reproduction": self._store_reproduction,
|
|
239
|
+
"add_relation": self._add_relation,
|
|
240
|
+
"get_neighbors": self._get_neighbors,
|
|
241
|
+
"ping": self._ping,
|
|
242
|
+
"status": self._status,
|
|
243
|
+
"search": self._search,
|
|
244
|
+
}
|
|
245
|
+
if action not in action_map:
|
|
246
|
+
raise ValueError(f"Unknown action: {action}")
|
|
247
|
+
self._logger.info(f"[WikiTool] executing action={action}")
|
|
248
|
+
return await action_map[action](**kwargs)
|
|
249
|
+
|
|
250
|
+
def _factor_to_dict(self, factor: WikiFactor) -> Dict[str, Any]:
|
|
251
|
+
return {
|
|
252
|
+
"name": factor.name,
|
|
253
|
+
"formula": factor.formula,
|
|
254
|
+
"source": factor.source.value,
|
|
255
|
+
"category": factor.category.value,
|
|
256
|
+
"ic_mean": factor.ic_mean,
|
|
257
|
+
"ic_std": factor.ic_std,
|
|
258
|
+
"icir": factor.icir,
|
|
259
|
+
"rank_ic_mean": factor.rank_ic_mean,
|
|
260
|
+
"tags": factor.tags,
|
|
261
|
+
"wiki_page_name": factor.wiki_page_name,
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
async def _store_factor(self, **kwargs) -> str:
|
|
265
|
+
source = FactorSource(kwargs.pop("source"))
|
|
266
|
+
category = FactorCategory(kwargs.pop("category"))
|
|
267
|
+
factor = WikiFactor(source=source, category=category, **kwargs)
|
|
268
|
+
result = self.proxy.store_factor(factor)
|
|
269
|
+
self._logger.info(f"[WikiTool] stored factor: {result}")
|
|
270
|
+
return result
|
|
271
|
+
|
|
272
|
+
async def _get_factor(self, name: str, **kwargs) -> Optional[Dict[str, Any]]:
|
|
273
|
+
factor = self.proxy.get_factor(name)
|
|
274
|
+
if factor:
|
|
275
|
+
return self._factor_to_dict(factor)
|
|
276
|
+
return None
|
|
277
|
+
|
|
278
|
+
async def _search_factors(self, query: str, limit: int = 10, **kwargs) -> List[Dict[str, Any]]:
|
|
279
|
+
factors = self.proxy.search_factors(query, limit=limit)
|
|
280
|
+
return [self._factor_to_dict(f) for f in factors]
|
|
281
|
+
|
|
282
|
+
async def _list_factors(
|
|
283
|
+
self, source=None, category=None, tags=None, limit=50, **kwargs,
|
|
284
|
+
) -> List[Dict[str, Any]]:
|
|
285
|
+
if source:
|
|
286
|
+
source = FactorSource(source)
|
|
287
|
+
if category:
|
|
288
|
+
category = FactorCategory(category)
|
|
289
|
+
factors = self.proxy.list_factors(source=source, category=category, tags=tags, limit=limit)
|
|
290
|
+
return [self._factor_to_dict(f) for f in factors]
|
|
291
|
+
|
|
292
|
+
async def _store_logic(self, **kwargs) -> str:
|
|
293
|
+
source = LogicSource(kwargs.pop("source"))
|
|
294
|
+
logic = WikiLogic(source=source, **kwargs)
|
|
295
|
+
result = self.proxy.store_logic(logic)
|
|
296
|
+
self._logger.info(f"[WikiTool] stored logic: {result}")
|
|
297
|
+
return result
|
|
298
|
+
|
|
299
|
+
async def _get_logic(self, name: str, **kwargs) -> Optional[Dict[str, Any]]:
|
|
300
|
+
logic = self.proxy.get_logic(name)
|
|
301
|
+
if logic:
|
|
302
|
+
return {
|
|
303
|
+
"name": logic.name,
|
|
304
|
+
"content": logic.content,
|
|
305
|
+
"source": logic.source.value,
|
|
306
|
+
"extracted_formula": logic.extracted_formula,
|
|
307
|
+
"validation_status": logic.validation_status,
|
|
308
|
+
"wiki_page_name": logic.wiki_page_name,
|
|
309
|
+
}
|
|
310
|
+
return None
|
|
311
|
+
|
|
312
|
+
async def _store_strategy(self, **kwargs) -> str:
|
|
313
|
+
strategy = WikiStrategy(**kwargs)
|
|
314
|
+
result = self.proxy.store_strategy(strategy)
|
|
315
|
+
self._logger.info(f"[WikiTool] stored strategy: {result}")
|
|
316
|
+
return result
|
|
317
|
+
|
|
318
|
+
async def _get_strategy(self, name: str, **kwargs) -> Optional[Dict[str, Any]]:
|
|
319
|
+
strategy = self.proxy.get_strategy(name)
|
|
320
|
+
if strategy:
|
|
321
|
+
return {
|
|
322
|
+
"name": strategy.name,
|
|
323
|
+
"description": strategy.description,
|
|
324
|
+
"category": strategy.category,
|
|
325
|
+
"tags": strategy.tags,
|
|
326
|
+
"strategy_yaml": strategy.strategy_yaml,
|
|
327
|
+
"backtest_result": strategy.backtest_result,
|
|
328
|
+
"wiki_page_name": strategy.wiki_page_name,
|
|
329
|
+
}
|
|
330
|
+
return None
|
|
331
|
+
|
|
332
|
+
async def _list_strategies(
|
|
333
|
+
self, category=None, tags=None, limit=50, **kwargs,
|
|
334
|
+
) -> List[Dict[str, Any]]:
|
|
335
|
+
strategies = self.proxy.list_strategies(category=category, tags=tags, limit=limit)
|
|
336
|
+
return [
|
|
337
|
+
{
|
|
338
|
+
"name": s.name,
|
|
339
|
+
"description": s.description,
|
|
340
|
+
"category": s.category,
|
|
341
|
+
"tags": s.tags,
|
|
342
|
+
"wiki_page_name": s.wiki_page_name,
|
|
343
|
+
}
|
|
344
|
+
for s in strategies
|
|
345
|
+
]
|
|
346
|
+
|
|
347
|
+
async def _store_reproduction(self, **kwargs) -> str:
|
|
348
|
+
reproduction = WikiReproduction(**kwargs)
|
|
349
|
+
result = self.proxy.store_reproduction(reproduction)
|
|
350
|
+
self._logger.info(f"[WikiTool] stored reproduction: {result}")
|
|
351
|
+
return result
|
|
352
|
+
|
|
353
|
+
async def _add_relation(
|
|
354
|
+
self, source_name: str, target_name: str, relation: str, **kwargs,
|
|
355
|
+
) -> bool:
|
|
356
|
+
result = self.proxy.add_relation(source_name, target_name, relation)
|
|
357
|
+
self._logger.info(f"[WikiTool] added relation: {source_name} -> {target_name}")
|
|
358
|
+
return result
|
|
359
|
+
|
|
360
|
+
async def _get_neighbors(self, name: str, **kwargs) -> List[Dict[str, Any]]:
|
|
361
|
+
return self.proxy.get_neighbors(name)
|
|
362
|
+
|
|
363
|
+
async def _ping(self, **kwargs) -> bool:
|
|
364
|
+
return self.proxy.ping()
|
|
365
|
+
|
|
366
|
+
async def _status(self, **kwargs) -> Dict[str, Any]:
|
|
367
|
+
return self.proxy.status()
|
|
368
|
+
|
|
369
|
+
async def _search(self, query: str, limit: int = 10, **kwargs) -> List[Dict[str, Any]]:
|
|
370
|
+
return self.proxy.wiki.search(query, limit=limit)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
工具函数模块
|
|
4
|
+
|
|
5
|
+
文本处理 / Prompt模板渲染 / 帮助函数
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .helpers import truncate_text, count_tokens, ensure_async
|
|
9
|
+
from .prompt_templates import render_template, load_template
|
|
10
|
+
|
|
11
|
+
__all__ = ["truncate_text", "count_tokens", "ensure_async", "render_template", "load_template"]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
工具函数
|
|
4
|
+
|
|
5
|
+
文本处理、Token计数等
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import asyncio
|
|
9
|
+
from typing import Any, Callable
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def truncate_text(text: str, max_chars: int, suffix: str = "...") -> str:
|
|
13
|
+
"""截断文本到指定长度"""
|
|
14
|
+
if max_chars <= 0:
|
|
15
|
+
return suffix
|
|
16
|
+
if len(text) <= max_chars:
|
|
17
|
+
return text
|
|
18
|
+
if max_chars <= len(suffix):
|
|
19
|
+
return suffix[:max_chars]
|
|
20
|
+
return text[:max_chars - len(suffix)] + suffix
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def count_tokens(text: Any) -> int:
|
|
24
|
+
"""估算token数量(简化版)"""
|
|
25
|
+
if text is None:
|
|
26
|
+
return 0
|
|
27
|
+
if not isinstance(text, str):
|
|
28
|
+
text = str(text)
|
|
29
|
+
return len(text) // 4
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
async def ensure_async(
|
|
33
|
+
func: Callable[..., Any],
|
|
34
|
+
*args: Any,
|
|
35
|
+
**kwargs: Any,
|
|
36
|
+
) -> Any:
|
|
37
|
+
"""确保函数异步执行"""
|
|
38
|
+
if asyncio.iscoroutinefunction(func):
|
|
39
|
+
return await func(*args, **kwargs)
|
|
40
|
+
else:
|
|
41
|
+
from functools import partial
|
|
42
|
+
loop = asyncio.get_event_loop()
|
|
43
|
+
return await loop.run_in_executor(None, partial(func, *args, **kwargs))
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
Prompt模板渲染
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Dict, Any
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def load_template(path: Path | str) -> str:
|
|
11
|
+
"""加载模板文件"""
|
|
12
|
+
path = Path(path)
|
|
13
|
+
if path.exists():
|
|
14
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
15
|
+
return f.read()
|
|
16
|
+
return ""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def render_template(template: str, context: Dict[str, Any]) -> str:
|
|
20
|
+
"""渲染模板(简单的字符串替换)"""
|
|
21
|
+
result = template
|
|
22
|
+
for key, value in context.items():
|
|
23
|
+
result = result.replace(f"{{{{{key}}}}}", str(value))
|
|
24
|
+
return result
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def render_template_file(path: Path | str, context: Dict[str, Any]) -> str:
|
|
28
|
+
"""从文件加载并渲染模板"""
|
|
29
|
+
template = load_template(path)
|
|
30
|
+
return render_template(template, context)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""QuantNodes Workflows — 多智能体 WorkflowTool 框架。
|
|
3
|
+
|
|
4
|
+
声明式定义 pipeline 步骤 (StepAgentSpec),
|
|
5
|
+
框架驱动多轮迭代执行 (WorkflowTool)。
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .step_agent import ParseResult, StepAgent, StepAgentSpec
|
|
9
|
+
from .registry import REGISTRY, WorkflowRegistry, WorkflowSpec
|
|
10
|
+
from .tool import WorkflowTool
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"StepAgent",
|
|
14
|
+
"StepAgentSpec",
|
|
15
|
+
"ParseResult",
|
|
16
|
+
"WorkflowRegistry",
|
|
17
|
+
"WorkflowSpec",
|
|
18
|
+
"REGISTRY",
|
|
19
|
+
"WorkflowTool",
|
|
20
|
+
]
|