hyperplane-eval 0.1.2__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.
- hyperplane_eval-0.1.2/LICENSE +176 -0
- hyperplane_eval-0.1.2/MANIFEST.in +6 -0
- hyperplane_eval-0.1.2/PKG-INFO +143 -0
- hyperplane_eval-0.1.2/README.md +109 -0
- hyperplane_eval-0.1.2/adapters/__init__.py +1 -0
- hyperplane_eval-0.1.2/adapters/llms/__init__.py +0 -0
- hyperplane_eval-0.1.2/adapters/llms/llm_client.py +64 -0
- hyperplane_eval-0.1.2/adapters/local_bindings/__init__.py +0 -0
- hyperplane_eval-0.1.2/adapters/local_bindings/executor.py +97 -0
- hyperplane_eval-0.1.2/adapters/local_bindings/scanner.py +124 -0
- hyperplane_eval-0.1.2/adapters/runners/__init__.py +0 -0
- hyperplane_eval-0.1.2/adapters/runners/agent_runner.py +81 -0
- hyperplane_eval-0.1.2/cli/__init__.py +1 -0
- hyperplane_eval-0.1.2/cli/app.py +429 -0
- hyperplane_eval-0.1.2/engine/__init__.py +0 -0
- hyperplane_eval-0.1.2/engine/config.py +20 -0
- hyperplane_eval-0.1.2/engine/domain/__init__.py +3 -0
- hyperplane_eval-0.1.2/engine/domain/dimensions.py +23 -0
- hyperplane_eval-0.1.2/engine/domain/predefined_features.json +327 -0
- hyperplane_eval-0.1.2/engine/domain/vectors/__init__.py +11 -0
- hyperplane_eval-0.1.2/engine/domain/vectors/base.py +16 -0
- hyperplane_eval-0.1.2/engine/domain/vectors/evaluated.py +16 -0
- hyperplane_eval-0.1.2/engine/domain/vectors/executed.py +9 -0
- hyperplane_eval-0.1.2/engine/domain/vectors/synthesized.py +21 -0
- hyperplane_eval-0.1.2/engine/orchestrator.py +193 -0
- hyperplane_eval-0.1.2/engine/plane_evaluator.py +250 -0
- hyperplane_eval-0.1.2/engine/prompt_loader.py +10 -0
- hyperplane_eval-0.1.2/engine/stages/__init__.py +0 -0
- hyperplane_eval-0.1.2/engine/stages/creator.py +406 -0
- hyperplane_eval-0.1.2/engine/stages/evaluator.py +72 -0
- hyperplane_eval-0.1.2/engine/stages/generator.py +327 -0
- hyperplane_eval-0.1.2/engine/stages/input_space.py +133 -0
- hyperplane_eval-0.1.2/engine/stages/navigator.py +187 -0
- hyperplane_eval-0.1.2/hyperplane_eval.egg-info/PKG-INFO +143 -0
- hyperplane_eval-0.1.2/hyperplane_eval.egg-info/SOURCES.txt +58 -0
- hyperplane_eval-0.1.2/hyperplane_eval.egg-info/dependency_links.txt +1 -0
- hyperplane_eval-0.1.2/hyperplane_eval.egg-info/entry_points.txt +2 -0
- hyperplane_eval-0.1.2/hyperplane_eval.egg-info/requires.txt +12 -0
- hyperplane_eval-0.1.2/hyperplane_eval.egg-info/top_level.txt +4 -0
- hyperplane_eval-0.1.2/prompts/stages/creator/anchors_sys.txt +1 -0
- hyperplane_eval-0.1.2/prompts/stages/creator/anchors_user.txt +5 -0
- hyperplane_eval-0.1.2/prompts/stages/creator/brainstorm_sys.txt +1 -0
- hyperplane_eval-0.1.2/prompts/stages/creator/brainstorm_user.txt +3 -0
- hyperplane_eval-0.1.2/prompts/stages/creator/refine_sys.txt +1 -0
- hyperplane_eval-0.1.2/prompts/stages/creator/refine_user.txt +6 -0
- hyperplane_eval-0.1.2/prompts/stages/evaluator/judge.txt +18 -0
- hyperplane_eval-0.1.2/prompts/stages/generator/continue_sys.txt +1 -0
- hyperplane_eval-0.1.2/prompts/stages/generator/continue_user.txt +7 -0
- hyperplane_eval-0.1.2/prompts/stages/generator/copyeditor_sys.txt +14 -0
- hyperplane_eval-0.1.2/prompts/stages/generator/copyeditor_user.txt +3 -0
- hyperplane_eval-0.1.2/prompts/stages/generator/eval_checks_sys.txt +7 -0
- hyperplane_eval-0.1.2/prompts/stages/generator/eval_checks_user.txt +5 -0
- hyperplane_eval-0.1.2/prompts/stages/generator/seed_sys.txt +5 -0
- hyperplane_eval-0.1.2/prompts/stages/generator/seed_user.txt +6 -0
- hyperplane_eval-0.1.2/reporting/__init__.py +0 -0
- hyperplane_eval-0.1.2/reporting/analyser.py +786 -0
- hyperplane_eval-0.1.2/reporting/templates/report_template.html +988 -0
- hyperplane_eval-0.1.2/requirements.txt +12 -0
- hyperplane_eval-0.1.2/setup.cfg +4 -0
- hyperplane_eval-0.1.2/setup.py +36 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hyperplane-eval
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A modular framework for evaluating and verifying agentic LLM outputs.
|
|
5
|
+
Author: Marten Panchev
|
|
6
|
+
Author-email: marten@aquithm.com
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: pydantic>=2.0.0
|
|
14
|
+
Requires-Dist: numpy>=1.24.0
|
|
15
|
+
Requires-Dist: scipy>=1.10.0
|
|
16
|
+
Requires-Dist: litellm>=1.0.0
|
|
17
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
18
|
+
Requires-Dist: pandas>=2.0.0
|
|
19
|
+
Requires-Dist: scikit-learn>=1.2.0
|
|
20
|
+
Requires-Dist: openai>=1.0.0
|
|
21
|
+
Requires-Dist: pyngrok>=7.1.0
|
|
22
|
+
Requires-Dist: rich>=13.0.0
|
|
23
|
+
Requires-Dist: questionary>=2.0.0
|
|
24
|
+
Requires-Dist: PyYAML>=6.0.0
|
|
25
|
+
Dynamic: author
|
|
26
|
+
Dynamic: author-email
|
|
27
|
+
Dynamic: classifier
|
|
28
|
+
Dynamic: description
|
|
29
|
+
Dynamic: description-content-type
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
Dynamic: requires-dist
|
|
32
|
+
Dynamic: requires-python
|
|
33
|
+
Dynamic: summary
|
|
34
|
+
|
|
35
|
+
# Asymptotic Agent Evaluation Framework
|
|
36
|
+
|
|
37
|
+
The **Asymptotic Agent Evaluation Framework** is a Python-based system designed to evaluate AI agents across a global multi-dimensional input space using a linear pipeline architecture. It strategically explores the boundaries of agent reliability to map the "Safe Polytope" of operation.
|
|
38
|
+
|
|
39
|
+
## 🚀 Overview
|
|
40
|
+
|
|
41
|
+
The framework evaluates how AI agents perform as they move through different "dimensions" of complexity (e.g., urgency, ambiguity, complexity). By sampling these dimensions and generating synthetic test cases, the system maps the **Safe Polytope** — the operational volume where an agent's performance is mathematically reliable ($P_{sat} \ge 0.95$).
|
|
42
|
+
|
|
43
|
+
### Key Features
|
|
44
|
+
- **Adaptive Navigation:** Uses Sobol sequences for uniform expansion from stable regions and binary search to pinpoint failure boundaries.
|
|
45
|
+
- **Chain-of-Thought (CoT) Evaluation:** A reasoning-first judge LLM analyzes compliance before scoring, ensuring high-fidelity boundary detection.
|
|
46
|
+
- **Geometric Analysis:** Calculates the hyper-volume of the agent's safe operational space using N-dimensional Convex Hulls.
|
|
47
|
+
- **Persistence:** Automatically saves the evaluation state to JSON after each iteration for crash-resilience.
|
|
48
|
+
- **Linear Pipeline:** Strictly typed state progression from raw coordinates to final performance metrics.
|
|
49
|
+
- **Local Execution:** Evaluates code directly through AST parsing and local binding execution without WebSocket overhead.
|
|
50
|
+
- **Provider Agnostic:** Uses LiteLLM to dynamically connect to any LLM provider (OpenAI, Gemini, vLLM, etc.) via simple API keys.
|
|
51
|
+
|
|
52
|
+
## 🔄 The Linear Pipeline & Iterative Mutation
|
|
53
|
+
|
|
54
|
+
The evaluation framework operates as a streaming loop that systematically explores the boundary of an agent's failure.
|
|
55
|
+
|
|
56
|
+
> [!NOTE]
|
|
57
|
+
> **Algorithm Update:** The framework has transitioned from Zero-Shot Synthesis to the **Iterative Mutation Pipeline** to prevent semantic drift, reduce API overhead, and achieve perfect variable isolation.
|
|
58
|
+
|
|
59
|
+
```mermaid
|
|
60
|
+
graph LR
|
|
61
|
+
A[InputSpace] -->|Origin Prompt| B[Sequential Mutation Engine]
|
|
62
|
+
B -->|Mutated Prompt| C[AgentRunner]
|
|
63
|
+
C -->|Executed Vector| D[AgentOutputEvaluator]
|
|
64
|
+
D -->|Evaluated Vector| E[InputSpace History]
|
|
65
|
+
E -->|Evaluated Vector| F[Adaptive Navigator]
|
|
66
|
+
F -->|Next Coord| B
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### State Transitions (Core Vector Hierarchy)
|
|
70
|
+
The framework uses a strictly typed progression to ensure data integrity:
|
|
71
|
+
1. **ScenarioVector (Stage 1):** Raw N-dimensional mutation coordinates (Urgency, Flooding, Bijection).
|
|
72
|
+
2. **SynthesizedVector (Stage 2):** Origin prompt mutated by the coordinates.
|
|
73
|
+
3. **ExecutedVector (Stage 3):** Mutated prompt run through the target agent (N runs).
|
|
74
|
+
4. **EvaluatedVector (Stage 4):** Performance score ($P_{sat}$) evaluated against the target rubric rule.
|
|
75
|
+
|
|
76
|
+
## 🛠 Technology Stack
|
|
77
|
+
- **Language:** Python 3.11+
|
|
78
|
+
- **Data Modeling:** `pydantic`
|
|
79
|
+
- **Math/Geometry:** `numpy`, `scipy` (Sobol sequences, ConvexHull analysis)
|
|
80
|
+
- **Orchestration:** `asyncio` for parallel scenario generation and execution.
|
|
81
|
+
- **LLM Integration:** `litellm` for universal API connectivity.
|
|
82
|
+
|
|
83
|
+
## 📂 Project Structure
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
├── engine/ # Core Evaluation Logic
|
|
87
|
+
│ ├── domain/ # Vector state hierarchy and Prompt features
|
|
88
|
+
│ ├── stages/ # Pipeline stages (input_space, generator, evaluator, navigator, etc.)
|
|
89
|
+
│ ├── pipeline.py # Central evaluation pipeline orchestrator
|
|
90
|
+
│ └── prompt_loader.py # Utility for loading external LLM prompts
|
|
91
|
+
├── adapters/ # External Interfaces
|
|
92
|
+
│ ├── llms/ # Universal LLM Client (LiteLLM Wrapper)
|
|
93
|
+
│ ├── runners/ # Target agent execution abstractions
|
|
94
|
+
│ └── local_bindings/ # AST scanning and local function execution
|
|
95
|
+
├── cli/ # Interactive CLI Interface
|
|
96
|
+
│ └── app.py # CLI Application and real-time dashboard logic
|
|
97
|
+
├── prompts/ # Externalized LLM prompt templates (.txt)
|
|
98
|
+
├── reporting/ # Results Analysis
|
|
99
|
+
│ └── analyser.py # Report compiler & vulnerability analyser
|
|
100
|
+
├── results/ # Evaluated state & reports
|
|
101
|
+
└── README.md # Project documentation
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 🚦 Getting Started
|
|
105
|
+
|
|
106
|
+
### Prerequisites
|
|
107
|
+
- Python 3.11+
|
|
108
|
+
- Access to an LLM inference server or API Key (e.g., OpenAI, Gemini, or a local vLLM instance)
|
|
109
|
+
|
|
110
|
+
### Setup & Installation
|
|
111
|
+
1. **Environment Setup:**
|
|
112
|
+
```bash
|
|
113
|
+
python3 -m venv .venv
|
|
114
|
+
source .venv/bin/activate
|
|
115
|
+
pip install -r requirements.txt
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
2. **Configuration:**
|
|
119
|
+
The framework has an interactive configuration step built-in. Launch the CLI to pick a target python file, select/enter rules, configure scenarios, and supply your chosen LLM model/API Key.
|
|
120
|
+
|
|
121
|
+
### Running the Evaluation
|
|
122
|
+
Execute the interactive CLI:
|
|
123
|
+
```bash
|
|
124
|
+
PYTHONPATH=. python3 cli/app.py
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The system will:
|
|
128
|
+
1. Prompt you for setup configurations in a CLI Wizard.
|
|
129
|
+
2. Initialize the search space and extract safety dimensions.
|
|
130
|
+
3. Spawn workers to systematically stress-test the agent rules locally.
|
|
131
|
+
4. Render a real-time CLI dashboard with a progress bar and events log.
|
|
132
|
+
5. Save evolving states to `results/` and automatically launch the final HTML results dashboard in your browser.
|
|
133
|
+
|
|
134
|
+
> [!NOTE]
|
|
135
|
+
> The `results/` directory is tracked by Git, but its contents (JSON states, HTML reports, logs) are ignored to keep the repository clean.
|
|
136
|
+
|
|
137
|
+
## 📈 Analysis Results
|
|
138
|
+
The framework outputs a hyper-volume metric (Reliability Coverage) which represents the percentage of the input space where the agent meets the reliability threshold. This allows for direct mathematical comparison between different model versions or system prompts.
|
|
139
|
+
|
|
140
|
+
## 📄 License
|
|
141
|
+
|
|
142
|
+
This project is licensed under the Apache License, Version 2.0.
|
|
143
|
+
See the [LICENSE](LICENSE) file for more information.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Asymptotic Agent Evaluation Framework
|
|
2
|
+
|
|
3
|
+
The **Asymptotic Agent Evaluation Framework** is a Python-based system designed to evaluate AI agents across a global multi-dimensional input space using a linear pipeline architecture. It strategically explores the boundaries of agent reliability to map the "Safe Polytope" of operation.
|
|
4
|
+
|
|
5
|
+
## 🚀 Overview
|
|
6
|
+
|
|
7
|
+
The framework evaluates how AI agents perform as they move through different "dimensions" of complexity (e.g., urgency, ambiguity, complexity). By sampling these dimensions and generating synthetic test cases, the system maps the **Safe Polytope** — the operational volume where an agent's performance is mathematically reliable ($P_{sat} \ge 0.95$).
|
|
8
|
+
|
|
9
|
+
### Key Features
|
|
10
|
+
- **Adaptive Navigation:** Uses Sobol sequences for uniform expansion from stable regions and binary search to pinpoint failure boundaries.
|
|
11
|
+
- **Chain-of-Thought (CoT) Evaluation:** A reasoning-first judge LLM analyzes compliance before scoring, ensuring high-fidelity boundary detection.
|
|
12
|
+
- **Geometric Analysis:** Calculates the hyper-volume of the agent's safe operational space using N-dimensional Convex Hulls.
|
|
13
|
+
- **Persistence:** Automatically saves the evaluation state to JSON after each iteration for crash-resilience.
|
|
14
|
+
- **Linear Pipeline:** Strictly typed state progression from raw coordinates to final performance metrics.
|
|
15
|
+
- **Local Execution:** Evaluates code directly through AST parsing and local binding execution without WebSocket overhead.
|
|
16
|
+
- **Provider Agnostic:** Uses LiteLLM to dynamically connect to any LLM provider (OpenAI, Gemini, vLLM, etc.) via simple API keys.
|
|
17
|
+
|
|
18
|
+
## 🔄 The Linear Pipeline & Iterative Mutation
|
|
19
|
+
|
|
20
|
+
The evaluation framework operates as a streaming loop that systematically explores the boundary of an agent's failure.
|
|
21
|
+
|
|
22
|
+
> [!NOTE]
|
|
23
|
+
> **Algorithm Update:** The framework has transitioned from Zero-Shot Synthesis to the **Iterative Mutation Pipeline** to prevent semantic drift, reduce API overhead, and achieve perfect variable isolation.
|
|
24
|
+
|
|
25
|
+
```mermaid
|
|
26
|
+
graph LR
|
|
27
|
+
A[InputSpace] -->|Origin Prompt| B[Sequential Mutation Engine]
|
|
28
|
+
B -->|Mutated Prompt| C[AgentRunner]
|
|
29
|
+
C -->|Executed Vector| D[AgentOutputEvaluator]
|
|
30
|
+
D -->|Evaluated Vector| E[InputSpace History]
|
|
31
|
+
E -->|Evaluated Vector| F[Adaptive Navigator]
|
|
32
|
+
F -->|Next Coord| B
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### State Transitions (Core Vector Hierarchy)
|
|
36
|
+
The framework uses a strictly typed progression to ensure data integrity:
|
|
37
|
+
1. **ScenarioVector (Stage 1):** Raw N-dimensional mutation coordinates (Urgency, Flooding, Bijection).
|
|
38
|
+
2. **SynthesizedVector (Stage 2):** Origin prompt mutated by the coordinates.
|
|
39
|
+
3. **ExecutedVector (Stage 3):** Mutated prompt run through the target agent (N runs).
|
|
40
|
+
4. **EvaluatedVector (Stage 4):** Performance score ($P_{sat}$) evaluated against the target rubric rule.
|
|
41
|
+
|
|
42
|
+
## 🛠 Technology Stack
|
|
43
|
+
- **Language:** Python 3.11+
|
|
44
|
+
- **Data Modeling:** `pydantic`
|
|
45
|
+
- **Math/Geometry:** `numpy`, `scipy` (Sobol sequences, ConvexHull analysis)
|
|
46
|
+
- **Orchestration:** `asyncio` for parallel scenario generation and execution.
|
|
47
|
+
- **LLM Integration:** `litellm` for universal API connectivity.
|
|
48
|
+
|
|
49
|
+
## 📂 Project Structure
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
├── engine/ # Core Evaluation Logic
|
|
53
|
+
│ ├── domain/ # Vector state hierarchy and Prompt features
|
|
54
|
+
│ ├── stages/ # Pipeline stages (input_space, generator, evaluator, navigator, etc.)
|
|
55
|
+
│ ├── pipeline.py # Central evaluation pipeline orchestrator
|
|
56
|
+
│ └── prompt_loader.py # Utility for loading external LLM prompts
|
|
57
|
+
├── adapters/ # External Interfaces
|
|
58
|
+
│ ├── llms/ # Universal LLM Client (LiteLLM Wrapper)
|
|
59
|
+
│ ├── runners/ # Target agent execution abstractions
|
|
60
|
+
│ └── local_bindings/ # AST scanning and local function execution
|
|
61
|
+
├── cli/ # Interactive CLI Interface
|
|
62
|
+
│ └── app.py # CLI Application and real-time dashboard logic
|
|
63
|
+
├── prompts/ # Externalized LLM prompt templates (.txt)
|
|
64
|
+
├── reporting/ # Results Analysis
|
|
65
|
+
│ └── analyser.py # Report compiler & vulnerability analyser
|
|
66
|
+
├── results/ # Evaluated state & reports
|
|
67
|
+
└── README.md # Project documentation
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 🚦 Getting Started
|
|
71
|
+
|
|
72
|
+
### Prerequisites
|
|
73
|
+
- Python 3.11+
|
|
74
|
+
- Access to an LLM inference server or API Key (e.g., OpenAI, Gemini, or a local vLLM instance)
|
|
75
|
+
|
|
76
|
+
### Setup & Installation
|
|
77
|
+
1. **Environment Setup:**
|
|
78
|
+
```bash
|
|
79
|
+
python3 -m venv .venv
|
|
80
|
+
source .venv/bin/activate
|
|
81
|
+
pip install -r requirements.txt
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
2. **Configuration:**
|
|
85
|
+
The framework has an interactive configuration step built-in. Launch the CLI to pick a target python file, select/enter rules, configure scenarios, and supply your chosen LLM model/API Key.
|
|
86
|
+
|
|
87
|
+
### Running the Evaluation
|
|
88
|
+
Execute the interactive CLI:
|
|
89
|
+
```bash
|
|
90
|
+
PYTHONPATH=. python3 cli/app.py
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The system will:
|
|
94
|
+
1. Prompt you for setup configurations in a CLI Wizard.
|
|
95
|
+
2. Initialize the search space and extract safety dimensions.
|
|
96
|
+
3. Spawn workers to systematically stress-test the agent rules locally.
|
|
97
|
+
4. Render a real-time CLI dashboard with a progress bar and events log.
|
|
98
|
+
5. Save evolving states to `results/` and automatically launch the final HTML results dashboard in your browser.
|
|
99
|
+
|
|
100
|
+
> [!NOTE]
|
|
101
|
+
> The `results/` directory is tracked by Git, but its contents (JSON states, HTML reports, logs) are ignored to keep the repository clean.
|
|
102
|
+
|
|
103
|
+
## 📈 Analysis Results
|
|
104
|
+
The framework outputs a hyper-volume metric (Reliability Coverage) which represents the percentage of the input space where the agent meets the reliability threshold. This allows for direct mathematical comparison between different model versions or system prompts.
|
|
105
|
+
|
|
106
|
+
## 📄 License
|
|
107
|
+
|
|
108
|
+
This project is licensed under the Apache License, Version 2.0.
|
|
109
|
+
See the [LICENSE](LICENSE) file for more information.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Infrastructure adapters for the evaluation framework."""
|
|
File without changes
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
import re
|
|
4
|
+
import asyncio
|
|
5
|
+
from typing import Any, Dict
|
|
6
|
+
from litellm import acompletion
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class LLMClient:
|
|
10
|
+
"""
|
|
11
|
+
A unified LLM client using LiteLLM to support multiple providers (OpenAI, Gemini, Anthropic, etc).
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, model: str | None = None, **kwargs):
|
|
15
|
+
# LiteLLM accepts strings like "gpt-4o", "gemini/gemini-1.5-flash", "anthropic/claude-3-5-sonnet"
|
|
16
|
+
self.model = model or os.environ.get("LLM_MODEL", "gpt-4o")
|
|
17
|
+
self.llm_kwargs = kwargs
|
|
18
|
+
self._semaphore = asyncio.Semaphore(10)
|
|
19
|
+
|
|
20
|
+
def parse_json(self, response: str) -> Dict[str, Any]:
|
|
21
|
+
if not (text := (response or "").strip()):
|
|
22
|
+
return {}
|
|
23
|
+
candidates = [text]
|
|
24
|
+
if match := re.search(r"```(?:json)?\s*(.*?)\s*```", text, re.DOTALL):
|
|
25
|
+
candidates.insert(0, match.group(1))
|
|
26
|
+
start, end = text.find("{"), text.rfind("}")
|
|
27
|
+
if start != -1 and end != -1 and end > start:
|
|
28
|
+
candidates.extend([text[start : end + 1], text[start:]])
|
|
29
|
+
for cand in filter(None, candidates):
|
|
30
|
+
try:
|
|
31
|
+
return json.loads(cand, strict=False)
|
|
32
|
+
except Exception:
|
|
33
|
+
pass
|
|
34
|
+
return {}
|
|
35
|
+
|
|
36
|
+
async def generate(
|
|
37
|
+
self,
|
|
38
|
+
prompt: str,
|
|
39
|
+
response_schema: Dict[str, Any],
|
|
40
|
+
temperature: float,
|
|
41
|
+
) -> str:
|
|
42
|
+
if response_schema:
|
|
43
|
+
prompt += f"\n\nYOU MUST RETURN A JSON OBJECT WITH THE EXACT FOLLOWING SCHEMA:\n{json.dumps(response_schema, indent=2)}"
|
|
44
|
+
|
|
45
|
+
kwargs = {
|
|
46
|
+
"model": self.model, # Force using the user-selected model
|
|
47
|
+
"messages": [{"role": "user", "content": prompt}],
|
|
48
|
+
"temperature": temperature,
|
|
49
|
+
**self.llm_kwargs,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if response_schema:
|
|
53
|
+
kwargs["response_format"] = {"type": "json_object"}
|
|
54
|
+
|
|
55
|
+
async with self._semaphore:
|
|
56
|
+
try:
|
|
57
|
+
response = await acompletion(**kwargs)
|
|
58
|
+
return response.choices[0].message.content
|
|
59
|
+
except Exception as e:
|
|
60
|
+
print(f"[LiteLLM] Error HTTP: {e}")
|
|
61
|
+
raise RuntimeError(f"LLM Server Error: {e}")
|
|
62
|
+
|
|
63
|
+
async def close(self) -> None:
|
|
64
|
+
pass
|
|
File without changes
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
import subprocess
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
async def execute_temp_runner(target_path: str, selected_func: dict, params: dict):
|
|
7
|
+
target_dir = os.path.dirname(os.path.abspath(target_path))
|
|
8
|
+
target_basename = os.path.basename(target_path)
|
|
9
|
+
module_name, ext = os.path.splitext(target_basename)
|
|
10
|
+
is_python = ext == ".py"
|
|
11
|
+
is_ts = ext == ".ts"
|
|
12
|
+
|
|
13
|
+
params_json_str = json.dumps(params)
|
|
14
|
+
|
|
15
|
+
if is_python:
|
|
16
|
+
python_script = f"""
|
|
17
|
+
import sys, json, asyncio, inspect, importlib
|
|
18
|
+
sys.path.insert(0, r"{target_dir}")
|
|
19
|
+
try:
|
|
20
|
+
target_func = getattr(importlib.import_module("{module_name}"), "{selected_func['name']}")
|
|
21
|
+
except Exception as e:
|
|
22
|
+
print("VERIFY_RUN_ERROR:Load fail: " + str(e))
|
|
23
|
+
sys.exit(1)
|
|
24
|
+
|
|
25
|
+
params = json.loads(sys.argv[1])
|
|
26
|
+
casted = {{}}
|
|
27
|
+
for name, param in inspect.signature(target_func).parameters.items():
|
|
28
|
+
if name in params: casted[name] = params[name]
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
res = target_func(**casted)
|
|
32
|
+
if inspect.iscoroutine(res): res = asyncio.run(res)
|
|
33
|
+
print("VERIFY_RUN_SUCCESS:" + json.dumps(res))
|
|
34
|
+
except Exception as e:
|
|
35
|
+
import traceback
|
|
36
|
+
print("VERIFY_RUN_ERROR:" + str(e) + "\\n" + traceback.format_exc())
|
|
37
|
+
"""
|
|
38
|
+
cmd = ["python3", "-c", python_script, params_json_str]
|
|
39
|
+
else:
|
|
40
|
+
params_array_str = json.dumps(selected_func["params"])
|
|
41
|
+
# Handle both ES modules and CommonJS
|
|
42
|
+
# For inline evaluation, we'll try to import dynamically
|
|
43
|
+
ts_script = f"""
|
|
44
|
+
async function main() {{
|
|
45
|
+
try {{
|
|
46
|
+
const moduleName = './{module_name}{ext}';
|
|
47
|
+
let mod;
|
|
48
|
+
try {{
|
|
49
|
+
mod = await import(moduleName);
|
|
50
|
+
}} catch(e) {{
|
|
51
|
+
mod = require(moduleName);
|
|
52
|
+
}}
|
|
53
|
+
const func = mod.{selected_func['name']};
|
|
54
|
+
if (!func) throw new Error("Function {selected_func['name']} not found in module.");
|
|
55
|
+
|
|
56
|
+
const params = JSON.parse(process.argv[1]);
|
|
57
|
+
const funcParams = {params_array_str};
|
|
58
|
+
const args = funcParams.map(p => params[p.name]);
|
|
59
|
+
|
|
60
|
+
let res = func(...args);
|
|
61
|
+
if (res instanceof Promise) res = await res;
|
|
62
|
+
console.log("VERIFY_RUN_SUCCESS:" + JSON.stringify(res));
|
|
63
|
+
}} catch (err) {{
|
|
64
|
+
console.log("VERIFY_RUN_ERROR:" + (err.stack || err.message));
|
|
65
|
+
}}
|
|
66
|
+
}}
|
|
67
|
+
main();
|
|
68
|
+
"""
|
|
69
|
+
if is_ts:
|
|
70
|
+
cmd = ["npx", "-y", "tsx", "--eval", ts_script, params_json_str]
|
|
71
|
+
else:
|
|
72
|
+
cmd = ["node", "-e", ts_script, params_json_str]
|
|
73
|
+
|
|
74
|
+
res = subprocess.run(cmd, cwd=target_dir, capture_output=True, text=True)
|
|
75
|
+
output = res.stdout
|
|
76
|
+
stderr = res.stderr
|
|
77
|
+
|
|
78
|
+
success_val = ""
|
|
79
|
+
error_val = ""
|
|
80
|
+
for line in output.splitlines():
|
|
81
|
+
if line.startswith("VERIFY_RUN_SUCCESS:"):
|
|
82
|
+
success_val = line[19:]
|
|
83
|
+
elif line.startswith("VERIFY_RUN_ERROR:"):
|
|
84
|
+
error_val = line[17:]
|
|
85
|
+
|
|
86
|
+
if not success_val and not error_val:
|
|
87
|
+
if stderr:
|
|
88
|
+
error_val = f"System Error (stderr): {stderr.strip()}"
|
|
89
|
+
else:
|
|
90
|
+
error_val = f"Empty execution result. Output: {output.strip()}"
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
"successVal": success_val,
|
|
94
|
+
"errorVal": error_val,
|
|
95
|
+
"output": output,
|
|
96
|
+
"stderr": stderr,
|
|
97
|
+
}
|