veris-ai 1.8.1__tar.gz → 1.9.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.8.1 → veris_ai-1.9.0}/PKG-INFO +109 -6
- {veris_ai-1.8.1 → veris_ai-1.9.0}/README.md +108 -5
- {veris_ai-1.8.1 → veris_ai-1.9.0}/examples/openai_agents_example.py +33 -26
- {veris_ai-1.8.1 → veris_ai-1.9.0}/pyproject.toml +1 -1
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/__init__.py +19 -29
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/agents_wrapper.py +68 -41
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/api_client.py +4 -3
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/models.py +1 -1
- {veris_ai-1.8.1 → veris_ai-1.9.0}/tests/test_agents_wrapper_simple.py +115 -136
- veris_ai-1.9.0/tests/test_veris_runner_tool_options.py +317 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/uv.lock +1 -1
- {veris_ai-1.8.1 → veris_ai-1.9.0}/.cursor/rules/documentation-management.mdc +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/.github/workflows/release.yml +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/.github/workflows/test.yml +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/.gitignore +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/.pre-commit-config.yaml +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/CHANGELOG.md +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/CLAUDE.md +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/LICENSE +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/examples/README.md +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/examples/__init__.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/examples/import_options.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/README.md +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/jaeger_interface/README.md +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/jaeger_interface/__init__.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/jaeger_interface/client.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/jaeger_interface/models.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/logging.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/observability.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/tool_mock.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/src/veris_ai/utils.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/tests/README.md +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/tests/__init__.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/tests/conftest.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/tests/fixtures/__init__.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/tests/fixtures/http_server.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/tests/fixtures/simple_app.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/tests/test_agents_wrapper_extract.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/tests/test_mcp_protocol_server_mocked.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/tests/test_tool_mock.py +0 -0
- {veris_ai-1.8.1 → veris_ai-1.9.0}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: veris-ai
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.9.0
|
|
4
4
|
Summary: A Python package for Veris AI tools
|
|
5
5
|
Project-URL: Homepage, https://github.com/veris-ai/veris-python-sdk
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/veris-ai/veris-python-sdk/issues
|
|
@@ -47,7 +47,7 @@ A Python package for Veris AI tools with simulation capabilities and FastAPI MCP
|
|
|
47
47
|
## Quick Reference
|
|
48
48
|
|
|
49
49
|
**Purpose**: Tool mocking, tracing, and FastAPI MCP integration for AI agent development
|
|
50
|
-
**Core Components**: [`tool_mock`](#function-mocking) • [`api_client`](src/veris_ai/api_client.py) • [`observability`](#sdk-observability-helpers) • [`fastapi_mcp`](#fastapi-mcp-integration) • [`jaeger_interface`](#jaeger-trace-interface)
|
|
50
|
+
**Core Components**: [`tool_mock`](#function-mocking) • [`api_client`](src/veris_ai/api_client.py) • [`observability`](#sdk-observability-helpers) • [`agents_wrapper`](#openai-agents-integration) • [`fastapi_mcp`](#fastapi-mcp-integration) • [`jaeger_interface`](#jaeger-trace-interface)
|
|
51
51
|
**Deep Dive**: [`Module Architecture`](src/veris_ai/README.md) • [`Testing Guide`](tests/README.md) • [`Usage Examples`](examples/README.md)
|
|
52
52
|
**Source of Truth**: Implementation details in [`src/veris_ai/`](src/veris_ai/) source code
|
|
53
53
|
|
|
@@ -58,13 +58,14 @@ A Python package for Veris AI tools with simulation capabilities and FastAPI MCP
|
|
|
58
58
|
uv add veris-ai
|
|
59
59
|
|
|
60
60
|
# With optional extras
|
|
61
|
-
uv add "veris-ai[dev,fastapi,
|
|
61
|
+
uv add "veris-ai[dev,fastapi,observability,agents]"
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
**Installation Profiles**:
|
|
65
65
|
- `dev`: Development tools (ruff, pytest, mypy)
|
|
66
66
|
- `fastapi`: FastAPI MCP integration
|
|
67
67
|
- `observability`: OpenTelemetry tracing
|
|
68
|
+
- `agents`: OpenAI agents integration
|
|
68
69
|
|
|
69
70
|
## Import Patterns
|
|
70
71
|
|
|
@@ -75,10 +76,11 @@ uv add "veris-ai[dev,fastapi,instrument]"
|
|
|
75
76
|
from veris_ai import veris, JaegerClient
|
|
76
77
|
|
|
77
78
|
# Optional features (require extras)
|
|
78
|
-
from veris_ai import init_observability, instrument_fastapi_app #
|
|
79
|
+
from veris_ai import init_observability, instrument_fastapi_app # Requires observability extras
|
|
80
|
+
from veris_ai import Runner, VerisConfig # Requires agents extras
|
|
79
81
|
```
|
|
80
82
|
|
|
81
|
-
**Complete Import Strategies**: See [`examples/README.md`](examples/README.md) for
|
|
83
|
+
**Complete Import Strategies**: See [`examples/README.md`](examples/README.md) for different import approaches, conditional features, and integration patterns.
|
|
82
84
|
|
|
83
85
|
## Configuration
|
|
84
86
|
|
|
@@ -182,6 +184,107 @@ async def get_data() -> dict:
|
|
|
182
184
|
|
|
183
185
|
**Implementation**: See [`src/veris_ai/tool_mock.py`](src/veris_ai/tool_mock.py) for decorator logic and API integration.
|
|
184
186
|
|
|
187
|
+
## OpenAI Agents Integration
|
|
188
|
+
|
|
189
|
+
**Semantic Tag**: `openai-agents`
|
|
190
|
+
|
|
191
|
+
The SDK provides seamless integration with [OpenAI's agents library](https://github.com/openai/agents) through the `Runner` class, which extends OpenAI's Runner to intercept tool calls and route them through Veris's mocking infrastructure.
|
|
192
|
+
|
|
193
|
+
### Installation
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Install with agents support
|
|
197
|
+
uv add "veris-ai[agents]"
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Basic Usage
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
from veris_ai import veris, Runner, VerisConfig
|
|
204
|
+
from agents import Agent, function_tool
|
|
205
|
+
|
|
206
|
+
# Define your tools
|
|
207
|
+
@function_tool
|
|
208
|
+
def calculator(x: int, y: int, operation: str = "add") -> int:
|
|
209
|
+
"""Performs arithmetic operations."""
|
|
210
|
+
# ... implementation ...
|
|
211
|
+
|
|
212
|
+
# Create an agent with tools
|
|
213
|
+
agent = Agent(
|
|
214
|
+
name="Assistant",
|
|
215
|
+
model="gpt-4",
|
|
216
|
+
tools=[calculator],
|
|
217
|
+
instructions="You are a helpful assistant.",
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
# Use Veris Runner instead of OpenAI's Runner
|
|
221
|
+
result = await Runner.run(agent, "Calculate 10 + 5")
|
|
222
|
+
|
|
223
|
+
# Or with configuration
|
|
224
|
+
config = VerisConfig(include_tools=["calculator"])
|
|
225
|
+
result = await Runner.run(agent, "Calculate 10 + 5", veris_config=config)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Selective Tool Interception
|
|
229
|
+
|
|
230
|
+
Control which tools are intercepted using VerisConfig:
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
from veris_ai import Runner, VerisConfig
|
|
234
|
+
|
|
235
|
+
# Only intercept specific tools
|
|
236
|
+
config = VerisConfig(include_tools=["calculator", "search_web"])
|
|
237
|
+
result = await Runner.run(agent, "Process this", veris_config=config)
|
|
238
|
+
|
|
239
|
+
# Or exclude specific tools from interception
|
|
240
|
+
config = VerisConfig(exclude_tools=["get_weather"])
|
|
241
|
+
result = await Runner.run(agent, "Check weather", veris_config=config)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Advanced Tool Configuration
|
|
245
|
+
|
|
246
|
+
Fine-tune individual tool behavior using `ToolCallOptions`:
|
|
247
|
+
|
|
248
|
+
```python
|
|
249
|
+
from veris_ai import Runner, VerisConfig, ResponseExpectation, ToolCallOptions
|
|
250
|
+
|
|
251
|
+
# Configure specific tool behaviors
|
|
252
|
+
config = VerisConfig(
|
|
253
|
+
tool_options={
|
|
254
|
+
"calculator": ToolCallOptions(
|
|
255
|
+
response_expectation=ResponseExpectation.REQUIRED, # Always expect response
|
|
256
|
+
cache_response=True, # Cache responses for identical calls
|
|
257
|
+
mode="tool" # Use tool mode (default)
|
|
258
|
+
),
|
|
259
|
+
"search_web": ToolCallOptions(
|
|
260
|
+
response_expectation=ResponseExpectation.NONE, # Don't wait for response
|
|
261
|
+
cache_response=False,
|
|
262
|
+
mode="spy" # Log calls but execute normally
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
result = await Runner.run(agent, "Calculate and search", veris_config=config)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**ToolCallOptions Parameters**:
|
|
271
|
+
- `response_expectation`: Control response behavior
|
|
272
|
+
- `AUTO` (default): Automatically determine based on context
|
|
273
|
+
- `REQUIRED`: Always wait for mock response
|
|
274
|
+
- `NONE`: Don't wait for response
|
|
275
|
+
- `cache_response`: Cache responses for identical tool calls
|
|
276
|
+
- `mode`: Tool execution mode
|
|
277
|
+
- `"tool"` (default): Standard tool execution
|
|
278
|
+
- `"function"`: Function mode
|
|
279
|
+
|
|
280
|
+
**Key Features**:
|
|
281
|
+
- **Drop-in replacement**: Use `Runner` from veris_ai instead of OpenAI's Runner
|
|
282
|
+
- **Extends OpenAI Runner**: Inherits all functionality while adding Veris capabilities
|
|
283
|
+
- **Automatic session management**: Integrates with Veris session IDs
|
|
284
|
+
- **Selective mocking**: Include or exclude specific tools from interception
|
|
285
|
+
|
|
286
|
+
**Implementation**: See [`src/veris_ai/agents_wrapper.py`](src/veris_ai/agents_wrapper.py) for the integration logic and [`examples/openai_agents_example.py`](examples/openai_agents_example.py) for complete examples.
|
|
287
|
+
|
|
185
288
|
## FastAPI MCP Integration
|
|
186
289
|
|
|
187
290
|
**Semantic Tag**: `fastapi-mcp`
|
|
@@ -254,7 +357,7 @@ pytest --cov=veris_ai # Test with coverage
|
|
|
254
357
|
|
|
255
358
|
**Semantic Tag**: `module-architecture`
|
|
256
359
|
|
|
257
|
-
**Core Modules**: `tool_mock` (mocking), `api_client` (centralized API), `jaeger_interface` (trace queries), `utils` (schema conversion)
|
|
360
|
+
**Core Modules**: `tool_mock` (mocking), `api_client` (centralized API), `agents_wrapper` (OpenAI agents integration), `jaeger_interface` (trace queries), `utils` (schema conversion)
|
|
258
361
|
|
|
259
362
|
**Complete Architecture**: See [`src/veris_ai/README.md`](src/veris_ai/README.md) for module overview, implementation flows, and configuration details.
|
|
260
363
|
|
|
@@ -5,7 +5,7 @@ A Python package for Veris AI tools with simulation capabilities and FastAPI MCP
|
|
|
5
5
|
## Quick Reference
|
|
6
6
|
|
|
7
7
|
**Purpose**: Tool mocking, tracing, and FastAPI MCP integration for AI agent development
|
|
8
|
-
**Core Components**: [`tool_mock`](#function-mocking) • [`api_client`](src/veris_ai/api_client.py) • [`observability`](#sdk-observability-helpers) • [`fastapi_mcp`](#fastapi-mcp-integration) • [`jaeger_interface`](#jaeger-trace-interface)
|
|
8
|
+
**Core Components**: [`tool_mock`](#function-mocking) • [`api_client`](src/veris_ai/api_client.py) • [`observability`](#sdk-observability-helpers) • [`agents_wrapper`](#openai-agents-integration) • [`fastapi_mcp`](#fastapi-mcp-integration) • [`jaeger_interface`](#jaeger-trace-interface)
|
|
9
9
|
**Deep Dive**: [`Module Architecture`](src/veris_ai/README.md) • [`Testing Guide`](tests/README.md) • [`Usage Examples`](examples/README.md)
|
|
10
10
|
**Source of Truth**: Implementation details in [`src/veris_ai/`](src/veris_ai/) source code
|
|
11
11
|
|
|
@@ -16,13 +16,14 @@ A Python package for Veris AI tools with simulation capabilities and FastAPI MCP
|
|
|
16
16
|
uv add veris-ai
|
|
17
17
|
|
|
18
18
|
# With optional extras
|
|
19
|
-
uv add "veris-ai[dev,fastapi,
|
|
19
|
+
uv add "veris-ai[dev,fastapi,observability,agents]"
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
**Installation Profiles**:
|
|
23
23
|
- `dev`: Development tools (ruff, pytest, mypy)
|
|
24
24
|
- `fastapi`: FastAPI MCP integration
|
|
25
25
|
- `observability`: OpenTelemetry tracing
|
|
26
|
+
- `agents`: OpenAI agents integration
|
|
26
27
|
|
|
27
28
|
## Import Patterns
|
|
28
29
|
|
|
@@ -33,10 +34,11 @@ uv add "veris-ai[dev,fastapi,instrument]"
|
|
|
33
34
|
from veris_ai import veris, JaegerClient
|
|
34
35
|
|
|
35
36
|
# Optional features (require extras)
|
|
36
|
-
from veris_ai import init_observability, instrument_fastapi_app #
|
|
37
|
+
from veris_ai import init_observability, instrument_fastapi_app # Requires observability extras
|
|
38
|
+
from veris_ai import Runner, VerisConfig # Requires agents extras
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
**Complete Import Strategies**: See [`examples/README.md`](examples/README.md) for
|
|
41
|
+
**Complete Import Strategies**: See [`examples/README.md`](examples/README.md) for different import approaches, conditional features, and integration patterns.
|
|
40
42
|
|
|
41
43
|
## Configuration
|
|
42
44
|
|
|
@@ -140,6 +142,107 @@ async def get_data() -> dict:
|
|
|
140
142
|
|
|
141
143
|
**Implementation**: See [`src/veris_ai/tool_mock.py`](src/veris_ai/tool_mock.py) for decorator logic and API integration.
|
|
142
144
|
|
|
145
|
+
## OpenAI Agents Integration
|
|
146
|
+
|
|
147
|
+
**Semantic Tag**: `openai-agents`
|
|
148
|
+
|
|
149
|
+
The SDK provides seamless integration with [OpenAI's agents library](https://github.com/openai/agents) through the `Runner` class, which extends OpenAI's Runner to intercept tool calls and route them through Veris's mocking infrastructure.
|
|
150
|
+
|
|
151
|
+
### Installation
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Install with agents support
|
|
155
|
+
uv add "veris-ai[agents]"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Basic Usage
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from veris_ai import veris, Runner, VerisConfig
|
|
162
|
+
from agents import Agent, function_tool
|
|
163
|
+
|
|
164
|
+
# Define your tools
|
|
165
|
+
@function_tool
|
|
166
|
+
def calculator(x: int, y: int, operation: str = "add") -> int:
|
|
167
|
+
"""Performs arithmetic operations."""
|
|
168
|
+
# ... implementation ...
|
|
169
|
+
|
|
170
|
+
# Create an agent with tools
|
|
171
|
+
agent = Agent(
|
|
172
|
+
name="Assistant",
|
|
173
|
+
model="gpt-4",
|
|
174
|
+
tools=[calculator],
|
|
175
|
+
instructions="You are a helpful assistant.",
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
# Use Veris Runner instead of OpenAI's Runner
|
|
179
|
+
result = await Runner.run(agent, "Calculate 10 + 5")
|
|
180
|
+
|
|
181
|
+
# Or with configuration
|
|
182
|
+
config = VerisConfig(include_tools=["calculator"])
|
|
183
|
+
result = await Runner.run(agent, "Calculate 10 + 5", veris_config=config)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Selective Tool Interception
|
|
187
|
+
|
|
188
|
+
Control which tools are intercepted using VerisConfig:
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
from veris_ai import Runner, VerisConfig
|
|
192
|
+
|
|
193
|
+
# Only intercept specific tools
|
|
194
|
+
config = VerisConfig(include_tools=["calculator", "search_web"])
|
|
195
|
+
result = await Runner.run(agent, "Process this", veris_config=config)
|
|
196
|
+
|
|
197
|
+
# Or exclude specific tools from interception
|
|
198
|
+
config = VerisConfig(exclude_tools=["get_weather"])
|
|
199
|
+
result = await Runner.run(agent, "Check weather", veris_config=config)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Advanced Tool Configuration
|
|
203
|
+
|
|
204
|
+
Fine-tune individual tool behavior using `ToolCallOptions`:
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
from veris_ai import Runner, VerisConfig, ResponseExpectation, ToolCallOptions
|
|
208
|
+
|
|
209
|
+
# Configure specific tool behaviors
|
|
210
|
+
config = VerisConfig(
|
|
211
|
+
tool_options={
|
|
212
|
+
"calculator": ToolCallOptions(
|
|
213
|
+
response_expectation=ResponseExpectation.REQUIRED, # Always expect response
|
|
214
|
+
cache_response=True, # Cache responses for identical calls
|
|
215
|
+
mode="tool" # Use tool mode (default)
|
|
216
|
+
),
|
|
217
|
+
"search_web": ToolCallOptions(
|
|
218
|
+
response_expectation=ResponseExpectation.NONE, # Don't wait for response
|
|
219
|
+
cache_response=False,
|
|
220
|
+
mode="spy" # Log calls but execute normally
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
result = await Runner.run(agent, "Calculate and search", veris_config=config)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**ToolCallOptions Parameters**:
|
|
229
|
+
- `response_expectation`: Control response behavior
|
|
230
|
+
- `AUTO` (default): Automatically determine based on context
|
|
231
|
+
- `REQUIRED`: Always wait for mock response
|
|
232
|
+
- `NONE`: Don't wait for response
|
|
233
|
+
- `cache_response`: Cache responses for identical tool calls
|
|
234
|
+
- `mode`: Tool execution mode
|
|
235
|
+
- `"tool"` (default): Standard tool execution
|
|
236
|
+
- `"function"`: Function mode
|
|
237
|
+
|
|
238
|
+
**Key Features**:
|
|
239
|
+
- **Drop-in replacement**: Use `Runner` from veris_ai instead of OpenAI's Runner
|
|
240
|
+
- **Extends OpenAI Runner**: Inherits all functionality while adding Veris capabilities
|
|
241
|
+
- **Automatic session management**: Integrates with Veris session IDs
|
|
242
|
+
- **Selective mocking**: Include or exclude specific tools from interception
|
|
243
|
+
|
|
244
|
+
**Implementation**: See [`src/veris_ai/agents_wrapper.py`](src/veris_ai/agents_wrapper.py) for the integration logic and [`examples/openai_agents_example.py`](examples/openai_agents_example.py) for complete examples.
|
|
245
|
+
|
|
143
246
|
## FastAPI MCP Integration
|
|
144
247
|
|
|
145
248
|
**Semantic Tag**: `fastapi-mcp`
|
|
@@ -212,7 +315,7 @@ pytest --cov=veris_ai # Test with coverage
|
|
|
212
315
|
|
|
213
316
|
**Semantic Tag**: `module-architecture`
|
|
214
317
|
|
|
215
|
-
**Core Modules**: `tool_mock` (mocking), `api_client` (centralized API), `jaeger_interface` (trace queries), `utils` (schema conversion)
|
|
318
|
+
**Core Modules**: `tool_mock` (mocking), `api_client` (centralized API), `agents_wrapper` (OpenAI agents integration), `jaeger_interface` (trace queries), `utils` (schema conversion)
|
|
216
319
|
|
|
217
320
|
**Complete Architecture**: See [`src/veris_ai/README.md`](src/veris_ai/README.md) for module overview, implementation flows, and configuration details.
|
|
218
321
|
|
|
@@ -4,15 +4,17 @@ import asyncio
|
|
|
4
4
|
import os
|
|
5
5
|
import sys
|
|
6
6
|
|
|
7
|
-
from veris_ai import veris,
|
|
7
|
+
from veris_ai import veris, Runner, VerisConfig
|
|
8
8
|
|
|
9
9
|
# Ensure the openai-agents package is installed
|
|
10
10
|
try:
|
|
11
|
-
from agents import Agent,
|
|
11
|
+
from agents import Agent, function_tool
|
|
12
12
|
except ImportError:
|
|
13
13
|
print("Please install the openai-agents package: pip install veris-ai[agents]")
|
|
14
14
|
sys.exit(1)
|
|
15
15
|
|
|
16
|
+
# Note: The Veris Runner extends OpenAI's Runner, providing a seamless upgrade path
|
|
17
|
+
|
|
16
18
|
|
|
17
19
|
# Define some example tools
|
|
18
20
|
@function_tool
|
|
@@ -42,9 +44,9 @@ def get_weather(location: str) -> str:
|
|
|
42
44
|
|
|
43
45
|
|
|
44
46
|
async def example_basic_wrap() -> None:
|
|
45
|
-
"""Basic example:
|
|
47
|
+
"""Basic example: Intercept all tools using Runner (recommended)."""
|
|
46
48
|
print("\n" + "=" * 60)
|
|
47
|
-
print("Example 1: Basic
|
|
49
|
+
print("Example 1: Basic - All Tools Intercepted (New Runner Class)")
|
|
48
50
|
print("=" * 60)
|
|
49
51
|
|
|
50
52
|
# Create an agent with tools
|
|
@@ -55,18 +57,15 @@ async def example_basic_wrap() -> None:
|
|
|
55
57
|
instructions="You are a helpful assistant with various tools.",
|
|
56
58
|
)
|
|
57
59
|
|
|
58
|
-
#
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
# Use it like normal Runner.run
|
|
62
|
-
result = await wrapped_run(agent, "What's 10 + 5? Also search for Python tutorials.")
|
|
60
|
+
# Use the new Runner class (recommended approach)
|
|
61
|
+
result = await Runner.run(agent, "What's 10 + 5? Also search for Python tutorials.")
|
|
63
62
|
print(f"Result: {result.output}")
|
|
64
63
|
|
|
65
64
|
|
|
66
65
|
async def example_selective_wrap() -> None:
|
|
67
|
-
"""Example with selective tool interception."""
|
|
66
|
+
"""Example with selective tool interception using Runner with config."""
|
|
68
67
|
print("\n" + "=" * 60)
|
|
69
|
-
print("Example 2: Selective
|
|
68
|
+
print("Example 2: Selective - Only Specific Tools (With Config)")
|
|
70
69
|
print("=" * 60)
|
|
71
70
|
|
|
72
71
|
agent = Agent(
|
|
@@ -76,13 +75,12 @@ async def example_selective_wrap() -> None:
|
|
|
76
75
|
instructions="You are a helpful assistant.",
|
|
77
76
|
)
|
|
78
77
|
|
|
79
|
-
# Only intercept calculator and search_web
|
|
80
|
-
wrapped_run = wrap(Runner.run, include_tools=["calculator", "search_web"])
|
|
81
|
-
|
|
82
78
|
print("📝 Only 'calculator' and 'search_web' will be mocked via Veris")
|
|
83
79
|
print(" 'get_weather' will run normally")
|
|
84
80
|
|
|
85
|
-
|
|
81
|
+
# Create configuration and use Runner.run
|
|
82
|
+
config = VerisConfig(include_tools=["calculator", "search_web"])
|
|
83
|
+
result = await Runner.run(agent, "Calculate 5+3 and check weather in NYC", veris_config=config)
|
|
86
84
|
print(f"Result: {result.output}")
|
|
87
85
|
|
|
88
86
|
|
|
@@ -99,19 +97,20 @@ async def example_exclude_tools() -> None:
|
|
|
99
97
|
instructions="You are a helpful assistant.",
|
|
100
98
|
)
|
|
101
99
|
|
|
102
|
-
# Intercept everything EXCEPT get_weather
|
|
103
|
-
wrapped_run = wrap(Runner.run, exclude_tools=["get_weather"])
|
|
104
|
-
|
|
105
100
|
print("📝 All tools EXCEPT 'get_weather' will be mocked via Veris")
|
|
106
101
|
|
|
107
|
-
|
|
102
|
+
# Use Runner.run with exclude_tools config
|
|
103
|
+
config = VerisConfig(exclude_tools=["get_weather"])
|
|
104
|
+
result = await Runner.run(
|
|
105
|
+
agent, "Calculate 10*5 and check weather in London", veris_config=config
|
|
106
|
+
)
|
|
108
107
|
print(f"Result: {result.output}")
|
|
109
108
|
|
|
110
109
|
|
|
111
|
-
async def
|
|
112
|
-
"""Example
|
|
110
|
+
async def example_simple_calculation() -> None:
|
|
111
|
+
"""Example with simple calculation tool."""
|
|
113
112
|
print("\n" + "=" * 60)
|
|
114
|
-
print("Example 4: Direct
|
|
113
|
+
print("Example 4: Simple Calculation (Direct Runner.run)")
|
|
115
114
|
print("=" * 60)
|
|
116
115
|
|
|
117
116
|
agent = Agent(
|
|
@@ -121,8 +120,8 @@ async def example_coroutine_wrap() -> None:
|
|
|
121
120
|
instructions="You are a helpful assistant.",
|
|
122
121
|
)
|
|
123
122
|
|
|
124
|
-
#
|
|
125
|
-
result = await
|
|
123
|
+
# Use Runner.run directly (like OpenAI's Runner)
|
|
124
|
+
result = await Runner.run(agent, "What's 7 * 8?")
|
|
126
125
|
print(f"Result: {result.output}")
|
|
127
126
|
|
|
128
127
|
|
|
@@ -131,6 +130,7 @@ async def main() -> None:
|
|
|
131
130
|
print("\n🚀 VERIS SDK - OPENAI AGENTS WRAPPER EXAMPLES")
|
|
132
131
|
print("\nThese examples demonstrate different ways to intercept tool calls")
|
|
133
132
|
print("from OpenAI agents and route them through the Veris SDK.\n")
|
|
133
|
+
print("🆕 Using the Veris Runner class that extends OpenAI's Runner!\n")
|
|
134
134
|
|
|
135
135
|
# Set up the environment
|
|
136
136
|
# In production, these would be set as environment variables
|
|
@@ -153,7 +153,7 @@ async def main() -> None:
|
|
|
153
153
|
await example_basic_wrap()
|
|
154
154
|
await example_selective_wrap()
|
|
155
155
|
await example_exclude_tools()
|
|
156
|
-
await
|
|
156
|
+
await example_simple_calculation()
|
|
157
157
|
except Exception as e:
|
|
158
158
|
print(f"\n❌ Error: {e}")
|
|
159
159
|
print("\nMake sure to:")
|
|
@@ -169,7 +169,14 @@ async def main() -> None:
|
|
|
169
169
|
print("\nNext steps:")
|
|
170
170
|
print("1. Set up your Veris endpoint")
|
|
171
171
|
print("2. Configure your OpenAI API key")
|
|
172
|
-
print("3. Use
|
|
172
|
+
print("3. Use the Runner class from veris_ai to intercept tool calls")
|
|
173
|
+
print("\n💡 Usage:")
|
|
174
|
+
print(" from veris_ai import Runner, VerisConfig")
|
|
175
|
+
print(" # Direct usage without config")
|
|
176
|
+
print(" result = await Runner.run(agent, 'your input')")
|
|
177
|
+
print(" # With configuration")
|
|
178
|
+
print(" config = VerisConfig(include_tools=['tool1'])")
|
|
179
|
+
print(" result = await Runner.run(agent, 'your input', veris_config=config)")
|
|
173
180
|
|
|
174
181
|
|
|
175
182
|
if __name__ == "__main__":
|
|
@@ -6,42 +6,31 @@ __version__ = "0.1.0"
|
|
|
6
6
|
|
|
7
7
|
# Import lightweight modules that only use base dependencies
|
|
8
8
|
from .jaeger_interface import JaegerClient
|
|
9
|
-
from .models import ResponseExpectation
|
|
9
|
+
from .models import ResponseExpectation, ToolCallOptions
|
|
10
10
|
from .observability import init_observability, instrument_fastapi_app
|
|
11
11
|
from .tool_mock import veris
|
|
12
12
|
|
|
13
13
|
# Lazy import for modules with heavy dependencies
|
|
14
|
-
|
|
14
|
+
_Runner = None
|
|
15
15
|
_VerisConfig = None
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def veris_runner(*args: Any, **kwargs: Any) -> Any: # noqa: ANN401
|
|
19
|
-
"""Lazy loader for the veris_runner function from agents_wrapper.
|
|
20
|
-
|
|
21
|
-
This function wraps OpenAI agents Runner.run to intercept tool calls
|
|
22
|
-
through the Veris SDK's mocking infrastructure.
|
|
23
|
-
|
|
24
|
-
This function requires the 'agents' extra dependencies:
|
|
25
|
-
pip install veris-ai[agents]
|
|
26
|
-
"""
|
|
27
|
-
global _veris_runner # noqa: PLW0603
|
|
28
|
-
if _veris_runner is None:
|
|
29
|
-
try:
|
|
30
|
-
from .agents_wrapper import veris_runner as _veris_runner_impl # noqa: PLC0415
|
|
31
|
-
|
|
32
|
-
_veris_runner = _veris_runner_impl
|
|
33
|
-
except ImportError as e:
|
|
34
|
-
error_msg = (
|
|
35
|
-
"The 'veris_runner' function requires additional dependencies. "
|
|
36
|
-
"Please install them with: pip install veris-ai[agents]"
|
|
37
|
-
)
|
|
38
|
-
raise ImportError(error_msg) from e
|
|
39
|
-
return _veris_runner(*args, **kwargs)
|
|
40
|
-
|
|
41
|
-
|
|
42
18
|
def __getattr__(name: str) -> Any: # noqa: ANN401
|
|
43
|
-
"""Lazy load VerisConfig
|
|
44
|
-
global _VerisConfig # noqa: PLW0603
|
|
19
|
+
"""Lazy load Runner and VerisConfig classes."""
|
|
20
|
+
global _Runner, _VerisConfig # noqa: PLW0603
|
|
21
|
+
if name == "Runner":
|
|
22
|
+
if _Runner is None:
|
|
23
|
+
try:
|
|
24
|
+
from .agents_wrapper import Runner as _Runner_impl # noqa: PLC0415
|
|
25
|
+
|
|
26
|
+
_Runner = _Runner_impl
|
|
27
|
+
except ImportError as e:
|
|
28
|
+
error_msg = (
|
|
29
|
+
"The 'Runner' class requires additional dependencies. "
|
|
30
|
+
"Please install them with: pip install veris-ai[agents]"
|
|
31
|
+
)
|
|
32
|
+
raise ImportError(error_msg) from e
|
|
33
|
+
return _Runner
|
|
45
34
|
if name == "VerisConfig":
|
|
46
35
|
if _VerisConfig is None:
|
|
47
36
|
try:
|
|
@@ -63,8 +52,9 @@ __all__ = [
|
|
|
63
52
|
"veris",
|
|
64
53
|
"JaegerClient",
|
|
65
54
|
"ResponseExpectation",
|
|
55
|
+
"ToolCallOptions",
|
|
66
56
|
"init_observability",
|
|
67
57
|
"instrument_fastapi_app",
|
|
68
|
-
"
|
|
58
|
+
"Runner",
|
|
69
59
|
"VerisConfig",
|
|
70
60
|
]
|