veris-ai 1.2.0__tar.gz → 1.4.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.
Potentially problematic release.
This version of veris-ai might be problematic. Click here for more details.
- veris_ai-1.4.0/.cursor/rules/documentation-management.mdc +80 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/.github/workflows/test.yml +1 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/CLAUDE.md +81 -3
- veris_ai-1.4.0/PKG-INFO +223 -0
- veris_ai-1.4.0/README.md +187 -0
- veris_ai-1.4.0/examples/README.md +117 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/pyproject.toml +1 -1
- veris_ai-1.4.0/src/veris_ai/README.md +75 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/src/veris_ai/__init__.py +2 -7
- veris_ai-1.4.0/src/veris_ai/jaeger_interface/README.md +101 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/src/veris_ai/jaeger_interface/client.py +44 -41
- {veris_ai-1.2.0 → veris_ai-1.4.0}/src/veris_ai/jaeger_interface/models.py +1 -2
- veris_ai-1.4.0/src/veris_ai/logging.py +116 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/src/veris_ai/models.py +2 -2
- {veris_ai-1.2.0 → veris_ai-1.4.0}/src/veris_ai/tool_mock.py +93 -26
- {veris_ai-1.2.0 → veris_ai-1.4.0}/src/veris_ai/utils.py +3 -0
- veris_ai-1.4.0/tests/README.md +108 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/tests/conftest.py +14 -4
- {veris_ai-1.2.0 → veris_ai-1.4.0}/tests/test_mcp_protocol_server_mocked.py +1 -1
- {veris_ai-1.2.0 → veris_ai-1.4.0}/tests/test_tool_mock.py +24 -26
- {veris_ai-1.2.0 → veris_ai-1.4.0}/tests/test_utils.py +33 -3
- {veris_ai-1.2.0 → veris_ai-1.4.0}/uv.lock +1 -1
- veris_ai-1.2.0/PKG-INFO +0 -457
- veris_ai-1.2.0/README.md +0 -421
- veris_ai-1.2.0/src/veris_ai/jaeger_interface/README.md +0 -137
- {veris_ai-1.2.0 → veris_ai-1.4.0}/.github/workflows/release.yml +0 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/.gitignore +0 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/CHANGELOG.md +0 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/LICENSE +0 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/examples/__init__.py +0 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/examples/import_options.py +0 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/src/veris_ai/braintrust_tracing.py +0 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/src/veris_ai/jaeger_interface/__init__.py +0 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/tests/__init__.py +0 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/tests/fixtures/__init__.py +0 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/tests/fixtures/simple_app.py +0 -0
- {veris_ai-1.2.0 → veris_ai-1.4.0}/tests/fixtures/sse_server.py +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Ensure READMEs function as both a human-friendly guide and an LLM semantic router, while designating source code as the sole source of truth. This document also defines LLM workflows that continuously evolve documentation in response to actual usage patterns.
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Documentation Handling Guidelines
|
|
7
|
+
|
|
8
|
+
### Dual‑Use Overview
|
|
9
|
+
|
|
10
|
+
* **Humans**: READMEs must be narrative‑driven, intuitive, and structured for readability, with inline cross‑links to related READMEs or code modules for deeper context.
|
|
11
|
+
* **LLM Agents**: Treat these same READMEs as semantic routers. Use linked references and tags within the document to locate the most relevant code, tests, and workflows — never treat the README as the ultimate logic source.
|
|
12
|
+
* **Shared Goal**: Documentation must actively fight codebase complexity. Instead of growing endlessly, it should simplify, subtract redundancy, and delegate details to lower‑level READMEs in the hierarchy.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
### When to Update Documentation
|
|
17
|
+
|
|
18
|
+
Trigger updates upon significant changes including:
|
|
19
|
+
|
|
20
|
+
* Major features, refactors, or architectural/schematic changes
|
|
21
|
+
* Workflow updates or dependencies added/removed
|
|
22
|
+
* Changes affecting user interactions or onboarding
|
|
23
|
+
|
|
24
|
+
**Heuristic**: If the change alters how a human would interact or mentally model the system — or how the LLM navigates it — it calls for a README update.
|
|
25
|
+
|
|
26
|
+
Updates should simplify where possible: remove outdated or redundant content, and delegate specifics via cross‑links (e.g., *See [Auth Module README](./auth/README.md) for details on authentication flows*).
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### LLM‑Driven Continuous Documentation
|
|
31
|
+
|
|
32
|
+
1. **End‑of‑session reflection**: At task completion, the LLM should summarize the work and, if needed, update the README with clarifications or new links to relevant modules.
|
|
33
|
+
2. **Parallel instance memory**: Maintain awareness of session context across LLM instances to keep documentation aligned with ongoing workflows.
|
|
34
|
+
3. **LLM as thought partner**: Propose not only wording edits but also simplifications and delegation opportunities — e.g., linking to an existing module README rather than duplicating logic.
|
|
35
|
+
4. **Complexity management**: Treat every update as a chance to prune. The README should remain a high‑level, navigable entry point, not a catch‑all.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### Structure & Format
|
|
40
|
+
|
|
41
|
+
Each meaningful workspace or module must include a `README.md` designed to operate like a **hub page** in an IDE‑backed website:
|
|
42
|
+
|
|
43
|
+
* **Quick Reference**: Purpose, setup, usage, and high‑level architecture.
|
|
44
|
+
* **Linked Context**: Cross‑links to deeper READMEs, design docs, or code directories.
|
|
45
|
+
* **Semantic Anchors**: Inline cues (e.g., tags, headings, links) that help the LLM map concepts to code without requiring redundant prose.
|
|
46
|
+
|
|
47
|
+
> Example:
|
|
48
|
+
> *“For transaction processing, see [Transactions README](./transactions/README.md). For error handling logic, see [Error Handling README](./errors/README.md).”*
|
|
49
|
+
|
|
50
|
+
The human and LLM share the same document: humans follow the narrative, while the LLM uses references and anchors to navigate the codebase semantically.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### Workflow Roles
|
|
55
|
+
|
|
56
|
+
#### LLM Responsibilities
|
|
57
|
+
|
|
58
|
+
* Detect README drift by comparing live code to described behavior.
|
|
59
|
+
* Perform updates with an emphasis on pruning duplication and linking to existing READMEs.
|
|
60
|
+
* Use end‑of‑session summaries to suggest or implement simplifications.
|
|
61
|
+
* Ensure docs remain aligned with code without ballooning in size.
|
|
62
|
+
|
|
63
|
+
#### Human Responsibilities
|
|
64
|
+
|
|
65
|
+
* Review LLM‑driven updates for clarity, accuracy, and usability.
|
|
66
|
+
* Refactor prose when needed to keep explanations intuitive.
|
|
67
|
+
* Validate that cross‑links resolve correctly and are helpful for navigation.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### Key Principles
|
|
72
|
+
|
|
73
|
+
| Principle | Description |
|
|
74
|
+
| -------------------------- | ------------------------------------------------------------------------- |
|
|
75
|
+
| **Code is truth** | Source code is definitive; README is a semantic guide, not the authority. |
|
|
76
|
+
| **Documentation evolves** | Updates happen with real usage, not on a fixed schedule. |
|
|
77
|
+
| **Simplicity over sprawl** | Fight complexity by pruning, delegating, and cross‑linking. |
|
|
78
|
+
| **One README, two roles** | The same README serves both humans and LLMs through cross‑referencing. |
|
|
79
|
+
| **Real‑world grounding** | Updates reflect actual changes in workflows and architecture. |
|
|
80
|
+
| **Human validation** | LLM edits require human review to ensure usability and accuracy. |
|
|
@@ -5,10 +5,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
5
5
|
## Project Overview
|
|
6
6
|
|
|
7
7
|
This is the Veris AI Python SDK - a package that provides simulation capabilities through decorator-based function mocking and FastAPI MCP (Model Context Protocol) integration. The core functionality revolves around:
|
|
8
|
-
- `VerisSDK` class in `src/veris_ai/tool_mock.py:27` - enables environment-aware execution where functions can be mocked in simulation mode or executed normally in production
|
|
8
|
+
- `VerisSDK` class in `src/veris_ai/tool_mock.py:27` - enables environment-aware execution where functions can be mocked in simulation mode, spied on, or executed normally in production
|
|
9
|
+
- Spy mode (`@veris.mock(mode="spy")`) - executes original functions while logging calls and responses to Redis via logging endpoints
|
|
9
10
|
- `convert_to_type()` function in `src/veris_ai/utils.py:5` - handles sophisticated type conversion from mock responses
|
|
10
11
|
- `FastApiMCPParams` model in `src/veris_ai/models.py:1` - provides configuration for integrating FastAPI applications with the Model Context Protocol
|
|
11
12
|
- `set_fastapi_mcp()` method in `src/veris_ai/tool_mock.py:54` - configures FastAPI MCP server with automatic OAuth2-based session management
|
|
13
|
+
- Logging utilities in `src/veris_ai/logging.py` - provide async and sync functions for logging tool calls and responses to VERIS endpoints
|
|
12
14
|
|
|
13
15
|
## Development Commands
|
|
14
16
|
|
|
@@ -100,7 +102,7 @@ uv build
|
|
|
100
102
|
### Environment Configuration
|
|
101
103
|
|
|
102
104
|
Required environment variables:
|
|
103
|
-
- `
|
|
105
|
+
- `VERIS_ENDPOINT_URL`: Base endpoint URL (required)
|
|
104
106
|
- `VERIS_MOCK_TIMEOUT`: Request timeout in seconds (optional, default: 30.0)
|
|
105
107
|
- `ENV`: Set to "simulation" to enable mocking, anything else runs original functions
|
|
106
108
|
|
|
@@ -182,4 +184,80 @@ Key implementation aspects:
|
|
|
182
184
|
- Creates internal OAuth2PasswordBearer scheme for token extraction
|
|
183
185
|
- Dependency injection for automatic session context setting
|
|
184
186
|
- Preserves user auth configurations while adding session management
|
|
185
|
-
- SSE (Server-Sent Events) support for streaming responses
|
|
187
|
+
- SSE (Server-Sent Events) support for streaming responses
|
|
188
|
+
|
|
189
|
+
## Documentation Handling Guidelines
|
|
190
|
+
|
|
191
|
+
### Dual‑Use Overview
|
|
192
|
+
|
|
193
|
+
* **Humans**: READMEs must be narrative‑driven, intuitive, and structured for readability, with inline cross‑links to related READMEs or code modules for deeper context.
|
|
194
|
+
* **LLM Agents**: Treat these same READMEs as semantic routers. Use linked references and tags within the document to locate the most relevant code, tests, and workflows — never treat the README as the ultimate logic source.
|
|
195
|
+
* **Shared Goal**: Documentation must actively fight codebase complexity. Instead of growing endlessly, it should simplify, subtract redundancy, and delegate details to lower‑level READMEs in the hierarchy.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
### When to Update Documentation
|
|
200
|
+
|
|
201
|
+
Trigger updates upon significant changes including:
|
|
202
|
+
|
|
203
|
+
* Major features, refactors, or architectural/schematic changes
|
|
204
|
+
* Workflow updates or dependencies added/removed
|
|
205
|
+
* Changes affecting user interactions or onboarding
|
|
206
|
+
|
|
207
|
+
**Heuristic**: If the change alters how a human would interact or mentally model the system — or how the LLM navigates it — it calls for a README update.
|
|
208
|
+
|
|
209
|
+
Updates should simplify where possible: remove outdated or redundant content, and delegate specifics via cross‑links (e.g., *See [Auth Module README](./auth/README.md) for details on authentication flows*).
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
### LLM‑Driven Continuous Documentation
|
|
214
|
+
|
|
215
|
+
1. **End‑of‑session reflection**: At task completion, the LLM should summarize the work and, if needed, update the README with clarifications or new links to relevant modules.
|
|
216
|
+
2. **Parallel instance memory**: Maintain awareness of session context across LLM instances to keep documentation aligned with ongoing workflows.
|
|
217
|
+
3. **LLM as thought partner**: Propose not only wording edits but also simplifications and delegation opportunities — e.g., linking to an existing module README rather than duplicating logic.
|
|
218
|
+
4. **Complexity management**: Treat every update as a chance to prune. The README should remain a high‑level, navigable entry point, not a catch‑all.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### Structure & Format
|
|
223
|
+
|
|
224
|
+
Each meaningful workspace or module must include a `README.md` designed to operate like a **hub page** in an IDE‑backed website:
|
|
225
|
+
|
|
226
|
+
* **Quick Reference**: Purpose, setup, usage, and high‑level architecture.
|
|
227
|
+
* **Linked Context**: Cross‑links to deeper READMEs, design docs, or code directories.
|
|
228
|
+
* **Semantic Anchors**: Inline cues (e.g., tags, headings, links) that help the LLM map concepts to code without requiring redundant prose.
|
|
229
|
+
|
|
230
|
+
> Example:
|
|
231
|
+
> *“For transaction processing, see [Transactions README](./transactions/README.md). For error handling logic, see [Error Handling README](./errors/README.md).”*
|
|
232
|
+
|
|
233
|
+
The human and LLM share the same document: humans follow the narrative, while the LLM uses references and anchors to navigate the codebase semantically.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
### Workflow Roles
|
|
238
|
+
|
|
239
|
+
#### LLM Responsibilities
|
|
240
|
+
|
|
241
|
+
* Detect README drift by comparing live code to described behavior.
|
|
242
|
+
* Perform updates with an emphasis on pruning duplication and linking to existing READMEs.
|
|
243
|
+
* Use end‑of‑session summaries to suggest or implement simplifications.
|
|
244
|
+
* Ensure docs remain aligned with code without ballooning in size.
|
|
245
|
+
|
|
246
|
+
#### Human Responsibilities
|
|
247
|
+
|
|
248
|
+
* Review LLM‑driven updates for clarity, accuracy, and usability.
|
|
249
|
+
* Refactor prose when needed to keep explanations intuitive.
|
|
250
|
+
* Validate that cross‑links resolve correctly and are helpful for navigation.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
### Key Principles
|
|
255
|
+
|
|
256
|
+
| Principle | Description |
|
|
257
|
+
| -------------------------- | ------------------------------------------------------------------------- |
|
|
258
|
+
| **Code is truth** | Source code is definitive; README is a semantic guide, not the authority. |
|
|
259
|
+
| **Documentation evolves** | Updates happen with real usage, not on a fixed schedule. |
|
|
260
|
+
| **Simplicity over sprawl** | Fight complexity by pruning, delegating, and cross‑linking. |
|
|
261
|
+
| **One README, two roles** | The same README serves both humans and LLMs through cross‑referencing. |
|
|
262
|
+
| **Real‑world grounding** | Updates reflect actual changes in workflows and architecture. |
|
|
263
|
+
| **Human validation** | LLM edits require human review to ensure usability and accuracy. |
|
veris_ai-1.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: veris-ai
|
|
3
|
+
Version: 1.4.0
|
|
4
|
+
Summary: A Python package for Veris AI tools
|
|
5
|
+
Project-URL: Homepage, https://github.com/veris-ai/veris-python-sdk
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/veris-ai/veris-python-sdk/issues
|
|
7
|
+
Author-email: Mehdi Jamei <mehdi@veris.ai>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Requires-Dist: httpx>=0.24.0
|
|
12
|
+
Requires-Dist: pydantic>=2.0.0
|
|
13
|
+
Requires-Dist: requests>=2.31.0
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: black>=23.7.0; extra == 'dev'
|
|
16
|
+
Requires-Dist: mypy>=1.5.1; extra == 'dev'
|
|
17
|
+
Requires-Dist: openai-agents>=0.0.1; extra == 'dev'
|
|
18
|
+
Requires-Dist: pre-commit>=3.3.3; extra == 'dev'
|
|
19
|
+
Requires-Dist: pytest-asyncio>=0.21.1; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: ruff>=0.11.4; extra == 'dev'
|
|
23
|
+
Provides-Extra: fastapi
|
|
24
|
+
Requires-Dist: fastapi; extra == 'fastapi'
|
|
25
|
+
Requires-Dist: fastapi-mcp; extra == 'fastapi'
|
|
26
|
+
Provides-Extra: instrument
|
|
27
|
+
Requires-Dist: braintrust; extra == 'instrument'
|
|
28
|
+
Requires-Dist: opentelemetry-api; extra == 'instrument'
|
|
29
|
+
Requires-Dist: opentelemetry-exporter-otlp; extra == 'instrument'
|
|
30
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-common; extra == 'instrument'
|
|
31
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc; extra == 'instrument'
|
|
32
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http; extra == 'instrument'
|
|
33
|
+
Requires-Dist: opentelemetry-sdk; extra == 'instrument'
|
|
34
|
+
Requires-Dist: wrapt; extra == 'instrument'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# Veris AI Python SDK
|
|
38
|
+
|
|
39
|
+
A Python package for Veris AI tools with simulation capabilities and FastAPI MCP (Model Context Protocol) integration.
|
|
40
|
+
|
|
41
|
+
## Quick Reference
|
|
42
|
+
|
|
43
|
+
**Purpose**: Tool mocking, tracing, and FastAPI MCP integration for AI agent development
|
|
44
|
+
**Core Components**: [`tool_mock`](#function-mocking) • [`jaeger_interface`](#jaeger-trace-interface) • [`braintrust_tracing`](#tracing-integration) • [`fastapi_mcp`](#fastapi-mcp-integration)
|
|
45
|
+
**Deep Dive**: [`Module Architecture`](src/veris_ai/README.md) • [`Testing Guide`](tests/README.md) • [`Usage Examples`](examples/README.md)
|
|
46
|
+
**Source of Truth**: Implementation details in [`src/veris_ai/`](src/veris_ai/) source code
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Base package
|
|
52
|
+
uv add veris-ai
|
|
53
|
+
|
|
54
|
+
# With optional extras
|
|
55
|
+
uv add "veris-ai[dev,fastapi,instrument]"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Installation Profiles**:
|
|
59
|
+
- `dev`: Development tools (ruff, pytest, mypy)
|
|
60
|
+
- `fastapi`: FastAPI MCP integration
|
|
61
|
+
- `instrument`: Braintrust/OpenTelemetry tracing
|
|
62
|
+
|
|
63
|
+
## Import Patterns
|
|
64
|
+
|
|
65
|
+
**Semantic Tag**: `import-patterns`
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
# Core imports (base dependencies only)
|
|
69
|
+
from veris_ai import veris, JaegerClient
|
|
70
|
+
|
|
71
|
+
# Optional features (require extras)
|
|
72
|
+
from veris_ai import braintrust_tracing # Requires [instrument]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Complete Import Strategies**: See [`examples/README.md`](examples/README.md) for five different import approaches, conditional features, and integration patterns.
|
|
76
|
+
|
|
77
|
+
## Configuration
|
|
78
|
+
|
|
79
|
+
**Semantic Tag**: `environment-config`
|
|
80
|
+
|
|
81
|
+
| Variable | Purpose | Default |
|
|
82
|
+
|----------|---------|---------|
|
|
83
|
+
| `VERIS_ENDPOINT_URL` | Mock server endpoint | *Required* |
|
|
84
|
+
| `VERIS_MOCK_TIMEOUT` | Request timeout (seconds) | `90.0` |
|
|
85
|
+
| `ENV` | Set to `"simulation"` for mock mode | Production |
|
|
86
|
+
| `VERIS_SERVICE_NAME` | Tracing service name | Auto-detected |
|
|
87
|
+
| `VERIS_OTLP_ENDPOINT` | OpenTelemetry collector | *Required for tracing* |
|
|
88
|
+
|
|
89
|
+
**Configuration Details**: See [`src/veris_ai/tool_mock.py`](src/veris_ai/tool_mock.py) for environment handling logic.
|
|
90
|
+
|
|
91
|
+
## Tracing Integration
|
|
92
|
+
|
|
93
|
+
**Semantic Tag**: `distributed-tracing`
|
|
94
|
+
|
|
95
|
+
Parallel tracing to Braintrust and Jaeger/OpenTelemetry for monitoring and evaluation.
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from veris_ai import braintrust_tracing
|
|
99
|
+
|
|
100
|
+
# Enable dual tracing
|
|
101
|
+
braintrust_tracing.instrument(service_name="my-service", otlp_endpoint="http://localhost:4317")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Session Management**: Automatic session ID extraction from bearer tokens. Manual session control via `veris.set_session_id()` and `veris.clear_session_id()`.
|
|
105
|
+
|
|
106
|
+
**Implementation Details**: See [`src/veris_ai/braintrust_tracing.py`](src/veris_ai/braintrust_tracing.py) for instrumentation logic.
|
|
107
|
+
|
|
108
|
+
## Function Mocking
|
|
109
|
+
|
|
110
|
+
**Semantic Tag**: `tool-mocking`
|
|
111
|
+
|
|
112
|
+
### Core Decorators
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from veris_ai import veris
|
|
116
|
+
|
|
117
|
+
# Mock mode: Returns simulated responses in ENV=simulation
|
|
118
|
+
@veris.mock()
|
|
119
|
+
async def your_function(param1: str, param2: int) -> dict:
|
|
120
|
+
"""Function documentation for LLM context."""
|
|
121
|
+
return {"result": "actual implementation"}
|
|
122
|
+
|
|
123
|
+
# Spy mode: Executes function but logs calls/responses
|
|
124
|
+
@veris.mock(mode="spy")
|
|
125
|
+
async def monitored_function(data: str) -> dict:
|
|
126
|
+
return process_data(data)
|
|
127
|
+
|
|
128
|
+
# Stub mode: Returns fixed value in simulation
|
|
129
|
+
@veris.stub(return_value={"status": "success"})
|
|
130
|
+
async def get_data() -> dict:
|
|
131
|
+
return await fetch_from_api()
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Behavior**: In simulation mode, decorators intercept calls to mock endpoints. In production, functions execute normally.
|
|
135
|
+
|
|
136
|
+
**Implementation**: See [`src/veris_ai/tool_mock.py`](src/veris_ai/tool_mock.py) for decorator logic and API integration.
|
|
137
|
+
|
|
138
|
+
## FastAPI MCP Integration
|
|
139
|
+
|
|
140
|
+
**Semantic Tag**: `fastapi-mcp`
|
|
141
|
+
|
|
142
|
+
Expose FastAPI endpoints as MCP tools for AI agent consumption.
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
from fastapi import FastAPI
|
|
146
|
+
from veris_ai import veris
|
|
147
|
+
|
|
148
|
+
app = FastAPI()
|
|
149
|
+
|
|
150
|
+
# Enable MCP integration
|
|
151
|
+
veris.set_fastapi_mcp(
|
|
152
|
+
fastapi=app,
|
|
153
|
+
name="My API Server",
|
|
154
|
+
include_operations=["get_users", "create_user"],
|
|
155
|
+
exclude_tags=["internal"]
|
|
156
|
+
)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Key Features**:
|
|
160
|
+
- **Automatic schema conversion**: FastAPI OpenAPI → MCP tool definitions
|
|
161
|
+
- **Session management**: Bearer token → session ID mapping
|
|
162
|
+
- **Filtering**: Include/exclude operations and tags
|
|
163
|
+
- **Authentication**: OAuth2 integration
|
|
164
|
+
|
|
165
|
+
**Configuration Reference**: See function signature in [`src/veris_ai/tool_mock.py`](src/veris_ai/tool_mock.py) for all `set_fastapi_mcp()` parameters.
|
|
166
|
+
|
|
167
|
+
## Utility Functions
|
|
168
|
+
|
|
169
|
+
**Semantic Tag**: `json-schema-utils`
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
from veris_ai.utils import extract_json_schema
|
|
173
|
+
|
|
174
|
+
# Schema extraction from types
|
|
175
|
+
user_schema = extract_json_schema(User) # Pydantic models
|
|
176
|
+
list_schema = extract_json_schema(List[str]) # Generics
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Supported Types**: Built-in types, generics (List, Dict, Union), Pydantic models, TypedDict, forward references.
|
|
180
|
+
|
|
181
|
+
**Implementation**: See [`src/veris_ai/utils.py`](src/veris_ai/utils.py) for type conversion logic.
|
|
182
|
+
|
|
183
|
+
## Development
|
|
184
|
+
|
|
185
|
+
**Semantic Tag**: `development-setup`
|
|
186
|
+
|
|
187
|
+
**Requirements**: Python 3.11+, `uv` package manager
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# Install with dev dependencies
|
|
191
|
+
uv add "veris-ai[dev]"
|
|
192
|
+
|
|
193
|
+
# Quality checks
|
|
194
|
+
ruff check --fix . # Lint and format
|
|
195
|
+
pytest --cov=veris_ai # Test with coverage
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Testing & Architecture**: See [`tests/README.md`](tests/README.md) for test structure, fixtures, and coverage strategies. See [`src/veris_ai/README.md`](src/veris_ai/README.md) for module architecture and implementation flows.
|
|
199
|
+
|
|
200
|
+
## Module Architecture
|
|
201
|
+
|
|
202
|
+
**Semantic Tag**: `module-architecture`
|
|
203
|
+
|
|
204
|
+
**Core Modules**: `tool_mock` (mocking), `jaeger_interface` (trace queries), `braintrust_tracing` (dual tracing), `utils` (schema conversion)
|
|
205
|
+
|
|
206
|
+
**Complete Architecture**: See [`src/veris_ai/README.md`](src/veris_ai/README.md) for module overview, implementation flows, and configuration details.
|
|
207
|
+
|
|
208
|
+
## Jaeger Trace Interface
|
|
209
|
+
|
|
210
|
+
**Semantic Tag**: `jaeger-query-api`
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
from veris_ai.jaeger_interface import JaegerClient
|
|
214
|
+
|
|
215
|
+
client = JaegerClient("http://localhost:16686")
|
|
216
|
+
traces = client.search(service="veris-agent", tags={"error": "true"})
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**Complete Guide**: See [`src/veris_ai/jaeger_interface/README.md`](src/veris_ai/jaeger_interface/README.md) for API reference, filtering strategies, and architecture details.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
**License**: MIT License - see [LICENSE](LICENSE) file for details.
|
veris_ai-1.4.0/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Veris AI Python SDK
|
|
2
|
+
|
|
3
|
+
A Python package for Veris AI tools with simulation capabilities and FastAPI MCP (Model Context Protocol) integration.
|
|
4
|
+
|
|
5
|
+
## Quick Reference
|
|
6
|
+
|
|
7
|
+
**Purpose**: Tool mocking, tracing, and FastAPI MCP integration for AI agent development
|
|
8
|
+
**Core Components**: [`tool_mock`](#function-mocking) • [`jaeger_interface`](#jaeger-trace-interface) • [`braintrust_tracing`](#tracing-integration) • [`fastapi_mcp`](#fastapi-mcp-integration)
|
|
9
|
+
**Deep Dive**: [`Module Architecture`](src/veris_ai/README.md) • [`Testing Guide`](tests/README.md) • [`Usage Examples`](examples/README.md)
|
|
10
|
+
**Source of Truth**: Implementation details in [`src/veris_ai/`](src/veris_ai/) source code
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Base package
|
|
16
|
+
uv add veris-ai
|
|
17
|
+
|
|
18
|
+
# With optional extras
|
|
19
|
+
uv add "veris-ai[dev,fastapi,instrument]"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Installation Profiles**:
|
|
23
|
+
- `dev`: Development tools (ruff, pytest, mypy)
|
|
24
|
+
- `fastapi`: FastAPI MCP integration
|
|
25
|
+
- `instrument`: Braintrust/OpenTelemetry tracing
|
|
26
|
+
|
|
27
|
+
## Import Patterns
|
|
28
|
+
|
|
29
|
+
**Semantic Tag**: `import-patterns`
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
# Core imports (base dependencies only)
|
|
33
|
+
from veris_ai import veris, JaegerClient
|
|
34
|
+
|
|
35
|
+
# Optional features (require extras)
|
|
36
|
+
from veris_ai import braintrust_tracing # Requires [instrument]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Complete Import Strategies**: See [`examples/README.md`](examples/README.md) for five different import approaches, conditional features, and integration patterns.
|
|
40
|
+
|
|
41
|
+
## Configuration
|
|
42
|
+
|
|
43
|
+
**Semantic Tag**: `environment-config`
|
|
44
|
+
|
|
45
|
+
| Variable | Purpose | Default |
|
|
46
|
+
|----------|---------|---------|
|
|
47
|
+
| `VERIS_ENDPOINT_URL` | Mock server endpoint | *Required* |
|
|
48
|
+
| `VERIS_MOCK_TIMEOUT` | Request timeout (seconds) | `90.0` |
|
|
49
|
+
| `ENV` | Set to `"simulation"` for mock mode | Production |
|
|
50
|
+
| `VERIS_SERVICE_NAME` | Tracing service name | Auto-detected |
|
|
51
|
+
| `VERIS_OTLP_ENDPOINT` | OpenTelemetry collector | *Required for tracing* |
|
|
52
|
+
|
|
53
|
+
**Configuration Details**: See [`src/veris_ai/tool_mock.py`](src/veris_ai/tool_mock.py) for environment handling logic.
|
|
54
|
+
|
|
55
|
+
## Tracing Integration
|
|
56
|
+
|
|
57
|
+
**Semantic Tag**: `distributed-tracing`
|
|
58
|
+
|
|
59
|
+
Parallel tracing to Braintrust and Jaeger/OpenTelemetry for monitoring and evaluation.
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from veris_ai import braintrust_tracing
|
|
63
|
+
|
|
64
|
+
# Enable dual tracing
|
|
65
|
+
braintrust_tracing.instrument(service_name="my-service", otlp_endpoint="http://localhost:4317")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Session Management**: Automatic session ID extraction from bearer tokens. Manual session control via `veris.set_session_id()` and `veris.clear_session_id()`.
|
|
69
|
+
|
|
70
|
+
**Implementation Details**: See [`src/veris_ai/braintrust_tracing.py`](src/veris_ai/braintrust_tracing.py) for instrumentation logic.
|
|
71
|
+
|
|
72
|
+
## Function Mocking
|
|
73
|
+
|
|
74
|
+
**Semantic Tag**: `tool-mocking`
|
|
75
|
+
|
|
76
|
+
### Core Decorators
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from veris_ai import veris
|
|
80
|
+
|
|
81
|
+
# Mock mode: Returns simulated responses in ENV=simulation
|
|
82
|
+
@veris.mock()
|
|
83
|
+
async def your_function(param1: str, param2: int) -> dict:
|
|
84
|
+
"""Function documentation for LLM context."""
|
|
85
|
+
return {"result": "actual implementation"}
|
|
86
|
+
|
|
87
|
+
# Spy mode: Executes function but logs calls/responses
|
|
88
|
+
@veris.mock(mode="spy")
|
|
89
|
+
async def monitored_function(data: str) -> dict:
|
|
90
|
+
return process_data(data)
|
|
91
|
+
|
|
92
|
+
# Stub mode: Returns fixed value in simulation
|
|
93
|
+
@veris.stub(return_value={"status": "success"})
|
|
94
|
+
async def get_data() -> dict:
|
|
95
|
+
return await fetch_from_api()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Behavior**: In simulation mode, decorators intercept calls to mock endpoints. In production, functions execute normally.
|
|
99
|
+
|
|
100
|
+
**Implementation**: See [`src/veris_ai/tool_mock.py`](src/veris_ai/tool_mock.py) for decorator logic and API integration.
|
|
101
|
+
|
|
102
|
+
## FastAPI MCP Integration
|
|
103
|
+
|
|
104
|
+
**Semantic Tag**: `fastapi-mcp`
|
|
105
|
+
|
|
106
|
+
Expose FastAPI endpoints as MCP tools for AI agent consumption.
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from fastapi import FastAPI
|
|
110
|
+
from veris_ai import veris
|
|
111
|
+
|
|
112
|
+
app = FastAPI()
|
|
113
|
+
|
|
114
|
+
# Enable MCP integration
|
|
115
|
+
veris.set_fastapi_mcp(
|
|
116
|
+
fastapi=app,
|
|
117
|
+
name="My API Server",
|
|
118
|
+
include_operations=["get_users", "create_user"],
|
|
119
|
+
exclude_tags=["internal"]
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Key Features**:
|
|
124
|
+
- **Automatic schema conversion**: FastAPI OpenAPI → MCP tool definitions
|
|
125
|
+
- **Session management**: Bearer token → session ID mapping
|
|
126
|
+
- **Filtering**: Include/exclude operations and tags
|
|
127
|
+
- **Authentication**: OAuth2 integration
|
|
128
|
+
|
|
129
|
+
**Configuration Reference**: See function signature in [`src/veris_ai/tool_mock.py`](src/veris_ai/tool_mock.py) for all `set_fastapi_mcp()` parameters.
|
|
130
|
+
|
|
131
|
+
## Utility Functions
|
|
132
|
+
|
|
133
|
+
**Semantic Tag**: `json-schema-utils`
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from veris_ai.utils import extract_json_schema
|
|
137
|
+
|
|
138
|
+
# Schema extraction from types
|
|
139
|
+
user_schema = extract_json_schema(User) # Pydantic models
|
|
140
|
+
list_schema = extract_json_schema(List[str]) # Generics
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Supported Types**: Built-in types, generics (List, Dict, Union), Pydantic models, TypedDict, forward references.
|
|
144
|
+
|
|
145
|
+
**Implementation**: See [`src/veris_ai/utils.py`](src/veris_ai/utils.py) for type conversion logic.
|
|
146
|
+
|
|
147
|
+
## Development
|
|
148
|
+
|
|
149
|
+
**Semantic Tag**: `development-setup`
|
|
150
|
+
|
|
151
|
+
**Requirements**: Python 3.11+, `uv` package manager
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Install with dev dependencies
|
|
155
|
+
uv add "veris-ai[dev]"
|
|
156
|
+
|
|
157
|
+
# Quality checks
|
|
158
|
+
ruff check --fix . # Lint and format
|
|
159
|
+
pytest --cov=veris_ai # Test with coverage
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Testing & Architecture**: See [`tests/README.md`](tests/README.md) for test structure, fixtures, and coverage strategies. See [`src/veris_ai/README.md`](src/veris_ai/README.md) for module architecture and implementation flows.
|
|
163
|
+
|
|
164
|
+
## Module Architecture
|
|
165
|
+
|
|
166
|
+
**Semantic Tag**: `module-architecture`
|
|
167
|
+
|
|
168
|
+
**Core Modules**: `tool_mock` (mocking), `jaeger_interface` (trace queries), `braintrust_tracing` (dual tracing), `utils` (schema conversion)
|
|
169
|
+
|
|
170
|
+
**Complete Architecture**: See [`src/veris_ai/README.md`](src/veris_ai/README.md) for module overview, implementation flows, and configuration details.
|
|
171
|
+
|
|
172
|
+
## Jaeger Trace Interface
|
|
173
|
+
|
|
174
|
+
**Semantic Tag**: `jaeger-query-api`
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
from veris_ai.jaeger_interface import JaegerClient
|
|
178
|
+
|
|
179
|
+
client = JaegerClient("http://localhost:16686")
|
|
180
|
+
traces = client.search(service="veris-agent", tags={"error": "true"})
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Complete Guide**: See [`src/veris_ai/jaeger_interface/README.md`](src/veris_ai/jaeger_interface/README.md) for API reference, filtering strategies, and architecture details.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
**License**: MIT License - see [LICENSE](LICENSE) file for details.
|