vantinel-sdk 0.3.0b0__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 vantinel-sdk might be problematic. Click here for more details.
- vantinel_sdk-0.3.0b0/.gitignore +72 -0
- vantinel_sdk-0.3.0b0/Makefile +76 -0
- vantinel_sdk-0.3.0b0/PKG-INFO +410 -0
- vantinel_sdk-0.3.0b0/QUICKSTART.md +216 -0
- vantinel_sdk-0.3.0b0/README.md +374 -0
- vantinel_sdk-0.3.0b0/SDK_IMPLEMENTATION.md +425 -0
- vantinel_sdk-0.3.0b0/TASK_11_COMPLETE.md +507 -0
- vantinel_sdk-0.3.0b0/examples/basic_usage.py +103 -0
- vantinel_sdk-0.3.0b0/examples/decorator_example.py +71 -0
- vantinel_sdk-0.3.0b0/examples/full_agent_example.py +176 -0
- vantinel_sdk-0.3.0b0/examples/high_volume_sampling.py +77 -0
- vantinel_sdk-0.3.0b0/examples/langchain_integration.py +82 -0
- vantinel_sdk-0.3.0b0/pyproject.toml +70 -0
- vantinel_sdk-0.3.0b0/pytest.ini +10 -0
- vantinel_sdk-0.3.0b0/requirements.txt +10 -0
- vantinel_sdk-0.3.0b0/setup.cfg +4 -0
- vantinel_sdk-0.3.0b0/setup.py +50 -0
- vantinel_sdk-0.3.0b0/setup_cython.py +33 -0
- vantinel_sdk-0.3.0b0/tests/conftest.py +12 -0
- vantinel_sdk-0.3.0b0/tests/test_client.py +91 -0
- vantinel_sdk-0.3.0b0/tests/test_cost.py +66 -0
- vantinel_sdk-0.3.0b0/tests/test_integration.py +147 -0
- vantinel_sdk-0.3.0b0/tests/test_monitor.py +218 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk/__init__.py +60 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk/client.py +199 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk/config.py +136 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk/cost.py +79 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk/errors.py +33 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk/monitor.py +573 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk/security.py +143 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk/types.py +107 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk.egg-info/PKG-INFO +410 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk.egg-info/SOURCES.txt +34 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk.egg-info/dependency_links.txt +1 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk.egg-info/requires.txt +9 -0
- vantinel_sdk-0.3.0b0/vantinel_sdk.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Unit test / coverage reports
|
|
35
|
+
htmlcov/
|
|
36
|
+
.tox/
|
|
37
|
+
.nox/
|
|
38
|
+
.coverage
|
|
39
|
+
.coverage.*
|
|
40
|
+
.cache
|
|
41
|
+
nosetests.xml
|
|
42
|
+
coverage.xml
|
|
43
|
+
*.cover
|
|
44
|
+
*.py,cover
|
|
45
|
+
.hypothesis/
|
|
46
|
+
.pytest_cache/
|
|
47
|
+
|
|
48
|
+
# Virtual environments
|
|
49
|
+
venv/
|
|
50
|
+
ENV/
|
|
51
|
+
env/
|
|
52
|
+
.venv
|
|
53
|
+
|
|
54
|
+
# IDEs
|
|
55
|
+
.vscode/
|
|
56
|
+
.idea/
|
|
57
|
+
*.swp
|
|
58
|
+
*.swo
|
|
59
|
+
*~
|
|
60
|
+
|
|
61
|
+
# OS
|
|
62
|
+
.DS_Store
|
|
63
|
+
Thumbs.db
|
|
64
|
+
|
|
65
|
+
# Type checking
|
|
66
|
+
.mypy_cache/
|
|
67
|
+
.dmypy.json
|
|
68
|
+
dmypy.json
|
|
69
|
+
.pytype/
|
|
70
|
+
|
|
71
|
+
# Ruff
|
|
72
|
+
.ruff_cache/
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.PHONY: install test format lint clean build help build-secure audit
|
|
2
|
+
|
|
3
|
+
help: ## Show this help message
|
|
4
|
+
@echo "Available commands:"
|
|
5
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
|
6
|
+
|
|
7
|
+
install: ## Install package in development mode
|
|
8
|
+
pip install -e ".[dev]"
|
|
9
|
+
|
|
10
|
+
test: ## Run all tests
|
|
11
|
+
pytest tests/ -v
|
|
12
|
+
|
|
13
|
+
test-unit: ## Run unit tests only (skip integration tests)
|
|
14
|
+
pytest tests/ -v -m "not integration"
|
|
15
|
+
|
|
16
|
+
test-integration: ## Run integration tests only (requires collector running)
|
|
17
|
+
pytest tests/ -v -m "integration"
|
|
18
|
+
|
|
19
|
+
format: ## Format code with black
|
|
20
|
+
black vantinel_sdk/ tests/ examples/
|
|
21
|
+
|
|
22
|
+
lint: ## Lint code with ruff
|
|
23
|
+
ruff check vantinel_sdk/ tests/ examples/
|
|
24
|
+
|
|
25
|
+
type-check: ## Run mypy type checker
|
|
26
|
+
mypy vantinel_sdk/
|
|
27
|
+
|
|
28
|
+
clean: ## Clean build artifacts
|
|
29
|
+
rm -rf build/
|
|
30
|
+
rm -rf dist/
|
|
31
|
+
rm -rf *.egg-info
|
|
32
|
+
rm -rf .pytest_cache
|
|
33
|
+
rm -rf .mypy_cache
|
|
34
|
+
rm -rf .ruff_cache
|
|
35
|
+
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
|
36
|
+
find . -type f -name "*.pyc" -delete
|
|
37
|
+
|
|
38
|
+
build: ## Build distribution packages
|
|
39
|
+
python -m build
|
|
40
|
+
|
|
41
|
+
publish-test: ## Publish to Test PyPI
|
|
42
|
+
python -m twine upload --repository testpypi dist/*
|
|
43
|
+
|
|
44
|
+
publish: ## Publish to PyPI
|
|
45
|
+
python -m twine upload dist/*
|
|
46
|
+
|
|
47
|
+
example-basic: ## Run basic usage example
|
|
48
|
+
python examples/basic_usage.py
|
|
49
|
+
|
|
50
|
+
example-decorator: ## Run decorator example
|
|
51
|
+
python examples/decorator_example.py
|
|
52
|
+
|
|
53
|
+
example-langchain: ## Run LangChain integration example
|
|
54
|
+
python examples/langchain_integration.py
|
|
55
|
+
|
|
56
|
+
example-sampling: ## Run high-volume sampling example
|
|
57
|
+
python examples/high_volume_sampling.py
|
|
58
|
+
|
|
59
|
+
run-examples: ## Run all examples
|
|
60
|
+
@echo "Running basic usage..."
|
|
61
|
+
@python examples/basic_usage.py
|
|
62
|
+
@echo "\n\nRunning decorator example..."
|
|
63
|
+
@python examples/decorator_example.py
|
|
64
|
+
@echo "\n\nRunning high-volume sampling..."
|
|
65
|
+
@python examples/high_volume_sampling.py
|
|
66
|
+
|
|
67
|
+
check: format lint type-check test-unit ## Run all checks (format, lint, type-check, tests)
|
|
68
|
+
@echo "All checks passed!"
|
|
69
|
+
|
|
70
|
+
build-secure: ## Build Cython-compiled secure wheel
|
|
71
|
+
pip install cython
|
|
72
|
+
python setup_cython.py bdist_wheel
|
|
73
|
+
|
|
74
|
+
audit: ## Run security audit on dependencies
|
|
75
|
+
pip install pip-audit
|
|
76
|
+
pip-audit
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vantinel-sdk
|
|
3
|
+
Version: 0.3.0b0
|
|
4
|
+
Summary: Lightweight observability and guardrails SDK for AI agents
|
|
5
|
+
Home-page: https://github.com/vantinel/vantinel-sdk
|
|
6
|
+
Author: Vantinel Team
|
|
7
|
+
Author-email: Vantinel Team <team@vantinel.dev>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/vantinel/vantinel-sdk
|
|
10
|
+
Project-URL: Documentation, https://docs.vantinel.dev
|
|
11
|
+
Project-URL: Repository, https://github.com/vantinel/vantinel-sdk
|
|
12
|
+
Project-URL: Bug Tracker, https://github.com/vantinel/vantinel-sdk/issues
|
|
13
|
+
Keywords: observability,monitoring,ai,agents,guardrails,llm
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: httpx>=0.24.0
|
|
26
|
+
Requires-Dist: tiktoken>=0.5.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
30
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
33
|
+
Dynamic: author
|
|
34
|
+
Dynamic: home-page
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
|
|
37
|
+
# Vantinel SDK for Python
|
|
38
|
+
|
|
39
|
+
[](https://pypi.org/project/vantinel-sdk/)
|
|
40
|
+
[](https://pypi.org/project/vantinel-sdk/)
|
|
41
|
+
[](https://opensource.org/licenses/MIT)
|
|
42
|
+
|
|
43
|
+
Lightweight observability and guardrails SDK for AI agents. Monitor, protect, and optimize your autonomous AI systems in real-time.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- **🚨 Zombie Loop Detection** - Automatically detect and prevent infinite loops and retry storms
|
|
48
|
+
- **💰 Cost Control** - Real-time budget tracking and forecasting to prevent runaway costs
|
|
49
|
+
- **🛡️ Safety Guardrails** - Block dangerous operations and require human approval
|
|
50
|
+
- **📊 Performance Monitoring** - Track latency, error rates, and usage patterns
|
|
51
|
+
- **⚡ Zero Overhead** - Async fire-and-forget telemetry with circuit breaker
|
|
52
|
+
- **🎯 Simple API** - 3 lines of code to get started
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
### Installation
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install vantinel-sdk
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Basic Usage
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import asyncio
|
|
66
|
+
from vantinel_sdk import VantinelMonitor, VantinelConfig
|
|
67
|
+
|
|
68
|
+
async def main():
|
|
69
|
+
# Configure the SDK
|
|
70
|
+
config = VantinelConfig(
|
|
71
|
+
api_key="vantinel_abc123",
|
|
72
|
+
client_id="my_company"
|
|
73
|
+
).with_session_budget(5.0)
|
|
74
|
+
|
|
75
|
+
# Create a monitor
|
|
76
|
+
async with VantinelMonitor(config) as monitor:
|
|
77
|
+
# Watch a tool execution
|
|
78
|
+
execution = await monitor.watch_tool(
|
|
79
|
+
"search_database",
|
|
80
|
+
'{"query": "users"}'
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# Execute your tool
|
|
84
|
+
result = await search_database("users")
|
|
85
|
+
|
|
86
|
+
# Report the result
|
|
87
|
+
await execution.success()
|
|
88
|
+
|
|
89
|
+
asyncio.run(main())
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Using the Decorator
|
|
93
|
+
|
|
94
|
+
The easiest way to monitor your tools:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from vantinel_sdk import VantinelMonitor, VantinelConfig
|
|
98
|
+
|
|
99
|
+
config = VantinelConfig(api_key="key", client_id="company")
|
|
100
|
+
monitor = VantinelMonitor(config)
|
|
101
|
+
|
|
102
|
+
@monitor.watch_tool_decorator()
|
|
103
|
+
async def search_database(query: str):
|
|
104
|
+
# Your tool logic
|
|
105
|
+
return results
|
|
106
|
+
|
|
107
|
+
# Now every call is automatically monitored!
|
|
108
|
+
result = await search_database("users")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Architecture
|
|
112
|
+
|
|
113
|
+
The SDK sends telemetry events to the Vantinel Collector, which runs real-time anomaly detection algorithms:
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
┌─────────────────┐
|
|
117
|
+
│ Your Agent │
|
|
118
|
+
│ (Python) │
|
|
119
|
+
└────────┬────────┘
|
|
120
|
+
│ Vantinel SDK
|
|
121
|
+
▼
|
|
122
|
+
┌─────────────────┐ ┌──────────────┐
|
|
123
|
+
│ Collector │─────▶│ Dashboard │
|
|
124
|
+
│ (Algorithms) │ │ (Metrics) │
|
|
125
|
+
└─────────────────┘ └──────────────┘
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### What Gets Sent
|
|
129
|
+
|
|
130
|
+
The SDK only sends **metadata**, never actual data:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"event": "tool_call",
|
|
135
|
+
"client_id": "your_company",
|
|
136
|
+
"session_id": "sess_abc123",
|
|
137
|
+
"tool_name": "search_database",
|
|
138
|
+
"tool_args_hash": "md5:a3f8b9c2...",
|
|
139
|
+
"timestamp": 1675432100000,
|
|
140
|
+
"latency_ms": 45,
|
|
141
|
+
"estimated_cost": 0.002
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
We **never** send:
|
|
146
|
+
- Request/response bodies
|
|
147
|
+
- User queries or prompts
|
|
148
|
+
- Tool arguments (only MD5 hash)
|
|
149
|
+
- Sensitive data
|
|
150
|
+
|
|
151
|
+
## Configuration
|
|
152
|
+
|
|
153
|
+
### From Environment Variables
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
export VANTINEL_API_KEY="your_api_key"
|
|
157
|
+
export VANTINEL_CLIENT_ID="your_company"
|
|
158
|
+
export VANTINEL_AGENT_ID="my_agent"
|
|
159
|
+
export VANTINEL_SESSION_BUDGET="10.0"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from vantinel_sdk import VantinelConfig
|
|
164
|
+
|
|
165
|
+
config = VantinelConfig.from_env()
|
|
166
|
+
monitor = VantinelMonitor(config)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Builder Pattern
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
config = VantinelConfig(
|
|
173
|
+
api_key="test_key",
|
|
174
|
+
client_id="test_client"
|
|
175
|
+
).with_agent_id("my_agent") \
|
|
176
|
+
.with_session_budget(10.0) \
|
|
177
|
+
.with_collector_url("https://collector.vantinel.com") \
|
|
178
|
+
.with_timeout(5.0) \
|
|
179
|
+
.with_batching(100, 1.0) \
|
|
180
|
+
.with_sampling_rate(0.1) # Sample 10% of events
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Advanced Features
|
|
184
|
+
|
|
185
|
+
### Sampling for High-Volume Scenarios
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
# Monitor only 10% of traffic to reduce overhead
|
|
189
|
+
config = VantinelConfig(
|
|
190
|
+
api_key="key",
|
|
191
|
+
client_id="client"
|
|
192
|
+
).with_sampling_rate(0.1)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Session Management
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
# Create a new session
|
|
199
|
+
monitor = VantinelMonitor(config)
|
|
200
|
+
session_id = monitor.session_id
|
|
201
|
+
|
|
202
|
+
# Resume an existing session
|
|
203
|
+
monitor = VantinelMonitor(config, session_id="existing-session-id")
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Statistics
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
# Get session statistics
|
|
210
|
+
total_calls = await monitor.total_calls()
|
|
211
|
+
session_cost = await monitor.session_cost()
|
|
212
|
+
|
|
213
|
+
# Get per-tool statistics
|
|
214
|
+
stats = await monitor.tool_stats("my_tool")
|
|
215
|
+
if stats:
|
|
216
|
+
calls, avg_latency, errors = stats
|
|
217
|
+
print(f"Tool called {calls} times")
|
|
218
|
+
print(f"Average latency: {avg_latency:.2f}ms")
|
|
219
|
+
print(f"Errors: {errors}")
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Testing
|
|
223
|
+
|
|
224
|
+
For local development, use dry-run mode:
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
config = VantinelConfig(
|
|
228
|
+
api_key="test_key",
|
|
229
|
+
client_id="test_client"
|
|
230
|
+
).with_dry_run() \
|
|
231
|
+
.with_verbose() # Print debug info
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Examples
|
|
235
|
+
|
|
236
|
+
### Basic Usage
|
|
237
|
+
```bash
|
|
238
|
+
python examples/basic_usage.py
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Demonstrates:
|
|
242
|
+
- Creating a monitor
|
|
243
|
+
- Watching tool executions
|
|
244
|
+
- Reporting success and errors
|
|
245
|
+
- Checking statistics
|
|
246
|
+
|
|
247
|
+
### Decorator Pattern
|
|
248
|
+
```bash
|
|
249
|
+
python examples/decorator_example.py
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Shows:
|
|
253
|
+
- Using the `@watch_tool_decorator()`
|
|
254
|
+
- Sync and async function support
|
|
255
|
+
- Custom tool naming
|
|
256
|
+
|
|
257
|
+
### LangChain Integration
|
|
258
|
+
```bash
|
|
259
|
+
python examples/langchain_integration.py
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Example of monitoring a LangChain agent.
|
|
263
|
+
|
|
264
|
+
### High-Volume Sampling
|
|
265
|
+
```bash
|
|
266
|
+
python examples/high_volume_sampling.py
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Demonstrates sampling for reducing overhead in high-traffic scenarios.
|
|
270
|
+
|
|
271
|
+
## Circuit Breaker
|
|
272
|
+
|
|
273
|
+
The SDK includes a built-in circuit breaker that fails gracefully if the Collector is unavailable:
|
|
274
|
+
|
|
275
|
+
```python
|
|
276
|
+
config = VantinelConfig(
|
|
277
|
+
api_key="key",
|
|
278
|
+
client_id="client"
|
|
279
|
+
).with_circuit_breaker(
|
|
280
|
+
threshold=3, # Open after 3 failures
|
|
281
|
+
reset_timeout=30 # Reset after 30 seconds
|
|
282
|
+
)
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
States:
|
|
286
|
+
- **Closed**: Normal operation
|
|
287
|
+
- **Open**: Collector unavailable, allow all operations
|
|
288
|
+
- **Half-Open**: Testing if Collector recovered
|
|
289
|
+
|
|
290
|
+
## Error Handling
|
|
291
|
+
|
|
292
|
+
The SDK fails gracefully by default. If the Collector is unreachable, tool calls are allowed to proceed:
|
|
293
|
+
|
|
294
|
+
```python
|
|
295
|
+
from vantinel_sdk.errors import ToolCallBlockedError
|
|
296
|
+
|
|
297
|
+
try:
|
|
298
|
+
execution = await monitor.watch_tool("my_tool", "{}")
|
|
299
|
+
result = await my_tool()
|
|
300
|
+
await execution.success()
|
|
301
|
+
except ToolCallBlockedError as e:
|
|
302
|
+
# Tool call blocked by policy
|
|
303
|
+
print(f"Blocked: {e}")
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Performance
|
|
307
|
+
|
|
308
|
+
- **Latency**: < 1ms overhead per tool call (async fire-and-forget)
|
|
309
|
+
- **Throughput**: 10,000+ events/sec per monitor
|
|
310
|
+
- **Memory**: ~1MB per monitor instance
|
|
311
|
+
- **Network**: ~200 bytes per event
|
|
312
|
+
|
|
313
|
+
## Development
|
|
314
|
+
|
|
315
|
+
### Install in Development Mode
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
cd sdk/python
|
|
319
|
+
pip install -e ".[dev]"
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Run Tests
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
pytest tests/
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Format Code
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
black vantinel_sdk/ tests/ examples/
|
|
332
|
+
ruff check vantinel_sdk/ tests/ examples/
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Type Checking
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
mypy vantinel_sdk/
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Requirements
|
|
342
|
+
|
|
343
|
+
- Python 3.9+
|
|
344
|
+
- httpx >= 0.24.0
|
|
345
|
+
- tiktoken >= 0.5.0 (for token counting)
|
|
346
|
+
|
|
347
|
+
## OpenAI & LangChain Wrappers
|
|
348
|
+
|
|
349
|
+
### OpenAI (3 lines)
|
|
350
|
+
|
|
351
|
+
```python
|
|
352
|
+
from openai import AsyncOpenAI
|
|
353
|
+
from vantinel_sdk import VantinelMonitor, VantinelConfig
|
|
354
|
+
|
|
355
|
+
monitor = VantinelMonitor(VantinelConfig.from_env())
|
|
356
|
+
client = monitor.wrap_openai(AsyncOpenAI())
|
|
357
|
+
# All client.chat.completions.create() calls are now monitored with auto cost tracking
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### LangChain (3 lines)
|
|
361
|
+
|
|
362
|
+
```python
|
|
363
|
+
from langchain_openai import ChatOpenAI
|
|
364
|
+
|
|
365
|
+
monitor = VantinelMonitor(VantinelConfig.from_env())
|
|
366
|
+
llm = monitor.wrap_langchain(ChatOpenAI())
|
|
367
|
+
result = llm.invoke("What is 2+2?") # invoke and ainvoke are both monitored
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## Error Capture
|
|
371
|
+
|
|
372
|
+
```python
|
|
373
|
+
from vantinel_sdk import VantinelMonitor, VantinelConfig
|
|
374
|
+
|
|
375
|
+
monitor = VantinelMonitor(VantinelConfig.from_env())
|
|
376
|
+
|
|
377
|
+
try:
|
|
378
|
+
await my_tool()
|
|
379
|
+
except Exception as e:
|
|
380
|
+
await monitor.capture_error("my_tool", e, metadata={"retry": 1})
|
|
381
|
+
raise
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## Roadmap
|
|
385
|
+
|
|
386
|
+
- [ ] Automatic LlamaIndex integration
|
|
387
|
+
- [ ] Cost estimation for all popular models
|
|
388
|
+
- [ ] Local-first mode with SQLite storage
|
|
389
|
+
- [ ] Java SDK
|
|
390
|
+
|
|
391
|
+
## Contributing
|
|
392
|
+
|
|
393
|
+
Contributions are welcome! Please open an issue or PR.
|
|
394
|
+
|
|
395
|
+
## License
|
|
396
|
+
|
|
397
|
+
Licensed under the MIT license. See [LICENSE](LICENSE) for details.
|
|
398
|
+
|
|
399
|
+
## Support
|
|
400
|
+
|
|
401
|
+
- GitHub Issues: https://github.com/vantinel/vantinel-sdk/issues
|
|
402
|
+
- Email: team@vantinel.com
|
|
403
|
+
- Discord: https://discord.gg/vantinel
|
|
404
|
+
|
|
405
|
+
## Resources
|
|
406
|
+
|
|
407
|
+
- [Documentation](https://docs.vantinel.com)
|
|
408
|
+
- [Examples](examples/)
|
|
409
|
+
- [Dashboard](https://dashboard.vantinel.com)
|
|
410
|
+
- [Project Documentation](../../CLAUDE.md)
|