qveris 0.2.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.
- qveris-0.2.0/.env.example +6 -0
- qveris-0.2.0/.gitignore +207 -0
- qveris-0.2.0/LICENSE +21 -0
- qveris-0.2.0/PKG-INFO +18 -0
- qveris-0.2.0/README.md +188 -0
- qveris-0.2.0/examples/_shared.py +72 -0
- qveris-0.2.0/examples/agent_loop_integration.py +35 -0
- qveris-0.2.0/examples/crypto_market.py +16 -0
- qveris-0.2.0/examples/data_analysis.py +16 -0
- qveris-0.2.0/examples/finance_research.py +16 -0
- qveris-0.2.0/examples/interactive_chat.py +200 -0
- qveris-0.2.0/examples/risk_compliance.py +16 -0
- qveris-0.2.0/examples/stock_debate.py +220 -0
- qveris-0.2.0/pyproject.toml +33 -0
- qveris-0.2.0/qveris/__init__.py +34 -0
- qveris-0.2.0/qveris/agent/__init__.py +4 -0
- qveris-0.2.0/qveris/agent/core.py +415 -0
- qveris-0.2.0/qveris/agent/memory.py +56 -0
- qveris-0.2.0/qveris/client/__init__.py +21 -0
- qveris-0.2.0/qveris/client/api.py +425 -0
- qveris-0.2.0/qveris/client/tools.py +115 -0
- qveris-0.2.0/qveris/config.py +74 -0
- qveris-0.2.0/qveris/generated/__init__.py +17 -0
- qveris-0.2.0/qveris/generated/openapi_models.py +574 -0
- qveris-0.2.0/qveris/llm/__init__.py +4 -0
- qveris-0.2.0/qveris/llm/base.py +108 -0
- qveris-0.2.0/qveris/llm/openai/__init__.py +4 -0
- qveris-0.2.0/qveris/llm/openai/config.py +14 -0
- qveris-0.2.0/qveris/llm/openai/provider.py +185 -0
- qveris-0.2.0/qveris/types.py +256 -0
- qveris-0.2.0/tests/test_agent_runtime.py +142 -0
- qveris-0.2.0/tests/test_canonical_workflow.py +146 -0
- qveris-0.2.0/tests/test_client_contracts.py +363 -0
- qveris-0.2.0/tests/test_client_tool_calls.py +142 -0
- qveris-0.2.0/tests/test_openapi_contract.py +66 -0
- qveris-0.2.0/tests/test_public_exports.py +66 -0
- qveris-0.2.0/uv.lock +1136 -0
qveris-0.2.0/.gitignore
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
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
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
qveris-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 QVerisAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
qveris-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qveris
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: QVeris Python SDK for agent capability discovery, calling, and audit
|
|
5
|
+
Author-email: QVeris Team <contact@qveris.ai>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Requires-Dist: httpx>=0.25.0
|
|
10
|
+
Requires-Dist: openai>=1.0.0
|
|
11
|
+
Requires-Dist: pydantic-settings>=2.0.0
|
|
12
|
+
Requires-Dist: pydantic>=2.0.0
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: datamodel-code-generator==0.26.3; extra == 'dev'
|
|
15
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
16
|
+
Requires-Dist: pytest-asyncio; extra == 'dev'
|
|
17
|
+
Requires-Dist: python-dotenv; extra == 'dev'
|
|
18
|
+
Requires-Dist: rich>=13.0.0; extra == 'dev'
|
qveris-0.2.0/README.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# QVeris Python SDK
|
|
2
|
+
|
|
3
|
+
Async Python SDK for the QVeris Agent External Data & Tool Harness workflow: discover, inspect, call, and audit real-world capabilities from your own agents or applications.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install qveris
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For local development in this monorepo:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
cd packages/python-sdk
|
|
15
|
+
uv run --extra dev python -m pytest
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Configuration
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
export QVERIS_API_KEY="sk-..."
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`QverisConfig` also accepts explicit values:
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from qveris import QverisClient, QverisConfig
|
|
28
|
+
|
|
29
|
+
client = QverisClient(QverisConfig(api_key="sk-...", base_url="https://qveris.ai/api/v1"))
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Canonical Workflow
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import asyncio
|
|
36
|
+
from qveris import QverisClient
|
|
37
|
+
|
|
38
|
+
async def main():
|
|
39
|
+
client = QverisClient()
|
|
40
|
+
try:
|
|
41
|
+
discovered = await client.discover("weather forecast API", limit=5)
|
|
42
|
+
tool = discovered.results[0]
|
|
43
|
+
|
|
44
|
+
inspected = await client.inspect([tool.tool_id], search_id=discovered.search_id)
|
|
45
|
+
selected = inspected.results[0]
|
|
46
|
+
|
|
47
|
+
params = selected.examples.sample_parameters if selected.examples else {"city": "London"}
|
|
48
|
+
result = await client.call(
|
|
49
|
+
selected.tool_id,
|
|
50
|
+
params,
|
|
51
|
+
search_id=discovered.search_id,
|
|
52
|
+
max_response_size=20480,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
usage = await client.usage(execution_id=result.execution_id, summary=True)
|
|
56
|
+
ledger = await client.ledger(summary=True, limit=5)
|
|
57
|
+
|
|
58
|
+
print(result.success, result.billing, usage.total, ledger.total)
|
|
59
|
+
finally:
|
|
60
|
+
await client.close()
|
|
61
|
+
|
|
62
|
+
asyncio.run(main())
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
First-class typed APIs:
|
|
66
|
+
|
|
67
|
+
| Method | REST endpoint | Purpose |
|
|
68
|
+
|--------|---------------|---------|
|
|
69
|
+
| `discover(query, ...)` | `POST /search` | Find capabilities with natural language |
|
|
70
|
+
| `inspect(tool_ids, ...)` | `POST /tools/by-ids` | Fetch full capability metadata |
|
|
71
|
+
| `call(tool_id, parameters, ...)` | `POST /tools/execute` | Execute a selected capability |
|
|
72
|
+
| `usage(...)` | `GET /auth/usage/history/v2` | Audit request status and charge outcome |
|
|
73
|
+
| `ledger(...)` | `GET /auth/credits/ledger` | Inspect final credit balance movements |
|
|
74
|
+
|
|
75
|
+
Backward-compatible aliases remain available: `search_tools`, `get_tools_by_ids`, and `execute_tool`.
|
|
76
|
+
|
|
77
|
+
## Typed Models
|
|
78
|
+
|
|
79
|
+
The SDK exposes Pydantic v2 models for the main QVeris Agent External Data & Tool Harness surfaces:
|
|
80
|
+
|
|
81
|
+
- Capability metadata: `ToolInfo`, `ToolParameter`, `ToolStats`
|
|
82
|
+
- Billing: `BillingRule`, `CompactBillingStatement`, `BillingChargeLine`
|
|
83
|
+
- Execution: `ToolExecutionResponse`
|
|
84
|
+
- Audit: `UsageHistoryResponse`, `UsageEventItem`
|
|
85
|
+
- Credits ledger: `CreditsLedgerResponse`, `CreditsLedgerItem`
|
|
86
|
+
|
|
87
|
+
Models allow additive API fields so newer backend metadata does not break older SDK clients.
|
|
88
|
+
|
|
89
|
+
## Agent Runtime
|
|
90
|
+
|
|
91
|
+
`qveris.Agent` wraps the same workflow into an LLM tool loop. It exposes canonical `discover`, `inspect`, and `call` tool definitions to OpenAI-compatible providers.
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import asyncio
|
|
95
|
+
from qveris import Agent, Message
|
|
96
|
+
|
|
97
|
+
async def main():
|
|
98
|
+
agent = Agent()
|
|
99
|
+
try:
|
|
100
|
+
messages = [Message(role="user", content="Find a weather capability and explain its parameters.")]
|
|
101
|
+
async for event in agent.run(messages):
|
|
102
|
+
if event.type == "content" and event.content:
|
|
103
|
+
print(event.content, end="", flush=True)
|
|
104
|
+
finally:
|
|
105
|
+
await agent.close()
|
|
106
|
+
|
|
107
|
+
asyncio.run(main())
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Set `OPENAI_API_KEY` and optional `OPENAI_BASE_URL` for the default OpenAI-compatible provider, or pass your own `LLMProvider`.
|
|
111
|
+
|
|
112
|
+
## Integration Patterns
|
|
113
|
+
|
|
114
|
+
Use the SDK at the level that matches your application:
|
|
115
|
+
|
|
116
|
+
- Direct typed client: call `discover`, `inspect`, `call`, `usage`, and `ledger` from your own code.
|
|
117
|
+
- Built-in streaming agent: use `Agent.run(messages)` and consume `StreamEvent` values for content, tool calls, tool results, metrics, and errors.
|
|
118
|
+
- Built-in non-streaming agent: use `Agent.run(messages, stream=False)` when your UI wants complete assistant turns plus events.
|
|
119
|
+
- Final text only: use `Agent.run_to_completion(messages)`.
|
|
120
|
+
- Bring your own loop: pass `DISCOVER_TOOL_DEF`, `INSPECT_TOOL_DEF`, and `CALL_TOOL_DEF` to your LLM provider, then route tool calls through `QverisClient.handle_tool_call(...)`.
|
|
121
|
+
|
|
122
|
+
## Custom LLM Providers
|
|
123
|
+
|
|
124
|
+
The default `Agent()` uses the built-in OpenAI-compatible provider. For non-OpenAI-compatible model APIs, implement `LLMProvider` and pass it to `Agent`:
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from typing import AsyncGenerator, List
|
|
128
|
+
from openai.types.chat import ChatCompletionToolParam
|
|
129
|
+
from qveris import Agent
|
|
130
|
+
from qveris.config import AgentConfig
|
|
131
|
+
from qveris.llm.base import LLMProvider
|
|
132
|
+
from qveris.types import ChatResponse, Message, StreamEvent
|
|
133
|
+
|
|
134
|
+
class MyProvider(LLMProvider):
|
|
135
|
+
async def chat_stream(
|
|
136
|
+
self,
|
|
137
|
+
messages: List[Message],
|
|
138
|
+
tools: List[ChatCompletionToolParam],
|
|
139
|
+
config: AgentConfig,
|
|
140
|
+
) -> AsyncGenerator[StreamEvent, None]:
|
|
141
|
+
...
|
|
142
|
+
|
|
143
|
+
async def chat(
|
|
144
|
+
self,
|
|
145
|
+
messages: List[Message],
|
|
146
|
+
tools: List[ChatCompletionToolParam],
|
|
147
|
+
config: AgentConfig,
|
|
148
|
+
) -> ChatResponse:
|
|
149
|
+
...
|
|
150
|
+
|
|
151
|
+
agent = Agent(llm_provider=MyProvider())
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Examples
|
|
155
|
+
|
|
156
|
+
Five runnable examples are included under [`examples/`](examples):
|
|
157
|
+
|
|
158
|
+
| Example | Scenario |
|
|
159
|
+
|---------|----------|
|
|
160
|
+
| `finance_research.py` | Stock quote / market data research |
|
|
161
|
+
| `risk_compliance.py` | Sanctions, adverse media, or compliance screening |
|
|
162
|
+
| `crypto_market.py` | Crypto price and volume data |
|
|
163
|
+
| `data_analysis.py` | Dataset enrichment with external capability data |
|
|
164
|
+
| `agent_loop_integration.py` | LLM agent loop integration |
|
|
165
|
+
|
|
166
|
+
The capability examples run `discover` and `inspect` when `QVERIS_API_KEY` is set. They only execute `call` when `RUN_QVERIS_CALLS=1` is set.
|
|
167
|
+
|
|
168
|
+
## Tests
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
cd packages/python-sdk
|
|
172
|
+
uv run python -m compileall qveris examples
|
|
173
|
+
uv run --extra dev python -m pytest
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Contract tests use `httpx.MockTransport` to validate SDK models against the REST API shapes for discover, inspect, call, usage, and ledger without consuming credits.
|
|
177
|
+
|
|
178
|
+
## Compatibility and Release Policy
|
|
179
|
+
|
|
180
|
+
- Python: `>=3.8`
|
|
181
|
+
- Runtime dependencies: `httpx`, `pydantic`, `pydantic-settings`, `openai`
|
|
182
|
+
- Public methods and Pydantic model fields follow additive compatibility where possible.
|
|
183
|
+
- Deprecated aliases remain for at least one minor release after canonical replacements are available.
|
|
184
|
+
- Breaking API changes require a major version bump and migration notes in this README.
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
MIT
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Any, Dict, Optional
|
|
3
|
+
|
|
4
|
+
from qveris import QverisClient, ToolInfo
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def require_api_key() -> bool:
|
|
8
|
+
if os.getenv("QVERIS_API_KEY"):
|
|
9
|
+
return True
|
|
10
|
+
print("Set QVERIS_API_KEY to run this example against the QVeris API.")
|
|
11
|
+
return False
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def should_call() -> bool:
|
|
15
|
+
return os.getenv("RUN_QVERIS_CALLS") == "1"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def sample_parameters(tool: ToolInfo, fallback: Dict[str, Any]) -> Dict[str, Any]:
|
|
19
|
+
if tool.examples and tool.examples.sample_parameters:
|
|
20
|
+
return tool.examples.sample_parameters
|
|
21
|
+
return fallback
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
async def preview_capability(
|
|
25
|
+
query: str,
|
|
26
|
+
fallback_params: Dict[str, Any],
|
|
27
|
+
*,
|
|
28
|
+
limit: int = 5,
|
|
29
|
+
max_response_size: Optional[int] = 4096,
|
|
30
|
+
) -> None:
|
|
31
|
+
if not require_api_key():
|
|
32
|
+
return
|
|
33
|
+
|
|
34
|
+
client = QverisClient()
|
|
35
|
+
try:
|
|
36
|
+
discovered = await client.discover(query, limit=limit)
|
|
37
|
+
print(f"search_id: {discovered.search_id}")
|
|
38
|
+
print(f"matches: {len(discovered.results)} / total={discovered.total}")
|
|
39
|
+
if not discovered.results:
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
tool = discovered.results[0]
|
|
43
|
+
inspected = await client.inspect([tool.tool_id], search_id=discovered.search_id)
|
|
44
|
+
tool = inspected.results[0] if inspected.results else tool
|
|
45
|
+
print(f"selected: {tool.tool_id} - {tool.name or tool.description or 'unnamed'}")
|
|
46
|
+
if tool.stats:
|
|
47
|
+
print(f"quality: success_rate={tool.stats.success_rate} latency_ms={tool.stats.avg_execution_time_ms}")
|
|
48
|
+
if tool.billing_rule:
|
|
49
|
+
print(f"billing: {tool.billing_rule.description or tool.billing_rule.metering_mode}")
|
|
50
|
+
|
|
51
|
+
params = sample_parameters(tool, fallback_params)
|
|
52
|
+
print(f"params: {params}")
|
|
53
|
+
if not should_call():
|
|
54
|
+
print("Set RUN_QVERIS_CALLS=1 to execute the selected capability.")
|
|
55
|
+
return
|
|
56
|
+
|
|
57
|
+
result = await client.call(
|
|
58
|
+
tool.tool_id,
|
|
59
|
+
params,
|
|
60
|
+
search_id=discovered.search_id,
|
|
61
|
+
max_response_size=max_response_size,
|
|
62
|
+
)
|
|
63
|
+
print(f"execution_id: {result.execution_id}")
|
|
64
|
+
print(f"success: {result.success}")
|
|
65
|
+
print(f"billing: {result.billing.summary if result.billing else None}")
|
|
66
|
+
print(f"result: {result.result}")
|
|
67
|
+
usage = await client.usage(execution_id=result.execution_id, summary=True, limit=5)
|
|
68
|
+
print(f"usage_records: {usage.total}")
|
|
69
|
+
ledger = await client.ledger(summary=True, limit=5)
|
|
70
|
+
print(f"ledger_records: {ledger.total}")
|
|
71
|
+
finally:
|
|
72
|
+
await client.close()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Minimal agent loop integration using the built-in QVeris Agent."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
from qveris import Agent, Message
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def main() -> None:
|
|
10
|
+
if not os.getenv("QVERIS_API_KEY") or not os.getenv("OPENAI_API_KEY"):
|
|
11
|
+
print("Set QVERIS_API_KEY and OPENAI_API_KEY to run the agent loop example.")
|
|
12
|
+
return
|
|
13
|
+
|
|
14
|
+
agent = Agent()
|
|
15
|
+
try:
|
|
16
|
+
messages = [
|
|
17
|
+
Message(
|
|
18
|
+
role="user",
|
|
19
|
+
content="Find a capability for current weather, inspect it if needed, then explain what parameters it needs.",
|
|
20
|
+
)
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
async for event in agent.run(messages):
|
|
24
|
+
if event.type == "content" and event.content:
|
|
25
|
+
print(event.content, end="", flush=True)
|
|
26
|
+
elif event.type == "tool_call" and event.tool_call:
|
|
27
|
+
print(f"\n-> tool_call: {event.tool_call.get('function', {}).get('name')}")
|
|
28
|
+
elif event.type == "tool_result" and event.tool_result:
|
|
29
|
+
print("\n<- tool_result")
|
|
30
|
+
finally:
|
|
31
|
+
await agent.close()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if __name__ == "__main__":
|
|
35
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Crypto market data workflow for token prices and exchange metrics."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
5
|
+
from _shared import preview_capability
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def main() -> None:
|
|
9
|
+
await preview_capability(
|
|
10
|
+
"cryptocurrency market price and volume API",
|
|
11
|
+
{"symbol": "BTC", "currency": "USD"},
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
if __name__ == "__main__":
|
|
16
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Data analysis workflow for enriching a dataset with a discovered capability."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
5
|
+
from _shared import preview_capability
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def main() -> None:
|
|
9
|
+
await preview_capability(
|
|
10
|
+
"company domain enrichment API",
|
|
11
|
+
{"domain": "qveris.ai"},
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
if __name__ == "__main__":
|
|
16
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Finance research workflow using discover, inspect, call, usage, and ledger."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
5
|
+
from _shared import preview_capability
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def main() -> None:
|
|
9
|
+
await preview_capability(
|
|
10
|
+
"public company stock quote and market data API",
|
|
11
|
+
{"symbol": "AAPL"},
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
if __name__ == "__main__":
|
|
16
|
+
asyncio.run(main())
|