monocle-test-tools 0.6.6__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.
Files changed (33) hide show
  1. monocle_test_tools-0.6.6/.gitignore +22 -0
  2. monocle_test_tools-0.6.6/LICENSE +51 -0
  3. monocle_test_tools-0.6.6/PKG-INFO +143 -0
  4. monocle_test_tools-0.6.6/README.md +97 -0
  5. monocle_test_tools-0.6.6/pyproject.toml +205 -0
  6. monocle_test_tools-0.6.6/src/monocle_test_tools/__init__.py +43 -0
  7. monocle_test_tools-0.6.6/src/monocle_test_tools/comparer/__init__.py +18 -0
  8. monocle_test_tools-0.6.6/src/monocle_test_tools/comparer/base_comparer.py +10 -0
  9. monocle_test_tools-0.6.6/src/monocle_test_tools/comparer/bert_score_comparer.py +50 -0
  10. monocle_test_tools-0.6.6/src/monocle_test_tools/comparer/comparer_manager.py +29 -0
  11. monocle_test_tools-0.6.6/src/monocle_test_tools/comparer/default_comparer.py +9 -0
  12. monocle_test_tools-0.6.6/src/monocle_test_tools/comparer/metric_comparer.py +14 -0
  13. monocle_test_tools-0.6.6/src/monocle_test_tools/comparer/sentense_comparer.py +81 -0
  14. monocle_test_tools-0.6.6/src/monocle_test_tools/evals/__init__.py +16 -0
  15. monocle_test_tools-0.6.6/src/monocle_test_tools/evals/base_eval.py +9 -0
  16. monocle_test_tools-0.6.6/src/monocle_test_tools/evals/bert_eval.py +31 -0
  17. monocle_test_tools-0.6.6/src/monocle_test_tools/evals/eval_manager.py +16 -0
  18. monocle_test_tools-0.6.6/src/monocle_test_tools/runner/__init__.py +5 -0
  19. monocle_test_tools-0.6.6/src/monocle_test_tools/runner/adk_runner.py +43 -0
  20. monocle_test_tools-0.6.6/src/monocle_test_tools/runner/agent_runner.py +12 -0
  21. monocle_test_tools-0.6.6/src/monocle_test_tools/runner/lg_runner.py +37 -0
  22. monocle_test_tools-0.6.6/src/monocle_test_tools/runner/openai_runner.py +13 -0
  23. monocle_test_tools-0.6.6/src/monocle_test_tools/runner/runner.py +20 -0
  24. monocle_test_tools-0.6.6/src/monocle_test_tools/schema.py +172 -0
  25. monocle_test_tools-0.6.6/src/monocle_test_tools/trace_utils.py +45 -0
  26. monocle_test_tools-0.6.6/src/monocle_test_tools/validator.py +639 -0
  27. monocle_test_tools-0.6.6/tests/__init__.py +0 -0
  28. monocle_test_tools-0.6.6/tests/integration/__init__.py +10 -0
  29. monocle_test_tools-0.6.6/tests/integration/test_adk_travel_agent.py +55 -0
  30. monocle_test_tools-0.6.6/tests/integration/test_tool_mock.py +38 -0
  31. monocle_test_tools-0.6.6/tests/test_common/adk_travel_agent.py +80 -0
  32. monocle_test_tools-0.6.6/tests/unit/span_loader.py +153 -0
  33. monocle_test_tools-0.6.6/tests/unit/test_validator.py +73 -0
@@ -0,0 +1,22 @@
1
+ # Python
2
+ *~
3
+ *.log
4
+ *.pyc
5
+ *.pyo
6
+ *.pyt
7
+ *.pytc
8
+ *.egg-info
9
+ .*.swp
10
+ storage
11
+ traces.txt
12
+ dist
13
+ .tox
14
+ .DS_Store
15
+ Pipfile**
16
+ launch.json
17
+ monocle_trace**.json
18
+
19
+ # Ignore LICENSE files in specific subdirectories
20
+ apptrace/LICENSE
21
+ mcp/LICENSE
22
+ test_tools/LICENSE
@@ -0,0 +1,51 @@
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, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
37
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
38
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
39
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
40
+
41
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
42
+
43
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
44
+
45
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
46
+
47
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
48
+
49
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
50
+
51
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: monocle_test_tools
3
+ Version: 0.6.6
4
+ Summary: Testing and validation framework for monocle AI agent tracing
5
+ Project-URL: Homepage, https://github.com/monocle2ai/monocle
6
+ Project-URL: Issues, https://github.com/monocle2ai/monocle/issues
7
+ Project-URL: Repository, https://github.com/monocle2ai/monocle
8
+ Project-URL: Documentation, http://monocle2ai.org
9
+ Author-email: "Okahu Inc." <okahu-pypi@okahu.ai>
10
+ License: Apache-2.0
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Requires-Python: >=3.8
19
+ Requires-Dist: bert-score>=0.3.0
20
+ Requires-Dist: jsonschema>=4.0.0
21
+ Requires-Dist: monocle-apptrace>=0.5.0
22
+ Requires-Dist: pydantic>=2.11.7
23
+ Requires-Dist: pytest-asyncio>=0.26.0
24
+ Requires-Dist: pytest>=8.0.0
25
+ Requires-Dist: sentence-transformers==3.3.0
26
+ Requires-Dist: transformers>=4.0.0
27
+ Provides-Extra: all
28
+ Requires-Dist: black>=23.0.0; extra == 'all'
29
+ Requires-Dist: flake8>=6.0.0; extra == 'all'
30
+ Requires-Dist: google-adk==1.10.0; extra == 'all'
31
+ Requires-Dist: google-generativeai==0.8.5; extra == 'all'
32
+ Requires-Dist: mypy>=1.0.0; extra == 'all'
33
+ Requires-Dist: openai-agents==0.2.6; extra == 'all'
34
+ Requires-Dist: pre-commit>=3.0.0; extra == 'all'
35
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'all'
36
+ Provides-Extra: dev
37
+ Requires-Dist: black>=23.0.0; extra == 'dev'
38
+ Requires-Dist: flake8>=6.0.0; extra == 'dev'
39
+ Requires-Dist: google-adk==1.10.0; extra == 'dev'
40
+ Requires-Dist: google-generativeai==0.8.5; extra == 'dev'
41
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
42
+ Requires-Dist: openai-agents==0.2.6; extra == 'dev'
43
+ Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
44
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
45
+ Description-Content-Type: text/markdown
46
+
47
+ # Monocle Test Tools
48
+
49
+ A comprehensive testing and validation framework for monocle AI agent tracing. This package provides tools for validating agent behavior, tool invocations, inference responses, and overall AI system performance.
50
+
51
+ ## Features
52
+
53
+ - **Agentic Response**: Verify that agent request got the appropreate response.
54
+ - **Agent Invocation**: Verify that specific agents are invoked and delegate tasks correctly.
55
+ - **Tool Validation**: Ensure tools are called with expected inputs and produce expected outputs
56
+ - **Inference Testing**: Test model inference responses against expected schemas or content
57
+ - **Cost/Performance/Quality**: Verify token usage, error states, warnings
58
+ - **Evaluation**: Integrate with any third party or custom evaluation tools to validate LLM responses
59
+
60
+ ## How does it work
61
+ The test tool runs your agent or workflow code with Monocle instrumentation enabled. It examines the traces generated by the genAI components used in your code (eg Google ADK, LangGraph etc) and verifies the test conditions you want to validated.
62
+
63
+ ## Installation
64
+
65
+ ```bash
66
+ pip install monocle_test_tools
67
+ ```
68
+
69
+ ## Quick Start
70
+ Here's a test that executes a ```root_travel_agent``` with a few inputs and validates it's response and tools invoked.
71
+ ```python
72
+ from monocle_test_tools import TestCase, MonocleValidator
73
+ from adk_travel_agent import root_travel_agent
74
+
75
+ # Test cases for testing travel booking agent
76
+ agent_test_cases:list[TestCase] = [
77
+ {
78
+ "test_input": ["Book a flight from San Francisco to Mumbai for 26th Nov 2025. Book a two queen room at Marriot Intercontinental at Juhu, Mumbai for 27th Nov 2025 for 4 nights."],
79
+ "test_output": "A flight from San Francisco to Mumbai has been booked, along with a four night stay in a two queen room at the Marriot Intercontinental in Juhu, Mumbai, starting November 27th, 2025.",
80
+ "comparer": "similarity",
81
+ },
82
+ {
83
+ "test_input": ["Book a flight from San Francisco to Mumbai for 26th Nov 2025. Book a two queen room at Marriot Intercontinental at Juhu, Mumbai for 27th Nov 2025 for 4 nights."],
84
+ "test_spans": [
85
+ {
86
+ "span_type": "agentic.tool.invocation",
87
+ "entities": [
88
+ {"type": "tool", "name": "adk_book_hotel"},
89
+ {"type": "agent", "name": "adk_hotel_booking_agent"}
90
+ ],
91
+ }
92
+ ]
93
+ }
94
+ ]
95
+
96
+ # Run test cases using Monocle test framework
97
+ @MonocleValidator().monocle_testcase(agent_test_cases)
98
+ async def test_run_workflows(my_test_case: TestCase):
99
+ await MonocleValidator().test_workflow_async(root_travel_agent, my_test_case)
100
+
101
+ if __name__ == "__main__":
102
+ pytest.main([__file__])
103
+
104
+ ```
105
+
106
+ ## Test format
107
+ ### Testcase
108
+ A TestCase defines the input, expected output, and evaluation criteria for testing
109
+ AI agent behaviors. It can contain multiple test spans representing different
110
+ interaction points (tool invocations, agent delegations, etc.) within the test.
111
+
112
+ Each test case can specify comparison methods for evaluating test results against
113
+ expected outcomes and can be configured to expect certain errors or warnings.
114
+ ```json
115
+ {
116
+ "test_input": "Input data provided to the test case, can be a prompt or structured data.",
117
+ "test_output": "Expected output that the test should produce.",
118
+ "comparer": "Method used to compare actual results with expected results. The default comparer is does exact match. The 'similarty' comparer does a fuzzy match using bert score",
119
+ "test_spans": "Array of TestSpan objects defining specific interactions to test."
120
+ }
121
+ ```
122
+ ### TestSpan
123
+ Represents a specific interaction or event within a test case in the Monocle testing framework.
124
+
125
+ A TestSpan defines a single testable unit of interaction such as a tool invocation,
126
+ agent delegation, or inference process. Each span captures the entities involved,
127
+ inputs and outputs, and validation criteria for that specific interaction.
128
+
129
+ Test spans enforce specific validation rules based on their type. For example:
130
+ - Tool invocation spans must include at least one tool entity
131
+ - Agentic delegation spans must include at least two agent entities (delegator and delegatee)
132
+ - Agentic invocation spans must include at least one agent entity
133
+
134
+ ```json
135
+ "span_type": "Type of interaction this span represents (e.g., tool invocation, agent delegation)"
136
+ "entities": "List of entities (tools, agents) involved in this interaction. Each entity has two attributes, name and type. The type can be 'tool' or 'agent' or 'inference'"
137
+ "input": "Input provided to this interaction"
138
+ "output": "Expected output from this interaction"
139
+ "test_type": "Whether this is a 'positive' (expected to succeed) or 'negative' (expected to fail) test"
140
+ ```
141
+ Check out these [examples](tests/integration/test_adk_travel_agent.py) of test cases.
142
+
143
+ .
@@ -0,0 +1,97 @@
1
+ # Monocle Test Tools
2
+
3
+ A comprehensive testing and validation framework for monocle AI agent tracing. This package provides tools for validating agent behavior, tool invocations, inference responses, and overall AI system performance.
4
+
5
+ ## Features
6
+
7
+ - **Agentic Response**: Verify that agent request got the appropreate response.
8
+ - **Agent Invocation**: Verify that specific agents are invoked and delegate tasks correctly.
9
+ - **Tool Validation**: Ensure tools are called with expected inputs and produce expected outputs
10
+ - **Inference Testing**: Test model inference responses against expected schemas or content
11
+ - **Cost/Performance/Quality**: Verify token usage, error states, warnings
12
+ - **Evaluation**: Integrate with any third party or custom evaluation tools to validate LLM responses
13
+
14
+ ## How does it work
15
+ The test tool runs your agent or workflow code with Monocle instrumentation enabled. It examines the traces generated by the genAI components used in your code (eg Google ADK, LangGraph etc) and verifies the test conditions you want to validated.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install monocle_test_tools
21
+ ```
22
+
23
+ ## Quick Start
24
+ Here's a test that executes a ```root_travel_agent``` with a few inputs and validates it's response and tools invoked.
25
+ ```python
26
+ from monocle_test_tools import TestCase, MonocleValidator
27
+ from adk_travel_agent import root_travel_agent
28
+
29
+ # Test cases for testing travel booking agent
30
+ agent_test_cases:list[TestCase] = [
31
+ {
32
+ "test_input": ["Book a flight from San Francisco to Mumbai for 26th Nov 2025. Book a two queen room at Marriot Intercontinental at Juhu, Mumbai for 27th Nov 2025 for 4 nights."],
33
+ "test_output": "A flight from San Francisco to Mumbai has been booked, along with a four night stay in a two queen room at the Marriot Intercontinental in Juhu, Mumbai, starting November 27th, 2025.",
34
+ "comparer": "similarity",
35
+ },
36
+ {
37
+ "test_input": ["Book a flight from San Francisco to Mumbai for 26th Nov 2025. Book a two queen room at Marriot Intercontinental at Juhu, Mumbai for 27th Nov 2025 for 4 nights."],
38
+ "test_spans": [
39
+ {
40
+ "span_type": "agentic.tool.invocation",
41
+ "entities": [
42
+ {"type": "tool", "name": "adk_book_hotel"},
43
+ {"type": "agent", "name": "adk_hotel_booking_agent"}
44
+ ],
45
+ }
46
+ ]
47
+ }
48
+ ]
49
+
50
+ # Run test cases using Monocle test framework
51
+ @MonocleValidator().monocle_testcase(agent_test_cases)
52
+ async def test_run_workflows(my_test_case: TestCase):
53
+ await MonocleValidator().test_workflow_async(root_travel_agent, my_test_case)
54
+
55
+ if __name__ == "__main__":
56
+ pytest.main([__file__])
57
+
58
+ ```
59
+
60
+ ## Test format
61
+ ### Testcase
62
+ A TestCase defines the input, expected output, and evaluation criteria for testing
63
+ AI agent behaviors. It can contain multiple test spans representing different
64
+ interaction points (tool invocations, agent delegations, etc.) within the test.
65
+
66
+ Each test case can specify comparison methods for evaluating test results against
67
+ expected outcomes and can be configured to expect certain errors or warnings.
68
+ ```json
69
+ {
70
+ "test_input": "Input data provided to the test case, can be a prompt or structured data.",
71
+ "test_output": "Expected output that the test should produce.",
72
+ "comparer": "Method used to compare actual results with expected results. The default comparer is does exact match. The 'similarty' comparer does a fuzzy match using bert score",
73
+ "test_spans": "Array of TestSpan objects defining specific interactions to test."
74
+ }
75
+ ```
76
+ ### TestSpan
77
+ Represents a specific interaction or event within a test case in the Monocle testing framework.
78
+
79
+ A TestSpan defines a single testable unit of interaction such as a tool invocation,
80
+ agent delegation, or inference process. Each span captures the entities involved,
81
+ inputs and outputs, and validation criteria for that specific interaction.
82
+
83
+ Test spans enforce specific validation rules based on their type. For example:
84
+ - Tool invocation spans must include at least one tool entity
85
+ - Agentic delegation spans must include at least two agent entities (delegator and delegatee)
86
+ - Agentic invocation spans must include at least one agent entity
87
+
88
+ ```json
89
+ "span_type": "Type of interaction this span represents (e.g., tool invocation, agent delegation)"
90
+ "entities": "List of entities (tools, agents) involved in this interaction. Each entity has two attributes, name and type. The type can be 'tool' or 'agent' or 'inference'"
91
+ "input": "Input provided to this interaction"
92
+ "output": "Expected output from this interaction"
93
+ "test_type": "Whether this is a 'positive' (expected to succeed) or 'negative' (expected to fail) test"
94
+ ```
95
+ Check out these [examples](tests/integration/test_adk_travel_agent.py) of test cases.
96
+
97
+ .
@@ -0,0 +1,205 @@
1
+ [build-system]
2
+ requires = ["hatchling","hatch-build-scripts"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [[tool.hatch.build.hooks.build-scripts.scripts]]
6
+ commands = [
7
+ "echo 'Running a pre-build step..copying license'",
8
+ "if [ -f \"LICENSE\" ]; then echo \"✅ LICENSE already exists\"; elif [ -f \"../LICENSE\" ]; then cp \"../LICENSE\" \"LICENSE\" && echo \"✅ LICENSE copied from parent\"; else echo \"❌ ERROR: LICENSE not found\" && exit 1; fi"
9
+ ]
10
+
11
+ [project]
12
+ name = "monocle_test_tools"
13
+ version = "0.6.6"
14
+ authors = [
15
+ { name="Okahu Inc.", email="okahu-pypi@okahu.ai" },
16
+ ]
17
+ description = "Testing and validation framework for monocle AI agent tracing"
18
+ readme = "README.md"
19
+ requires-python = ">=3.8"
20
+ license = {text = "Apache-2.0"}
21
+ classifiers = [
22
+ "Programming Language :: Python :: 3",
23
+ "License :: OSI Approved :: Apache Software License",
24
+ "Operating System :: OS Independent",
25
+ "Development Status :: 3 - Alpha",
26
+ "Intended Audience :: Developers",
27
+ "Topic :: Software Development :: Testing",
28
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
29
+ ]
30
+
31
+ dependencies = [
32
+ # Core dependencies
33
+ "pytest>=8.0.0",
34
+ "pytest-asyncio>=0.26.0",
35
+ "pydantic>=2.11.7",
36
+ "jsonschema>=4.0.0",
37
+
38
+ # Monocle dependencies
39
+ "monocle_apptrace>=0.5.0",
40
+
41
+ # Evaluation dependencies
42
+ "bert-score>=0.3.0",
43
+ "transformers>=4.0.0",
44
+ "sentence-transformers==3.3.0"
45
+ ]
46
+
47
+ [project.optional-dependencies]
48
+ dev = [
49
+ "pytest-cov>=4.0.0",
50
+ "black>=23.0.0",
51
+ "flake8>=6.0.0",
52
+ "mypy>=1.0.0",
53
+ "pre-commit>=3.0.0",
54
+ 'google-adk==1.10.0',
55
+ 'google-generativeai==0.8.5',
56
+ 'openai-agents==0.2.6'
57
+ ]
58
+
59
+ all = [
60
+ "monocle_test_tools[dev]",
61
+ ]
62
+
63
+ [project.urls]
64
+ Homepage = "https://github.com/monocle2ai/monocle"
65
+ Issues = "https://github.com/monocle2ai/monocle/issues"
66
+ Repository = "https://github.com/monocle2ai/monocle"
67
+ Documentation = "http://monocle2ai.org"
68
+
69
+ [tool.hatch.build.targets.wheel]
70
+ packages = ["src/monocle_test_tools"]
71
+
72
+ [tool.hatch.build.targets.sdist]
73
+ include = [
74
+ "pyproject.toml",
75
+ "README.md",
76
+ "LICENSE",
77
+ "src/**",
78
+ "tests/**/*.py",
79
+ ]
80
+
81
+ [tool.hatch.build]
82
+ exclude = [
83
+ "/__pycache__",
84
+ "*.pyc",
85
+ "*.pyo",
86
+ "*.pyd",
87
+ ".git",
88
+ ".pytest_cache",
89
+ ".mypy_cache",
90
+ ".coverage",
91
+ ]
92
+
93
+ [tool.pytest.ini_options]
94
+ testpaths = ["test_tools"]
95
+ python_files = ["test_*.py", "*_test.py"]
96
+ python_classes = ["Test*"]
97
+ python_functions = ["test_*"]
98
+ addopts = [
99
+ "--strict-markers",
100
+ "--strict-config",
101
+ "--verbose",
102
+ ]
103
+ log_cli = true
104
+ log_cli_level = "INFO"
105
+ log_cli_format = "%(asctime)s [%(levelname)8s] %(name)s: %(message)s"
106
+ log_cli_date_format = "%Y-%m-%d %H:%M:%S"
107
+ pythonpath = ["src", "tests", "../apptrace/src"]
108
+
109
+ markers = [
110
+ "unit: marks tests as unit tests",
111
+ "integration: marks tests as integration tests",
112
+ "slow: marks tests as slow",
113
+ "agent: marks tests as agent-related tests",
114
+ "tool: marks tests as tool-related tests",
115
+ "inference: marks tests as inference-related tests",
116
+ ]
117
+
118
+ [tool.black]
119
+ line-length = 120
120
+ target-version = ['py38', 'py39', 'py310', 'py311']
121
+ include = '\.pyi?$'
122
+ extend-exclude = '''
123
+ /(
124
+ # directories
125
+ \.eggs
126
+ | \.git
127
+ | \.hg
128
+ | \.mypy_cache
129
+ | \.pytest_cache
130
+ | \.tox
131
+ | \.venv
132
+ | build
133
+ | dist
134
+ )/
135
+ '''
136
+
137
+ [tool.mypy]
138
+ python_version = "3.8"
139
+ warn_return_any = true
140
+ warn_unused_configs = true
141
+ disallow_untyped_defs = true
142
+ disallow_incomplete_defs = true
143
+ check_untyped_defs = true
144
+ disallow_untyped_decorators = true
145
+ no_implicit_optional = true
146
+ warn_redundant_casts = true
147
+ warn_unused_ignores = true
148
+ warn_no_return = true
149
+ warn_unreachable = true
150
+ strict_equality = true
151
+
152
+ [[tool.mypy.overrides]]
153
+ module = [
154
+ "bert_score.*",
155
+ "transformers.*",
156
+ "opentelemetry.*",
157
+ "monocle_apptrace.*",
158
+ ]
159
+ ignore_missing_imports = true
160
+
161
+ [tool.coverage.run]
162
+ source = ["test_tools"]
163
+ omit = [
164
+ "*/tests/*",
165
+ "*/__pycache__/*",
166
+ "*/site-packages/*",
167
+ ]
168
+
169
+ [tool.coverage.report]
170
+ exclude_lines = [
171
+ "pragma: no cover",
172
+ "def __repr__",
173
+ "if self.debug:",
174
+ "if settings.DEBUG",
175
+ "raise AssertionError",
176
+ "raise NotImplementedError",
177
+ "if 0:",
178
+ "if __name__ == .__main__.:",
179
+ "class .*\\bProtocol\\):",
180
+ "@(abc\\.)?abstractmethod",
181
+ ]
182
+
183
+ [tool.ruff]
184
+ target-version = "py38"
185
+ line-length = 120
186
+ select = [
187
+ "E", # pycodestyle errors
188
+ "W", # pycodestyle warnings
189
+ "F", # pyflakes
190
+ "I", # isort
191
+ "B", # flake8-bugbear
192
+ "C4", # flake8-comprehensions
193
+ "UP", # pyupgrade
194
+ ]
195
+ ignore = [
196
+ "E501", # line too long, handled by black
197
+ "B008", # do not perform function calls in argument defaults
198
+ "C901", # too complex
199
+ ]
200
+
201
+ [tool.ruff.per-file-ignores]
202
+ "__init__.py" = ["F401"]
203
+
204
+ [tool.ruff.isort]
205
+ known-first-party = ["monocle_test_tools", "monocle_apptrace"]
@@ -0,0 +1,43 @@
1
+ """
2
+ Test tools for monocle AI agent validation.
3
+
4
+ This module provides classes and utilities for testing and validating AI agent behavior,
5
+ including agent invocations, tool usage, and response evaluation.
6
+ """
7
+
8
+ from .validator import (
9
+ MonocleValidator
10
+ )
11
+
12
+ from .schema import (
13
+ TestCase,
14
+ TestSpan,
15
+ Entity,
16
+ EntityType,
17
+ SpanType,
18
+ Evaluation,
19
+ MockTool,
20
+ ToolType
21
+ )
22
+
23
+ from .evals import ( BaseEval, BertScorerEval)
24
+ from .comparer import ( BaseComparer, BertScoreComparer, DefaultComparer)
25
+ from . import trace_utils
26
+ from .runner import AgentRunner, get_agent_runner
27
+
28
+ __all__ = [
29
+ "MonocleValidator",
30
+ "TestCase",
31
+ "TestSpan",
32
+ "Entity",
33
+ "EntityType",
34
+ "SpanType",
35
+ "BaseEval",
36
+ "Evaluation",
37
+ "BertScorerEval",
38
+ "BaseComparer",
39
+ "BertScoreComparer",
40
+ "DefaultComparer",
41
+ "AgentRunner",
42
+ "get_agent_runner"
43
+ ]
@@ -0,0 +1,18 @@
1
+ """
2
+ Evaluation modules for monocle test tools.
3
+
4
+ This package provides base and default evaluation implementations
5
+ for validating AI agent responses and behavior.
6
+ """
7
+
8
+ from .base_comparer import BaseComparer
9
+ from .bert_score_comparer import BertScoreComparer
10
+ from .default_comparer import DefaultComparer
11
+ from .metric_comparer import MetricComparer
12
+
13
+ __all__ = [
14
+ "BaseComparer",
15
+ "BertScoreComparer",
16
+ "DefaultComparer",
17
+ "MetricComparer",
18
+ ]
@@ -0,0 +1,10 @@
1
+ from typing import Optional, Union
2
+ from pydantic import BaseModel
3
+
4
+ class BaseComparer(BaseModel):
5
+ eval_options: Optional[dict] = {}
6
+ def __init__(self, **data):
7
+ super().__init__(**data)
8
+
9
+ def compare(self, expected: Union[dict, str], actual: Union[dict, str]) -> bool:
10
+ raise NotImplementedError
@@ -0,0 +1,50 @@
1
+ import logging
2
+ from monocle_test_tools.comparer.base_comparer import BaseComparer
3
+
4
+ from monocle_test_tools.evals.base_eval import BaseEval
5
+ from monocle_test_tools.evals.bert_eval import BertScorerEval
6
+
7
+ logger = logging.getLogger(__name__)
8
+ BERT_ACCEPTABLE_F1_THRESHOLD:float = 0.7
9
+ BERT_ACCEPTABLE_PRECISION_THRESHOLD:float = 0.7
10
+ BERT_ACCEPTABLE_RECALL_THRESHOLD:float = 0.7
11
+ MODEL_TYPE:str = 'bert-base-uncased'
12
+
13
+ class BertScoreComparer(BaseComparer):
14
+ bert_scorer_eval: BaseEval
15
+
16
+ bert_scorer_acceptible_f1_threshold: float = BERT_ACCEPTABLE_F1_THRESHOLD
17
+ bert_scorer_precision_threshold: float = BERT_ACCEPTABLE_PRECISION_THRESHOLD
18
+ bert_scorer_recall_threshold: float = BERT_ACCEPTABLE_RECALL_THRESHOLD
19
+ bert_scorer_eval: BaseEval = None
20
+
21
+ def __init__(self, **data):
22
+ super().__init__(**data)
23
+ self.bert_scorer_eval = BertScorerEval()
24
+
25
+ def compare(self, expected: str, actual: str) -> bool:
26
+ if expected == actual:
27
+ return True
28
+ if expected is None or actual is None:
29
+ return False
30
+ return self._bert_score_validation(expected, actual)
31
+
32
+ def _bert_score_validation(self, expected_response: str, actual_response: str) -> bool:
33
+ """
34
+ Calculate BERTScore between expected and actual responses.
35
+
36
+ Args:
37
+ expected_response (str): The expected response string.
38
+ actual_response (str): The actual response string.
39
+ """
40
+ eval_args = {
41
+ "input": expected_response,
42
+ "output": actual_response
43
+ }
44
+ scores = self.bert_scorer_eval.evaluate(eval_args=eval_args)
45
+ if scores["F1"] < self.bert_scorer_acceptible_f1_threshold or scores["Recall"] < self.bert_scorer_recall_threshold or scores["Precision"] < self.bert_scorer_precision_threshold:
46
+ logger.debug(f"Output does not match expected. Precision: {scores['Precision']:.4f}, Recall: {scores['Recall']:.4f}, F1: {scores['F1']:.4f}")
47
+ valid_response = False
48
+ else:
49
+ valid_response = True
50
+ return valid_response