sr-harness 1.0.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.
- sr_harness-1.0.0/LICENSE +7 -0
- sr_harness-1.0.0/PKG-INFO +165 -0
- sr_harness-1.0.0/README.md +109 -0
- sr_harness-1.0.0/pyproject.toml +106 -0
- sr_harness-1.0.0/setup.cfg +4 -0
- sr_harness-1.0.0/src/sr_harness/README.md +102 -0
- sr_harness-1.0.0/src/sr_harness/__init__.py +31 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/README.zh.md +13 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/__init__.py +0 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/__init__.py +1 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/__init__.py +32 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/codex/__init__.py +747 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/codex/call_tool_template.py +63 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/codex/readme_template.md +83 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/codex/utils.py +41 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/functionevolve.py +288 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/linear.py +37 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/my_igsr.py +414 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/my_pysr.py +102 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/polynomial.py +57 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/pysr.py +105 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/sr_harness.py +212 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/algorithms/sr_scientist.py +425 -0
- sr_harness-1.0.0/src/sr_harness/_vendor/llmsr_bench/core.py +81 -0
- sr_harness-1.0.0/src/sr_harness/agents/__init__.py +14 -0
- sr_harness-1.0.0/src/sr_harness/agents/agent.py +136 -0
- sr_harness-1.0.0/src/sr_harness/agents/data_preparation_agent.py +315 -0
- sr_harness-1.0.0/src/sr_harness/agents/evaluator_construction_agent.py +317 -0
- sr_harness-1.0.0/src/sr_harness/agents/sr_agent.py +1376 -0
- sr_harness-1.0.0/src/sr_harness/agents/sr_agent_interactive.py +682 -0
- sr_harness-1.0.0/src/sr_harness/api/__init__.py +24 -0
- sr_harness-1.0.0/src/sr_harness/api/base_api.py +180 -0
- sr_harness-1.0.0/src/sr_harness/api/deepseek_api.py +102 -0
- sr_harness-1.0.0/src/sr_harness/api/gemini_api.py +102 -0
- sr_harness-1.0.0/src/sr_harness/api/lmstudio_api.py +161 -0
- sr_harness-1.0.0/src/sr_harness/api/manual_api.py +60 -0
- sr_harness-1.0.0/src/sr_harness/api/openai_api.py +349 -0
- sr_harness-1.0.0/src/sr_harness/api/openrouter_api.py +296 -0
- sr_harness-1.0.0/src/sr_harness/api/siliconflow_api.py +199 -0
- sr_harness-1.0.0/src/sr_harness/cli/README.zh.md +5 -0
- sr_harness-1.0.0/src/sr_harness/cli/__init__.py +78 -0
- sr_harness-1.0.0/src/sr_harness/cli/benchmark.py +705 -0
- sr_harness-1.0.0/src/sr_harness/cli/run.py +142 -0
- sr_harness-1.0.0/src/sr_harness/cli/synthetic.py +369 -0
- sr_harness-1.0.0/src/sr_harness/cli/tool.py +194 -0
- sr_harness-1.0.0/src/sr_harness/core/__init__.py +40 -0
- sr_harness-1.0.0/src/sr_harness/core/api.py +73 -0
- sr_harness-1.0.0/src/sr_harness/core/context.py +319 -0
- sr_harness-1.0.0/src/sr_harness/core/context_data.py +458 -0
- sr_harness-1.0.0/src/sr_harness/core/search.py +668 -0
- sr_harness-1.0.0/src/sr_harness/core/tool.py +59 -0
- sr_harness-1.0.0/src/sr_harness/evaluator/__init__.py +15 -0
- sr_harness-1.0.0/src/sr_harness/evaluator/default_evaluator.py +90 -0
- sr_harness-1.0.0/src/sr_harness/evaluator/graph_evaluator.py +99 -0
- sr_harness-1.0.0/src/sr_harness/evaluator/load_custom_evaluator.py +170 -0
- sr_harness-1.0.0/src/sr_harness/evaluator/utils/__init__.py +342 -0
- sr_harness-1.0.0/src/sr_harness/parser/__init__.py +12 -0
- sr_harness-1.0.0/src/sr_harness/parser/base_parser.py +103 -0
- sr_harness-1.0.0/src/sr_harness/parser/json_parser.py +110 -0
- sr_harness-1.0.0/src/sr_harness/parser/openai_parser.py +72 -0
- sr_harness-1.0.0/src/sr_harness/parser/text_parser.py +231 -0
- sr_harness-1.0.0/src/sr_harness/parser/xml_parser.py +18 -0
- sr_harness-1.0.0/src/sr_harness/runtime/__init__.py +24 -0
- sr_harness-1.0.0/src/sr_harness/runtime/interaction_manager.py +559 -0
- sr_harness-1.0.0/src/sr_harness/runtime/model_router.py +120 -0
- sr_harness-1.0.0/src/sr_harness/skills/__init__.py +1 -0
- sr_harness-1.0.0/src/sr_harness/skills/discover-symbolic-laws/SKILL.md +343 -0
- sr_harness-1.0.0/src/sr_harness/skills/skill_manager.py +289 -0
- sr_harness-1.0.0/src/sr_harness/skills/sr-harness-engine-graph-syntax/SKILL.md +181 -0
- sr_harness-1.0.0/src/sr_harness/skills/sr-harness-engine-syntax/SKILL.md +96 -0
- sr_harness-1.0.0/src/sr_harness/tools/README.md +160 -0
- sr_harness-1.0.0/src/sr_harness/tools/__init__.py +50 -0
- sr_harness-1.0.0/src/sr_harness/tools/base_tool.py +907 -0
- sr_harness-1.0.0/src/sr_harness/tools/call_llm.py +36 -0
- sr_harness-1.0.0/src/sr_harness/tools/call_pysr.py +274 -0
- sr_harness-1.0.0/src/sr_harness/tools/call_sindy.py +275 -0
- sr_harness-1.0.0/src/sr_harness/tools/code_executor.py +810 -0
- sr_harness-1.0.0/src/sr_harness/tools/constant_fit.py +225 -0
- sr_harness-1.0.0/src/sr_harness/tools/create_skill.py +293 -0
- sr_harness-1.0.0/src/sr_harness/tools/edit_skill.py +133 -0
- sr_harness-1.0.0/src/sr_harness/tools/edit_tool.py +113 -0
- sr_harness-1.0.0/src/sr_harness/tools/eic.py +320 -0
- sr_harness-1.0.0/src/sr_harness/tools/evaluate_code.py +356 -0
- sr_harness-1.0.0/src/sr_harness/tools/evaluate_formula.py +98 -0
- sr_harness-1.0.0/src/sr_harness/tools/harmonic_interaction_fit.py +155 -0
- sr_harness-1.0.0/src/sr_harness/tools/model_test.py +36 -0
- sr_harness-1.0.0/src/sr_harness/tools/nd2.py +383 -0
- sr_harness-1.0.0/src/sr_harness/tools/polynomial_fit.py +385 -0
- sr_harness-1.0.0/src/sr_harness/tools/power_law_fit.py +320 -0
- sr_harness-1.0.0/src/sr_harness/tools/predict_property.py +398 -0
- sr_harness-1.0.0/src/sr_harness/tools/rational_fit.py +301 -0
- sr_harness-1.0.0/src/sr_harness/tools/read_pdf.py +114 -0
- sr_harness-1.0.0/src/sr_harness/tools/read_skill.py +119 -0
- sr_harness-1.0.0/src/sr_harness/tools/read_source.py +209 -0
- sr_harness-1.0.0/src/sr_harness/tools/relationship_analysis.py +329 -0
- sr_harness-1.0.0/src/sr_harness/tools/sr4mdl.py +345 -0
- sr_harness-1.0.0/src/sr_harness/tools/statistics_analysis.py +205 -0
- sr_harness-1.0.0/src/sr_harness/tools/subagent.py +196 -0
- sr_harness-1.0.0/src/sr_harness/tools/validate_context_data.py +114 -0
- sr_harness-1.0.0/src/sr_harness/tools/validate_evaluator.py +67 -0
- sr_harness-1.0.0/src/sr_harness/tools/web_research.py +191 -0
- sr_harness-1.0.0/src/sr_harness/tools/workspace_code_executor.py +501 -0
- sr_harness-1.0.0/src/sr_harness/tools/workspace_shell.py +1123 -0
- sr_harness-1.0.0/src/sr_harness/utils/__init__.py +34 -0
- sr_harness-1.0.0/src/sr_harness/utils/attr_dict.py +49 -0
- sr_harness-1.0.0/src/sr_harness/utils/auto_gpu.py +81 -0
- sr_harness-1.0.0/src/sr_harness/utils/classproperty.py +13 -0
- sr_harness-1.0.0/src/sr_harness/utils/constant_optimizer.py +242 -0
- sr_harness-1.0.0/src/sr_harness/utils/df_to_3line.py +48 -0
- sr_harness-1.0.0/src/sr_harness/utils/factory_mixin.py +138 -0
- sr_harness-1.0.0/src/sr_harness/utils/fix_parser.py +64 -0
- sr_harness-1.0.0/src/sr_harness/utils/format_confusion_matrix.py +75 -0
- sr_harness-1.0.0/src/sr_harness/utils/format_pareto_front.py +129 -0
- sr_harness-1.0.0/src/sr_harness/utils/lazy_loader.py +35 -0
- sr_harness-1.0.0/src/sr_harness/utils/log_exception.py +12 -0
- sr_harness-1.0.0/src/sr_harness/utils/logger.py +268 -0
- sr_harness-1.0.0/src/sr_harness/utils/metrics.py +30 -0
- sr_harness-1.0.0/src/sr_harness/utils/model_store.py +154 -0
- sr_harness-1.0.0/src/sr_harness/utils/nn/__init__.py +3 -0
- sr_harness-1.0.0/src/sr_harness/utils/nn/gnn.py +113 -0
- sr_harness-1.0.0/src/sr_harness/utils/nn/positional_encoding.py +22 -0
- sr_harness-1.0.0/src/sr_harness/utils/parse_json_with_template.py +154 -0
- sr_harness-1.0.0/src/sr_harness/utils/plot.py +369 -0
- sr_harness-1.0.0/src/sr_harness/utils/render_markdown.py +23 -0
- sr_harness-1.0.0/src/sr_harness/utils/render_python.py +18 -0
- sr_harness-1.0.0/src/sr_harness/utils/sanitize_filename.py +6 -0
- sr_harness-1.0.0/src/sr_harness/utils/save_args.py +77 -0
- sr_harness-1.0.0/src/sr_harness/utils/serialize.py +35 -0
- sr_harness-1.0.0/src/sr_harness/utils/symbolic_acc.py +291 -0
- sr_harness-1.0.0/src/sr_harness/utils/tag2ansi.py +170 -0
- sr_harness-1.0.0/src/sr_harness/utils/timing.py +283 -0
- sr_harness-1.0.0/src/sr_harness/utils/utils.py +44 -0
- sr_harness-1.0.0/src/sr_harness/web/__init__.py +2 -0
- sr_harness-1.0.0/src/sr_harness/web/app.py +287 -0
- sr_harness-1.0.0/src/sr_harness/web/conversations.py +478 -0
- sr_harness-1.0.0/src/sr_harness/web/demo_data.py +139 -0
- sr_harness-1.0.0/src/sr_harness/web/platform.py +1007 -0
- sr_harness-1.0.0/src/sr_harness/web/session.py +1624 -0
- sr_harness-1.0.0/src/sr_harness/web/static/favicon.svg +4 -0
- sr_harness-1.0.0/src/sr_harness/web/static/index.html +2962 -0
- sr_harness-1.0.0/src/sr_harness/web/static/platform.html +1331 -0
- sr_harness-1.0.0/src/sr_harness.egg-info/PKG-INFO +165 -0
- sr_harness-1.0.0/src/sr_harness.egg-info/SOURCES.txt +163 -0
- sr_harness-1.0.0/src/sr_harness.egg-info/dependency_links.txt +1 -0
- sr_harness-1.0.0/src/sr_harness.egg-info/entry_points.txt +2 -0
- sr_harness-1.0.0/src/sr_harness.egg-info/requires.txt +44 -0
- sr_harness-1.0.0/src/sr_harness.egg-info/top_level.txt +2 -0
- sr_harness-1.0.0/src/sr_harness_engine/README.zh.md +282 -0
- sr_harness-1.0.0/src/sr_harness_engine/__init__.py +104 -0
- sr_harness-1.0.0/src/sr_harness_engine/analysis.py +127 -0
- sr_harness-1.0.0/src/sr_harness_engine/context.py +37 -0
- sr_harness-1.0.0/src/sr_harness_engine/desugar.py +90 -0
- sr_harness-1.0.0/src/sr_harness_engine/evaluation.py +422 -0
- sr_harness-1.0.0/src/sr_harness_engine/expression.py +530 -0
- sr_harness-1.0.0/src/sr_harness_engine/indexed_evaluation.py +838 -0
- sr_harness-1.0.0/src/sr_harness_engine/optimize.py +166 -0
- sr_harness-1.0.0/src/sr_harness_engine/parser.py +281 -0
- sr_harness-1.0.0/src/sr_harness_engine/render.py +132 -0
- sr_harness-1.0.0/src/sr_harness_engine/tree.py +162 -0
- sr_harness-1.0.0/tests/test_benchmark_default_tools.py +63 -0
- sr_harness-1.0.0/tests/test_codex_usage.py +36 -0
- sr_harness-1.0.0/tests/test_functionevolve.py +124 -0
- sr_harness-1.0.0/tests/test_my_igsr.py +63 -0
- sr_harness-1.0.0/tests/test_public_api_documentation.py +68 -0
- sr_harness-1.0.0/tests/test_sr_agent_parallel.py +757 -0
sr_harness-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2026-present, YuMeow.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sr-harness
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: SRHarness: a harness for agentic symbolic regression
|
|
5
|
+
Author-email: YuMeow <yuzh19@tsinghua.org.cn>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
8
|
+
Classifier: Intended Audience :: Science/Research
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: numpy>=1.24.0
|
|
16
|
+
Requires-Dist: scipy>=1.10.0
|
|
17
|
+
Requires-Dist: scikit-learn>=1.3.0
|
|
18
|
+
Requires-Dist: sympy>=1.12
|
|
19
|
+
Requires-Dist: pandas>=2.0.0
|
|
20
|
+
Requires-Dist: openpyxl>=3.1.0
|
|
21
|
+
Requires-Dist: joblib>=1.3.0
|
|
22
|
+
Requires-Dist: docstring-parser>=0.16
|
|
23
|
+
Requires-Dist: pyyaml>=6.0
|
|
24
|
+
Requires-Dist: rich>=13.0.0
|
|
25
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
26
|
+
Requires-Dist: openai>=1.0.0
|
|
27
|
+
Requires-Dist: google-genai>=1.0.0
|
|
28
|
+
Requires-Dist: requests>=2.28.0
|
|
29
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
30
|
+
Requires-Dist: h5py>=3.16.0
|
|
31
|
+
Requires-Dist: datasets>=4.8.0
|
|
32
|
+
Requires-Dist: textual>=1.0.0
|
|
33
|
+
Requires-Dist: prompt_toolkit>=3.0.0
|
|
34
|
+
Requires-Dist: fastapi>=0.115.0
|
|
35
|
+
Requires-Dist: uvicorn>=0.30.0
|
|
36
|
+
Provides-Extra: nn
|
|
37
|
+
Requires-Dist: torch>=2.0.0; extra == "nn"
|
|
38
|
+
Requires-Dist: torch-geometric>=2.4.0; extra == "nn"
|
|
39
|
+
Provides-Extra: tools
|
|
40
|
+
Requires-Dist: pysr>=1.5.10; extra == "tools"
|
|
41
|
+
Requires-Dist: pysindy>=2.1.0; extra == "tools"
|
|
42
|
+
Requires-Dist: pypdf>=5.0.0; extra == "tools"
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
45
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
46
|
+
Requires-Dist: ipynbname>=2025.8.0.0; extra == "dev"
|
|
47
|
+
Requires-Dist: yumeow_plot>=0.1.2; extra == "dev"
|
|
48
|
+
Requires-Dist: mkdocs>=1.6; extra == "dev"
|
|
49
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "dev"
|
|
50
|
+
Requires-Dist: mkdocstrings[python]>=0.27; extra == "dev"
|
|
51
|
+
Requires-Dist: mkdocs-static-i18n>=1.3; extra == "dev"
|
|
52
|
+
Requires-Dist: ruff>=0.8; extra == "dev"
|
|
53
|
+
Provides-Extra: all
|
|
54
|
+
Requires-Dist: sr-harness[dev,nn,tools]; extra == "all"
|
|
55
|
+
Dynamic: license-file
|
|
56
|
+
|
|
57
|
+
# SRHarness: A Harness for Agentic Symbolic Regression
|
|
58
|
+
|
|
59
|
+
[English](README.md) | [简体中文](README.zh.md)
|
|
60
|
+
|
|
61
|
+
[](https://github.com/yuzhTHU/SRHarness)
|
|
62
|
+
[](https://pypi.org/project/sr-harness/)
|
|
63
|
+
[](https://yuzhthu.github.io/SRHarness/)
|
|
64
|
+
[](http://sim1.fiblab.tech:30000/)
|
|
65
|
+
[](https://arxiv.org/abs/2609.35501)
|
|
66
|
+
[](https://github.com/yuzhTHU/SRHarness/actions/workflows/docs.yml)
|
|
67
|
+
[](https://pypi.org/project/sr-harness/)
|
|
68
|
+
[](LICENSE)
|
|
69
|
+
|
|
70
|
+
SRHarness is a domain-specific runtime for **agentic symbolic regression**. It lets language-model agents prepare scientific data, invoke composable analysis and fitting tools, retain evaluated hypotheses, and refine interpretable formulas over long search trajectories. Its interactive workbench also supports persistent conversations, editable task configuration, and task-specific formula evaluation through custom Evaluators.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
## Highlights
|
|
74
|
+
|
|
75
|
+
- **Composable scientific actions:** analysis, fitting, evaluation, code execution, and formula submission use a shared tool interface.
|
|
76
|
+
- **Persistent scientific state:** candidates, metrics, complexity, diagnostics, provenance, and Pareto rankings survive beyond one model response.
|
|
77
|
+
- **Managed search trajectories:** the `R-C-L-K` lifecycle coordinates restarts, branches, refinement depth, and local sampling.
|
|
78
|
+
- **Interactive research workflow:** the WebUI connects data preparation, task configuration, Evaluator construction, symbolic search, human guidance, and persistent workspaces.
|
|
79
|
+
- **Extensible symbolic modeling:** SRHarness Engine supports ordinary expressions as well as indexed graph and hypergraph formulas.
|
|
80
|
+
|
|
81
|
+
## Results
|
|
82
|
+
|
|
83
|
+
The [paper](https://arxiv.org/abs/2609.35501) evaluates SRHarness on LLM-SRBench under matched language-model backbones. LSR-Transform measures symbolic recovery on transformed scientific equations, while LSR-Transform-Anon removes scientific descriptions and variable semantics to test whether the search process remains effective without domain-specific textual cues. The table reports symbolic accuracy (SA):
|
|
84
|
+
|
|
85
|
+
| Method / backbone | LSR-Transform | LSR-Transform-Anon |
|
|
86
|
+
|---|---:|---:|
|
|
87
|
+
| SRHarness + DeepSeek-v4-flash-0731 | **93.69%** | **72.97%** |
|
|
88
|
+
| SR-Scientist + DeepSeek-v4-flash-0731 | 62.16% | 39.64% |
|
|
89
|
+
| Codex + DeepSeek-v4-flash-0731 | — | 20.72% |
|
|
90
|
+
|
|
91
|
+
With the same DeepSeek-v4-flash-0731 backbone, SRHarness substantially improves symbolic recovery over SR-Scientist on both settings. Its accuracy remains comparatively high after descriptions and variable semantics are removed, and it also outperforms Codex on the anonymized benchmark. These results indicate that the structured runtime—scientific actions, persistent hypothesis state, and trajectory management—contributes materially beyond the choice of language model alone. See the paper for the complete evaluation protocol, numerical-generalization results, complexity and resource analyses, and ablation studies.
|
|
92
|
+
|
|
93
|
+
## Installation
|
|
94
|
+
|
|
95
|
+
SRHarness requires Python 3.12 or newer.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pip install sr-harness
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
See the [installation guide](https://yuzhthu.github.io/SRHarness/install/) for provider configuration, source installation, development environments, and optional integrations.
|
|
102
|
+
|
|
103
|
+
## Quick Start
|
|
104
|
+
|
|
105
|
+
### Discover a known equation: `sr-harness synthetic`
|
|
106
|
+
|
|
107
|
+
Set `OPENROUTER_API_KEY`, then use `synthetic` to generate data from a known equation and test whether SRAgent can recover it:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
sr-harness synthetic \
|
|
111
|
+
--equation 'y = 1 + x1 ** 2 + 2 * x1 * x2' \
|
|
112
|
+
--n-samples 200 \
|
|
113
|
+
--x-low -2 \
|
|
114
|
+
--x-high 2 \
|
|
115
|
+
--seed 42 \
|
|
116
|
+
--llm-provider openrouter \
|
|
117
|
+
--llm-model deepseek/deepseek-v4-flash-0731 \
|
|
118
|
+
--save-path ./logs/quick-start \
|
|
119
|
+
-R 1 -C 1 -L 10 -K 1
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
If you use another provider, configure its API key and change `--llm-provider` and `--llm-model` accordingly.
|
|
123
|
+
|
|
124
|
+
### Interactive workbench: `sr-harness run`
|
|
125
|
+
|
|
126
|
+
Use `run` for the complete interactive research workflow. It starts the WebUI for data preparation, task and evaluator configuration, symbolic-regression search, and human guidance:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
sr-harness run \
|
|
130
|
+
--host 127.0.0.1 \
|
|
131
|
+
--port 8000 \
|
|
132
|
+
--workspace-dir ./workspaces \
|
|
133
|
+
--save-path ./logs/webui
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Then open <http://127.0.0.1:8000/>. The workspace registry and conversation workspaces are stored under `./workspaces`, while session snapshots and run records are stored under `./logs/webui`. A hosted instance is also available at <http://sim1.fiblab.tech:30000/>.
|
|
137
|
+
|
|
138
|
+
## Documentation
|
|
139
|
+
|
|
140
|
+
- [Overview](https://yuzhthu.github.io/SRHarness/)
|
|
141
|
+
- [Quick Start](https://yuzhthu.github.io/SRHarness/quick-start/)
|
|
142
|
+
- [Installation and provider configuration](https://yuzhthu.github.io/SRHarness/install/)
|
|
143
|
+
- [Commands and runtime options](https://yuzhthu.github.io/SRHarness/sr-harness/)
|
|
144
|
+
- [SRHarness Agent Workflow](https://yuzhthu.github.io/SRHarness/agent/)
|
|
145
|
+
- [Tools and tool-call Parsers](https://yuzhthu.github.io/SRHarness/core-abstractions/)
|
|
146
|
+
- [Structured data and `context.data`](https://yuzhthu.github.io/SRHarness/context-data/)
|
|
147
|
+
- [Formula evaluation and custom Evaluators](https://yuzhthu.github.io/SRHarness/evaluator/)
|
|
148
|
+
- [SRHarness WebUI](https://yuzhthu.github.io/SRHarness/web-ui/)
|
|
149
|
+
- [SRHarness Engine](https://yuzhthu.github.io/SRHarness/engine/)
|
|
150
|
+
- [API reference](https://yuzhthu.github.io/SRHarness/reference/)
|
|
151
|
+
|
|
152
|
+
## Citation
|
|
153
|
+
|
|
154
|
+
```bibtex
|
|
155
|
+
@article{yu2026srharness,
|
|
156
|
+
title = {SRHarness: A Harness for Agentic Symbolic Regression},
|
|
157
|
+
author = {Yu, Zihan and Zhou, Shixuan and Huang, Hao and Ding, Jingtao and Li, Yong},
|
|
158
|
+
journal = {arXiv preprint arXiv:2609.35501},
|
|
159
|
+
year = {2026}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
SRHarness is released under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# SRHarness: A Harness for Agentic Symbolic Regression
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [简体中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
[](https://github.com/yuzhTHU/SRHarness)
|
|
6
|
+
[](https://pypi.org/project/sr-harness/)
|
|
7
|
+
[](https://yuzhthu.github.io/SRHarness/)
|
|
8
|
+
[](http://sim1.fiblab.tech:30000/)
|
|
9
|
+
[](https://arxiv.org/abs/2609.35501)
|
|
10
|
+
[](https://github.com/yuzhTHU/SRHarness/actions/workflows/docs.yml)
|
|
11
|
+
[](https://pypi.org/project/sr-harness/)
|
|
12
|
+
[](LICENSE)
|
|
13
|
+
|
|
14
|
+
SRHarness is a domain-specific runtime for **agentic symbolic regression**. It lets language-model agents prepare scientific data, invoke composable analysis and fitting tools, retain evaluated hypotheses, and refine interpretable formulas over long search trajectories. Its interactive workbench also supports persistent conversations, editable task configuration, and task-specific formula evaluation through custom Evaluators.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Highlights
|
|
18
|
+
|
|
19
|
+
- **Composable scientific actions:** analysis, fitting, evaluation, code execution, and formula submission use a shared tool interface.
|
|
20
|
+
- **Persistent scientific state:** candidates, metrics, complexity, diagnostics, provenance, and Pareto rankings survive beyond one model response.
|
|
21
|
+
- **Managed search trajectories:** the `R-C-L-K` lifecycle coordinates restarts, branches, refinement depth, and local sampling.
|
|
22
|
+
- **Interactive research workflow:** the WebUI connects data preparation, task configuration, Evaluator construction, symbolic search, human guidance, and persistent workspaces.
|
|
23
|
+
- **Extensible symbolic modeling:** SRHarness Engine supports ordinary expressions as well as indexed graph and hypergraph formulas.
|
|
24
|
+
|
|
25
|
+
## Results
|
|
26
|
+
|
|
27
|
+
The [paper](https://arxiv.org/abs/2609.35501) evaluates SRHarness on LLM-SRBench under matched language-model backbones. LSR-Transform measures symbolic recovery on transformed scientific equations, while LSR-Transform-Anon removes scientific descriptions and variable semantics to test whether the search process remains effective without domain-specific textual cues. The table reports symbolic accuracy (SA):
|
|
28
|
+
|
|
29
|
+
| Method / backbone | LSR-Transform | LSR-Transform-Anon |
|
|
30
|
+
|---|---:|---:|
|
|
31
|
+
| SRHarness + DeepSeek-v4-flash-0731 | **93.69%** | **72.97%** |
|
|
32
|
+
| SR-Scientist + DeepSeek-v4-flash-0731 | 62.16% | 39.64% |
|
|
33
|
+
| Codex + DeepSeek-v4-flash-0731 | — | 20.72% |
|
|
34
|
+
|
|
35
|
+
With the same DeepSeek-v4-flash-0731 backbone, SRHarness substantially improves symbolic recovery over SR-Scientist on both settings. Its accuracy remains comparatively high after descriptions and variable semantics are removed, and it also outperforms Codex on the anonymized benchmark. These results indicate that the structured runtime—scientific actions, persistent hypothesis state, and trajectory management—contributes materially beyond the choice of language model alone. See the paper for the complete evaluation protocol, numerical-generalization results, complexity and resource analyses, and ablation studies.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
SRHarness requires Python 3.12 or newer.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install sr-harness
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
See the [installation guide](https://yuzhthu.github.io/SRHarness/install/) for provider configuration, source installation, development environments, and optional integrations.
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
### Discover a known equation: `sr-harness synthetic`
|
|
50
|
+
|
|
51
|
+
Set `OPENROUTER_API_KEY`, then use `synthetic` to generate data from a known equation and test whether SRAgent can recover it:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
sr-harness synthetic \
|
|
55
|
+
--equation 'y = 1 + x1 ** 2 + 2 * x1 * x2' \
|
|
56
|
+
--n-samples 200 \
|
|
57
|
+
--x-low -2 \
|
|
58
|
+
--x-high 2 \
|
|
59
|
+
--seed 42 \
|
|
60
|
+
--llm-provider openrouter \
|
|
61
|
+
--llm-model deepseek/deepseek-v4-flash-0731 \
|
|
62
|
+
--save-path ./logs/quick-start \
|
|
63
|
+
-R 1 -C 1 -L 10 -K 1
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
If you use another provider, configure its API key and change `--llm-provider` and `--llm-model` accordingly.
|
|
67
|
+
|
|
68
|
+
### Interactive workbench: `sr-harness run`
|
|
69
|
+
|
|
70
|
+
Use `run` for the complete interactive research workflow. It starts the WebUI for data preparation, task and evaluator configuration, symbolic-regression search, and human guidance:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
sr-harness run \
|
|
74
|
+
--host 127.0.0.1 \
|
|
75
|
+
--port 8000 \
|
|
76
|
+
--workspace-dir ./workspaces \
|
|
77
|
+
--save-path ./logs/webui
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Then open <http://127.0.0.1:8000/>. The workspace registry and conversation workspaces are stored under `./workspaces`, while session snapshots and run records are stored under `./logs/webui`. A hosted instance is also available at <http://sim1.fiblab.tech:30000/>.
|
|
81
|
+
|
|
82
|
+
## Documentation
|
|
83
|
+
|
|
84
|
+
- [Overview](https://yuzhthu.github.io/SRHarness/)
|
|
85
|
+
- [Quick Start](https://yuzhthu.github.io/SRHarness/quick-start/)
|
|
86
|
+
- [Installation and provider configuration](https://yuzhthu.github.io/SRHarness/install/)
|
|
87
|
+
- [Commands and runtime options](https://yuzhthu.github.io/SRHarness/sr-harness/)
|
|
88
|
+
- [SRHarness Agent Workflow](https://yuzhthu.github.io/SRHarness/agent/)
|
|
89
|
+
- [Tools and tool-call Parsers](https://yuzhthu.github.io/SRHarness/core-abstractions/)
|
|
90
|
+
- [Structured data and `context.data`](https://yuzhthu.github.io/SRHarness/context-data/)
|
|
91
|
+
- [Formula evaluation and custom Evaluators](https://yuzhthu.github.io/SRHarness/evaluator/)
|
|
92
|
+
- [SRHarness WebUI](https://yuzhthu.github.io/SRHarness/web-ui/)
|
|
93
|
+
- [SRHarness Engine](https://yuzhthu.github.io/SRHarness/engine/)
|
|
94
|
+
- [API reference](https://yuzhthu.github.io/SRHarness/reference/)
|
|
95
|
+
|
|
96
|
+
## Citation
|
|
97
|
+
|
|
98
|
+
```bibtex
|
|
99
|
+
@article{yu2026srharness,
|
|
100
|
+
title = {SRHarness: A Harness for Agentic Symbolic Regression},
|
|
101
|
+
author = {Yu, Zihan and Zhou, Shixuan and Huang, Hao and Ding, Jingtao and Li, Yong},
|
|
102
|
+
journal = {arXiv preprint arXiv:2609.35501},
|
|
103
|
+
year = {2026}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
SRHarness is released under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sr-harness"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "SRHarness: a harness for agentic symbolic regression"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 5 - Production/Stable",
|
|
13
|
+
"Intended Audience :: Science/Research",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.12",
|
|
16
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
17
|
+
]
|
|
18
|
+
license = "MIT"
|
|
19
|
+
authors = [
|
|
20
|
+
{name = "YuMeow", email = "yuzh19@tsinghua.org.cn"}
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"numpy>=1.24.0",
|
|
24
|
+
"scipy>=1.10.0",
|
|
25
|
+
"scikit-learn>=1.3.0",
|
|
26
|
+
"sympy>=1.12",
|
|
27
|
+
"pandas>=2.0.0",
|
|
28
|
+
"openpyxl>=3.1.0",
|
|
29
|
+
"joblib>=1.3.0",
|
|
30
|
+
"docstring-parser>=0.16",
|
|
31
|
+
"pyyaml>=6.0",
|
|
32
|
+
"rich>=13.0.0",
|
|
33
|
+
"matplotlib>=3.7.0",
|
|
34
|
+
"openai>=1.0.0",
|
|
35
|
+
"google-genai>=1.0.0",
|
|
36
|
+
"requests>=2.28.0",
|
|
37
|
+
"python-dotenv>=1.0.0",
|
|
38
|
+
"h5py>=3.16.0",
|
|
39
|
+
"datasets>=4.8.0",
|
|
40
|
+
"textual>=1.0.0",
|
|
41
|
+
"prompt_toolkit>=3.0.0",
|
|
42
|
+
"fastapi>=0.115.0",
|
|
43
|
+
"uvicorn>=0.30.0",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.scripts]
|
|
47
|
+
sr-harness = "sr_harness.cli:entrypoint"
|
|
48
|
+
|
|
49
|
+
[project.optional-dependencies]
|
|
50
|
+
nn = [
|
|
51
|
+
"torch>=2.0.0",
|
|
52
|
+
"torch-geometric>=2.4.0",
|
|
53
|
+
]
|
|
54
|
+
tools = [
|
|
55
|
+
"pysr>=1.5.10",
|
|
56
|
+
"pysindy>=2.1.0",
|
|
57
|
+
"pypdf>=5.0.0",
|
|
58
|
+
]
|
|
59
|
+
dev = [
|
|
60
|
+
"pytest>=8.0.0",
|
|
61
|
+
"pytest-cov>=4.0.0",
|
|
62
|
+
"ipynbname>=2025.8.0.0",
|
|
63
|
+
"yumeow_plot>=0.1.2",
|
|
64
|
+
"mkdocs>=1.6",
|
|
65
|
+
"mkdocs-material>=9.5",
|
|
66
|
+
"mkdocstrings[python]>=0.27",
|
|
67
|
+
"mkdocs-static-i18n>=1.3",
|
|
68
|
+
"ruff>=0.8",
|
|
69
|
+
]
|
|
70
|
+
all = [
|
|
71
|
+
"sr-harness[nn,tools,dev]",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
[tool.setuptools.packages.find]
|
|
75
|
+
where = ["src"]
|
|
76
|
+
include = ["sr_harness*", "sr_harness_engine*"]
|
|
77
|
+
|
|
78
|
+
[tool.setuptools.package-data]
|
|
79
|
+
sr_harness = [
|
|
80
|
+
"*.md",
|
|
81
|
+
"*.yaml",
|
|
82
|
+
"**/*.md",
|
|
83
|
+
"**/*.yaml",
|
|
84
|
+
"web/static/*.html",
|
|
85
|
+
"web/static/*.svg",
|
|
86
|
+
]
|
|
87
|
+
sr_harness_engine = ["README.zh.md"]
|
|
88
|
+
|
|
89
|
+
[tool.pytest.ini_options]
|
|
90
|
+
minversion = "7.0"
|
|
91
|
+
testpaths = ["tests"]
|
|
92
|
+
python_files = "test_*.py"
|
|
93
|
+
python_classes = "Test*"
|
|
94
|
+
python_functions = "test_*"
|
|
95
|
+
markers = [
|
|
96
|
+
"slow: marks tests as slow (integration tests)",
|
|
97
|
+
"paid: marks tests as paid API calls (requires credits)",
|
|
98
|
+
]
|
|
99
|
+
addopts = "--quiet -m 'not slow and not paid'"
|
|
100
|
+
|
|
101
|
+
[tool.ruff]
|
|
102
|
+
line-length = 100
|
|
103
|
+
target-version = "py312"
|
|
104
|
+
|
|
105
|
+
[tool.ruff.lint]
|
|
106
|
+
select = ["E", "F", "W"]
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# SRHarness 框架说明
|
|
2
|
+
|
|
3
|
+
> SRHarness 的长篇使用文档和 API Reference:[`docs/index.md`](../../docs/index.md)
|
|
4
|
+
|
|
5
|
+
## SRAgent 整体架构
|
|
6
|
+
|
|
7
|
+
SRAgent 是一个基于 LLM 的符号回归 Agent。其核心是一个 **"请求 LLM → 解析工具调用 → 调用工具 → 格式化消息"** 的循环,循环的 pipeline 由四个参数控制:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
for R in 1..max_restart_loop: # best-solution restart 次数
|
|
11
|
+
for C in 1..global_width: # 独立对话分支数量
|
|
12
|
+
for L in 1..max_refinement_depth: # 每个分支的迭代轮数
|
|
13
|
+
for K in 1..local_sample_size: # 每轮 LLM 重复采样次数
|
|
14
|
+
... (单次迭代)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- **R (Restart)**:外层重启循环。每轮重启会用历史最优结果构建新的初始 prompt,引导 LLM 在已有成果上继续搜索。
|
|
18
|
+
- **C (Conversation branch)**:独立对话分支,每个分支从相同的初始 prompt 出发独立探索。
|
|
19
|
+
- **L (Refinement step)**:单个分支内的对话迭代,每轮包含一次完整的 prompt 构建、LLM 请求、工具调用、buffer 更新。
|
|
20
|
+
- **K (Local sample)**:单次 LLM 请求的重复采样次数,产生多个候选响应,产生最佳结果的响应会被追加到 buffer 中,其余结果中不涉及公式评估的工具调用结果也会被追加到 buffer 中以供后续参考。
|
|
21
|
+
|
|
22
|
+
## SRAgent 核心组件
|
|
23
|
+
|
|
24
|
+
`Agent` 抽象基类负责 API、Parser、共享工具上下文和工具执行机制。
|
|
25
|
+
`DataPreparationAgent` 基于它维护独立、可持续的资料整理对话;`SRAgent` 基于它维护
|
|
26
|
+
R-C-L-K 符号回归搜索,`SRAgentInteractive` 则在同一个搜索循环上增加人工控制和事件。
|
|
27
|
+
这些 Agent 可以共享一个 `AgentContext`,但不会混用各自的对话 Buffer。
|
|
28
|
+
|
|
29
|
+
`AgentContext`:内存中的权威研究上下文。它保存完整结构化数据、目标和自变量、变量
|
|
30
|
+
描述、来源、工作区、当前训练/验证划分以及单调递增的数据版本。工具继续通过 Mapping
|
|
31
|
+
接口读取上下文。数据准备 Agent 只在工作区生成或验证 `context.data/`;`InteractiveSession` 在受控边界加载新版本。运行中的交互式
|
|
32
|
+
SRAgent 只在安全迭代边界刷新划分并把变量变化写入原有对话。
|
|
33
|
+
|
|
34
|
+
SRAgent 在运行时组织以下核心组件:
|
|
35
|
+
|
|
36
|
+
`tools: List[BaseTool]`:可用的工具实例列表。每个工具接收调用参数,返回一个 `ToolCallResult`。
|
|
37
|
+
- 工具的详细开发指南见 [`tools/README.md`](tools/README.md)。
|
|
38
|
+
- 工具的调用流程如下:
|
|
39
|
+
1. 初始化 SRAgent 时,工具被实例化并拿到运行时上下文(数据、目标变量等)。
|
|
40
|
+
2. LLM 产生工具调用(名称 + 参数)
|
|
41
|
+
3. Agent 根据名称在 `tools` 中查找对应工具实例
|
|
42
|
+
4. 调用 `tool(**params)`,返回 `ToolCallResult`(包含 `ok`、`result`、`result_str`、`meta_data`)
|
|
43
|
+
|
|
44
|
+
`api: BaseAPI`:LLM API 实例,负责与 LLM 服务交互。
|
|
45
|
+
- 调用方式如下:
|
|
46
|
+
```python
|
|
47
|
+
llm_result = self.api(messages, n=local_sample_size)
|
|
48
|
+
```
|
|
49
|
+
- `messages` 是对话消息列表,格式为 `[{'role': 'system', 'content': ...}, {'role': 'user', 'content': ...}, ...]`。
|
|
50
|
+
- `llm_result` 是一个 `APICallResult` 对象,可迭代获取 LLM 的响应:
|
|
51
|
+
```python
|
|
52
|
+
for content, tool_calls, message in llm_result:
|
|
53
|
+
# content: LLM 响应中的文字内容
|
|
54
|
+
# tool_calls: 从响应中解析出的工具调用列表 (List[ToolCall])
|
|
55
|
+
# - 文本解析模式 (text/json): 从 content 中解析
|
|
56
|
+
# - OpenAI 模式: 从 message 的 tool_calls 字段直接提取
|
|
57
|
+
# message: 可直接追加到 messages 中以延续对话的消息字典
|
|
58
|
+
```
|
|
59
|
+
- 迭代完成后,`llm_result` 中保留用量统计:
|
|
60
|
+
```python
|
|
61
|
+
llm_result.usage # {'token': {...}, 'price': {...}}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## SRAgent 单次迭代流程
|
|
65
|
+
|
|
66
|
+
每一轮 (L) 的执行步骤如下:
|
|
67
|
+
|
|
68
|
+
1. **构建 Prompt**:根据当前 buffer(对话历史)构建 messages。
|
|
69
|
+
2. **请求 LLM**:调用 `api(messages)`,得到 K 个候选响应。
|
|
70
|
+
3. **执行工具**:解析每个响应中的 tool_calls,查找并调用对应工具,得到结果列表。
|
|
71
|
+
4. **记录搜索节点**:将当前 Prompt、响应、工具结果、父节点关系和用量写入 `SearchRunState`。
|
|
72
|
+
5. **收集候选公式**:验证 `is_candidate=True` 的结果,并按配置的排名指标更新候选集合。
|
|
73
|
+
6. **更新 Buffer**:选择产生最优候选的分支,将其 message 和工具结果追加到 buffer;其它分支中不涉及公式评估的工具结果也会追加,避免丢失有用信息。
|
|
74
|
+
7. **日志与终止检查**:打印当前最优结果、工具调用统计和 token/费用用量,并判断是否结束搜索。
|
|
75
|
+
|
|
76
|
+
## 目录结构
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
src/sr_harness/
|
|
80
|
+
├── agents/
|
|
81
|
+
│ ├── agent.py # Agent 抽象基类与共享工具执行机制
|
|
82
|
+
│ ├── data_preparation_agent.py # 持久化的数据准备 Agent
|
|
83
|
+
│ ├── sr_agent.py # SRAgent 主类,包含 run() 主循环和各个步骤方法
|
|
84
|
+
│ └── sr_agent_interactive.py # 交互式 SRAgent
|
|
85
|
+
├── api/ # BaseAPI 与各 Provider API
|
|
86
|
+
│ ├── base_api.py
|
|
87
|
+
│ └── *_api.py # OpenAI、DeepSeek、Gemini 等实现
|
|
88
|
+
├── core/ # APICallResult、ToolCall 和搜索状态等核心结构
|
|
89
|
+
│ ├── api.py
|
|
90
|
+
│ ├── context.py # AgentContext 共享研究上下文
|
|
91
|
+
│ ├── search.py
|
|
92
|
+
│ └── tool.py
|
|
93
|
+
├── interaction/ # 终端与 Web 交互管理器
|
|
94
|
+
├── runtime/ # 模型路由与交互控制器
|
|
95
|
+
├── parser/ # 工具调用解析器
|
|
96
|
+
│ ├── base_parser.py # BaseParser 基类
|
|
97
|
+
│ ├── *_parser.py # 具体解析器实现 (TextParser, JSONParser, ...)
|
|
98
|
+
├── tools/ # BaseTool 与具体科学工具
|
|
99
|
+
├── skills/ # 运行时技能管理
|
|
100
|
+
├── web/ # Web 服务与会话适配
|
|
101
|
+
└── utils/ # 通用工具函数
|
|
102
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from .agents.agent import Agent
|
|
2
|
+
from .agents.data_preparation_agent import DataPreparationAgent
|
|
3
|
+
from .agents.evaluator_construction_agent import EvaluatorConstructionAgent
|
|
4
|
+
from .agents.sr_agent import SRAgent
|
|
5
|
+
from .agents.sr_agent_interactive import SRAgentInteractive
|
|
6
|
+
from .core import AgentContext, ToolCall
|
|
7
|
+
from .evaluator import DefaultEvaluator, GraphEvaluator, load_custom_evaluator
|
|
8
|
+
from .runtime import InteractionManager, SRInteractionManager
|
|
9
|
+
from . import api
|
|
10
|
+
from . import tools
|
|
11
|
+
from . import utils
|
|
12
|
+
from . import parser
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"Agent",
|
|
16
|
+
"AgentContext",
|
|
17
|
+
"DataPreparationAgent",
|
|
18
|
+
"DefaultEvaluator",
|
|
19
|
+
"EvaluatorConstructionAgent",
|
|
20
|
+
"GraphEvaluator",
|
|
21
|
+
"InteractionManager",
|
|
22
|
+
"SRAgent",
|
|
23
|
+
"SRAgentInteractive",
|
|
24
|
+
"SRInteractionManager",
|
|
25
|
+
"ToolCall",
|
|
26
|
+
"api",
|
|
27
|
+
"load_custom_evaluator",
|
|
28
|
+
"parser",
|
|
29
|
+
"tools",
|
|
30
|
+
"utils",
|
|
31
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
本目录用于存放被 `sr_harness` 私有化的第三方源码。
|
|
2
|
+
|
|
3
|
+
具体而言,sr_harness 需要利用第三方的代码和/或工具,尽管绝大多数工具可以通过 `pip install` 等方式安装,某些代码可能:
|
|
4
|
+
1. 不存在合理的包结构、无法通过常规方式安装;
|
|
5
|
+
2. 需要经过适当修改或包装以适应 SRHarness 的调用;
|
|
6
|
+
我们将这类代码作为 `sr_harness` 的内部实现细节,安装到这一目录中。
|
|
7
|
+
|
|
8
|
+
这一目录中的依赖应使用 `sr_harness._vendor` 作为唯一导入入口,例如:
|
|
9
|
+
```python
|
|
10
|
+
import sr_harness._vendor.vendor_package
|
|
11
|
+
```
|
|
12
|
+
对于可以安装的第三方库,优先使用正常依赖声明和/或 `pip install`,不要将它放入这一目录。
|
|
13
|
+
不要让同一份源码同时支持 `import vendor_package` 和 `import sr_harness._vendor.vendor_package` 两种入口,否则 Python 会把它们加载成两套模块对象,可能导致 `isinstance`、类身份比较、注册表和缓存失效。
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .core import SEDTask, SRResult, Problem
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""
|
|
2
|
+
符号回归算法集合
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
# 算法目录
|
|
9
|
+
ALGORITHMS_DIR = Path(__file__).parent
|
|
10
|
+
|
|
11
|
+
def get_algorithm(name: str):
|
|
12
|
+
"""获取指定算法的 run 函数"""
|
|
13
|
+
module = importlib.import_module(f".{name}", __name__)
|
|
14
|
+
return getattr(module, "run")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def get_update_parser(name: str):
|
|
18
|
+
"""获取指定算法的 update_parser 函数"""
|
|
19
|
+
module = importlib.import_module(f".{name}", __name__)
|
|
20
|
+
return getattr(module, "update_parser", None)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def list_algorithms():
|
|
24
|
+
"""列出所有可用的算法"""
|
|
25
|
+
algorithms = []
|
|
26
|
+
for p in ALGORITHMS_DIR.glob("*.py"):
|
|
27
|
+
if p.stem != "__init__":
|
|
28
|
+
algorithms.append(p.stem)
|
|
29
|
+
for p in ALGORITHMS_DIR.iterdir():
|
|
30
|
+
if p.is_dir() and (p / "__init__.py").exists() and not p.name.startswith("__"):
|
|
31
|
+
algorithms.append(p.name)
|
|
32
|
+
return sorted(algorithms)
|