tensorzero 0.0.1__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.
- tensorzero-0.0.1/.gitignore +27 -0
- tensorzero-0.0.1/PKG-INFO +56 -0
- tensorzero-0.0.1/README.md +47 -0
- tensorzero-0.0.1/pyproject.toml +18 -0
- tensorzero-0.0.1/src/tensorzero/__init__.py +29 -0
- tensorzero-0.0.1/src/tensorzero/client.py +194 -0
- tensorzero-0.0.1/src/tensorzero/types.py +175 -0
- tensorzero-0.0.1/tests/test_client.py +334 -0
- tensorzero-0.0.1/uv.lock +208 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Generated by Cargo
|
|
2
|
+
# will have compiled files and executables
|
|
3
|
+
debug/
|
|
4
|
+
target/
|
|
5
|
+
|
|
6
|
+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
|
7
|
+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
|
8
|
+
Cargo.lock
|
|
9
|
+
|
|
10
|
+
# These are backup files generated by rustfmt
|
|
11
|
+
**/*.rs.bk
|
|
12
|
+
|
|
13
|
+
# MSVC Windows builds of rustc generate these, which store debugging information
|
|
14
|
+
*.pdb
|
|
15
|
+
.envrc
|
|
16
|
+
.python-version
|
|
17
|
+
|
|
18
|
+
# VScode settings
|
|
19
|
+
.vscode/
|
|
20
|
+
|
|
21
|
+
.DS_Store
|
|
22
|
+
.credentials/
|
|
23
|
+
|
|
24
|
+
# Python cache files
|
|
25
|
+
__pycache__/
|
|
26
|
+
*.py[cod]
|
|
27
|
+
*$py.class
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: tensorzero
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: The Python client for TensorZero
|
|
5
|
+
Author-email: Viraj Mehta <viraj@tensorzero.com>, Gabriel Bianconi <gabriel@tensorzero.com>
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: httpx>=0.27.0
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# TensorZero Python Client
|
|
11
|
+
|
|
12
|
+
This is an async Python client for the TensorZero gateway. Check out the [docs](https://tensorzero.com/docs/) for more information. This client allows you to easily make inference requests and assign feedback to them via the TensorZero gateway.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install tensorzero
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Basic Usage
|
|
21
|
+
|
|
22
|
+
### Non-Streaming Inference
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from tensorzero import AsyncTensorZero
|
|
26
|
+
|
|
27
|
+
with AsyncTensorZero("http://localhost:3000") as client:
|
|
28
|
+
result = await client.inference(
|
|
29
|
+
function_name="basic_test",
|
|
30
|
+
input={
|
|
31
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
32
|
+
"messages": [{"role": "user", "content": "Hello"}],
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
episode_id = result.episode_id
|
|
36
|
+
output = result.output
|
|
37
|
+
print(output[0].text) # Prints the text of the first content block returned by TensorZero
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Streaming Inference
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from tensorzero import AsyncTensorZero
|
|
44
|
+
|
|
45
|
+
async with AsyncTensorZero() as client:
|
|
46
|
+
stream = await client.chat.completions.create(
|
|
47
|
+
function_name="basic_test",
|
|
48
|
+
input={
|
|
49
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
50
|
+
"messages": [{"role": "user", "content": "Hello"}],
|
|
51
|
+
},
|
|
52
|
+
stream=True,
|
|
53
|
+
)
|
|
54
|
+
async for chunk in stream:
|
|
55
|
+
print(chunk.content[0].text) # Prints the text in each chunk returned by TensorZero
|
|
56
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# TensorZero Python Client
|
|
2
|
+
|
|
3
|
+
This is an async Python client for the TensorZero gateway. Check out the [docs](https://tensorzero.com/docs/) for more information. This client allows you to easily make inference requests and assign feedback to them via the TensorZero gateway.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install tensorzero
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
### Non-Streaming Inference
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from tensorzero import AsyncTensorZero
|
|
17
|
+
|
|
18
|
+
with AsyncTensorZero("http://localhost:3000") as client:
|
|
19
|
+
result = await client.inference(
|
|
20
|
+
function_name="basic_test",
|
|
21
|
+
input={
|
|
22
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
23
|
+
"messages": [{"role": "user", "content": "Hello"}],
|
|
24
|
+
},
|
|
25
|
+
)
|
|
26
|
+
episode_id = result.episode_id
|
|
27
|
+
output = result.output
|
|
28
|
+
print(output[0].text) # Prints the text of the first content block returned by TensorZero
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Streaming Inference
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from tensorzero import AsyncTensorZero
|
|
35
|
+
|
|
36
|
+
async with AsyncTensorZero() as client:
|
|
37
|
+
stream = await client.chat.completions.create(
|
|
38
|
+
function_name="basic_test",
|
|
39
|
+
input={
|
|
40
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
41
|
+
"messages": [{"role": "user", "content": "Hello"}],
|
|
42
|
+
},
|
|
43
|
+
stream=True,
|
|
44
|
+
)
|
|
45
|
+
async for chunk in stream:
|
|
46
|
+
print(chunk.content[0].text) # Prints the text in each chunk returned by TensorZero
|
|
47
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tensorzero"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "The Python client for TensorZero"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
dependencies = ["httpx>=0.27.0"]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Viraj Mehta", email = "viraj@tensorzero.com" },
|
|
10
|
+
{ name = "Gabriel Bianconi", email = "gabriel@tensorzero.com" },
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[build-system]
|
|
14
|
+
requires = ["hatchling"]
|
|
15
|
+
build-backend = "hatchling.build"
|
|
16
|
+
|
|
17
|
+
[tool.uv]
|
|
18
|
+
dev-dependencies = ["uuid7>=0.1.0", "pytest>=8.3.2", "pytest-asyncio>=0.24.0"]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from .client import AsyncTensorZero
|
|
2
|
+
from .types import (
|
|
3
|
+
ChatInferenceResponse,
|
|
4
|
+
ContentBlock,
|
|
5
|
+
FeedbackResponse,
|
|
6
|
+
InferenceChunk,
|
|
7
|
+
InferenceResponse,
|
|
8
|
+
JsonInferenceOutput,
|
|
9
|
+
Text,
|
|
10
|
+
TextChunk,
|
|
11
|
+
ToolCall,
|
|
12
|
+
ToolCallChunk,
|
|
13
|
+
Usage,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"ChatInferenceResponse",
|
|
18
|
+
"ContentBlock",
|
|
19
|
+
"FeedbackResponse",
|
|
20
|
+
"InferenceChunk",
|
|
21
|
+
"InferenceResponse",
|
|
22
|
+
"JsonInferenceOutput",
|
|
23
|
+
"AsyncTensorZero",
|
|
24
|
+
"Text",
|
|
25
|
+
"TextChunk",
|
|
26
|
+
"ToolCall",
|
|
27
|
+
"ToolCallChunk",
|
|
28
|
+
"Usage",
|
|
29
|
+
]
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TensorZero Client
|
|
3
|
+
|
|
4
|
+
This module provides an asynchronous client for interacting with the TensorZero gateway.
|
|
5
|
+
It includes functionality for making inference requests and sending feedback.
|
|
6
|
+
|
|
7
|
+
The main class, AsyncTensorZero, offers methods for:
|
|
8
|
+
- Initializing the client with a base URL
|
|
9
|
+
- Making inference requests (with optional streaming)
|
|
10
|
+
- Sending feedback on episodes or inferences
|
|
11
|
+
- Managing the client session using async context managers
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
async with TensorZero(base_url) as client:
|
|
15
|
+
response = await client.inference(...)
|
|
16
|
+
feedback = await client.feedback(...)
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import json
|
|
20
|
+
import logging
|
|
21
|
+
from typing import Any, AsyncGenerator, Dict, List, Literal, Optional, Union
|
|
22
|
+
from urllib.parse import urljoin
|
|
23
|
+
from uuid import UUID
|
|
24
|
+
|
|
25
|
+
import httpx
|
|
26
|
+
|
|
27
|
+
from .types import (
|
|
28
|
+
FeedbackResponse,
|
|
29
|
+
InferenceChunk,
|
|
30
|
+
InferenceResponse,
|
|
31
|
+
parse_inference_chunk,
|
|
32
|
+
parse_inference_response,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class AsyncTensorZero:
|
|
37
|
+
def __init__(self, base_url: str):
|
|
38
|
+
"""
|
|
39
|
+
Initialize the TensorZero client.
|
|
40
|
+
|
|
41
|
+
:param base_url: The base URL of the TensorZero gateway. Example:"http://localhost:3000"
|
|
42
|
+
"""
|
|
43
|
+
self.base_url = base_url
|
|
44
|
+
self.client = httpx.AsyncClient()
|
|
45
|
+
self.logger = logging.getLogger(__name__)
|
|
46
|
+
|
|
47
|
+
async def inference(
|
|
48
|
+
self,
|
|
49
|
+
function_name: str,
|
|
50
|
+
input: Dict[str, Any],
|
|
51
|
+
episode_id: Optional[UUID] = None,
|
|
52
|
+
stream: Optional[bool] = None,
|
|
53
|
+
params: Optional[Dict[str, Any]] = None,
|
|
54
|
+
variant_name: Optional[str] = None,
|
|
55
|
+
dryrun: Optional[bool] = None,
|
|
56
|
+
allowed_tools: Optional[List[str]] = None,
|
|
57
|
+
additional_tools: Optional[List[Dict[str, Any]]] = None,
|
|
58
|
+
tool_choice: Optional[
|
|
59
|
+
Union[Literal["auto", "required", "off"], Dict[Literal["specific"], str]]
|
|
60
|
+
] = None,
|
|
61
|
+
parallel_tool_calls: Optional[bool] = None,
|
|
62
|
+
) -> Union[InferenceResponse, AsyncGenerator[InferenceChunk, None]]:
|
|
63
|
+
"""
|
|
64
|
+
Make a POST request to the /inference endpoint.
|
|
65
|
+
|
|
66
|
+
:param function_name: The name of the function to call
|
|
67
|
+
:param input: The input to the function
|
|
68
|
+
Structure: {"system": Optional[str], "messages": List[{"role": "user" | "assistant", "content": Any}]}
|
|
69
|
+
The input will be validated server side against the input schema of the function being called.
|
|
70
|
+
:param episode_id: The episode ID to use for the inference.
|
|
71
|
+
If this is the first inference in an episode, leave this field blank. The TensorZero gateway will generate and return a new episode ID.
|
|
72
|
+
Note: Only use episode IDs generated by the TensorZero gateway. Don't generate them yourself.
|
|
73
|
+
:param stream: If set, the TensorZero gateway will stream partial message deltas (e.g. generated tokens) as it receives them from model providers.
|
|
74
|
+
:param params: Override inference-time parameters for a particular variant type. Currently, we support:
|
|
75
|
+
{"chat_completion": {"temperature": float, "max_tokens": int, "seed": int}}
|
|
76
|
+
:param variant_name: If set, pins the inference request to a particular variant.
|
|
77
|
+
Note: You should generally not do this, and instead let the TensorZero gateway assign a
|
|
78
|
+
particular variant. This field is primarily used for testing or debugging purposes.
|
|
79
|
+
:param dryrun: If true, the request will be executed but won't be stored to the database.
|
|
80
|
+
:param allowed_tools: If set, restricts the tools available during this inference request.
|
|
81
|
+
The list of names should be a subset of the tools configured for the function.
|
|
82
|
+
Tools provided at inference time in `additional_tools` (if any) are always available.
|
|
83
|
+
:param additional_tools: A list of additional tools to use for the request. Each element should look like {"name": str, "parameters": valid JSON Schema, "description": str}
|
|
84
|
+
:param tool_choice: If set, overrides the tool choice strategy for the request.
|
|
85
|
+
It should be one of: "auto", "required", "off", or {"specific": str}. The last option pins the request to a specific tool name.
|
|
86
|
+
:param parallel_tool_calls: If true, the request will allow for multiple tool calls in a single inference request.
|
|
87
|
+
:return: If stream is false, returns an InferenceResponse.
|
|
88
|
+
If stream is true, returns an async generator that yields InferenceChunks as they come in.
|
|
89
|
+
"""
|
|
90
|
+
url = urljoin(self.base_url, "inference")
|
|
91
|
+
data = {
|
|
92
|
+
"function_name": function_name,
|
|
93
|
+
"input": input,
|
|
94
|
+
}
|
|
95
|
+
if episode_id is not None:
|
|
96
|
+
data["episode_id"] = str(episode_id)
|
|
97
|
+
if stream is not None:
|
|
98
|
+
data["stream"] = stream
|
|
99
|
+
if params is not None:
|
|
100
|
+
data["params"] = params
|
|
101
|
+
if variant_name is not None:
|
|
102
|
+
data["variant_name"] = variant_name
|
|
103
|
+
if dryrun is not None:
|
|
104
|
+
data["dryrun"] = dryrun
|
|
105
|
+
if allowed_tools is not None:
|
|
106
|
+
data["allowed_tools"] = allowed_tools
|
|
107
|
+
if additional_tools is not None:
|
|
108
|
+
data["additional_tools"] = additional_tools
|
|
109
|
+
if tool_choice is not None:
|
|
110
|
+
data["tool_choice"] = tool_choice
|
|
111
|
+
if parallel_tool_calls is not None:
|
|
112
|
+
data["parallel_tool_calls"] = parallel_tool_calls
|
|
113
|
+
response = await self.client.post(url, json=data)
|
|
114
|
+
response.raise_for_status()
|
|
115
|
+
if not stream:
|
|
116
|
+
return parse_inference_response(response.json())
|
|
117
|
+
else:
|
|
118
|
+
return self._stream_sse(response)
|
|
119
|
+
|
|
120
|
+
async def feedback(
|
|
121
|
+
self,
|
|
122
|
+
metric_name: str,
|
|
123
|
+
value: Any,
|
|
124
|
+
inference_id: Optional[UUID] = None,
|
|
125
|
+
episode_id: Optional[UUID] = None,
|
|
126
|
+
dryrun: Optional[bool] = None,
|
|
127
|
+
) -> Dict[str, Any]:
|
|
128
|
+
"""
|
|
129
|
+
Make a POST request to the /feedback endpoint.
|
|
130
|
+
|
|
131
|
+
:param metric_name: The name of the metric to provide feedback for
|
|
132
|
+
:param value: The value of the feedback. It should correspond to the metric type.
|
|
133
|
+
:param inference_id: The inference ID to assign the feedback to.
|
|
134
|
+
Only use inference IDs that were returned by the TensorZero gateway.
|
|
135
|
+
Note: You can assign feedback to either an episode or an inference, but not both.
|
|
136
|
+
:param episode_id: The episode ID to use for the request
|
|
137
|
+
Only use episode IDs that were returned by the TensorZero gateway.
|
|
138
|
+
Note: You can assign feedback to either an episode or an inference, but not both.
|
|
139
|
+
:param dryrun: If true, the feedback request will be executed but won't be stored to the database (i.e. no-op).
|
|
140
|
+
:return: {"feedback_id": str}
|
|
141
|
+
"""
|
|
142
|
+
if episode_id is None and inference_id is None:
|
|
143
|
+
raise ValueError("Either episode_id or inference_id must be provided")
|
|
144
|
+
if episode_id is not None and inference_id is not None:
|
|
145
|
+
raise ValueError(
|
|
146
|
+
"Only one of episode_id or inference_id can be provided, not both"
|
|
147
|
+
)
|
|
148
|
+
data = {
|
|
149
|
+
"metric_name": metric_name,
|
|
150
|
+
"value": value,
|
|
151
|
+
}
|
|
152
|
+
if dryrun is not None:
|
|
153
|
+
data["dryrun"] = dryrun
|
|
154
|
+
if episode_id is not None:
|
|
155
|
+
data["episode_id"] = str(episode_id)
|
|
156
|
+
if inference_id is not None:
|
|
157
|
+
data["inference_id"] = str(inference_id)
|
|
158
|
+
url = urljoin(self.base_url, "feedback")
|
|
159
|
+
response = await self.client.post(url, json=data)
|
|
160
|
+
response.raise_for_status()
|
|
161
|
+
feedback_result = FeedbackResponse(**response.json())
|
|
162
|
+
return feedback_result
|
|
163
|
+
|
|
164
|
+
async def close(self):
|
|
165
|
+
"""
|
|
166
|
+
Close the connection to the TensorZero gateway.
|
|
167
|
+
"""
|
|
168
|
+
await self.client.aclose()
|
|
169
|
+
|
|
170
|
+
async def __aenter__(self):
|
|
171
|
+
return self
|
|
172
|
+
|
|
173
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
174
|
+
await self.close()
|
|
175
|
+
|
|
176
|
+
async def _stream_sse(
|
|
177
|
+
self, response: httpx.Response
|
|
178
|
+
) -> AsyncGenerator[InferenceChunk, None]:
|
|
179
|
+
"""
|
|
180
|
+
Parse the SSE stream from the response.
|
|
181
|
+
|
|
182
|
+
:param response: The httpx.Response object
|
|
183
|
+
:yield: Parsed SSE events as dictionaries
|
|
184
|
+
"""
|
|
185
|
+
async for line in response.aiter_lines():
|
|
186
|
+
if line.startswith("data: "):
|
|
187
|
+
data = line[6:].strip()
|
|
188
|
+
if data == "[DONE]":
|
|
189
|
+
break
|
|
190
|
+
try:
|
|
191
|
+
data = json.loads(data)
|
|
192
|
+
yield parse_inference_chunk(data)
|
|
193
|
+
except json.JSONDecodeError:
|
|
194
|
+
self.logger.error(f"Failed to parse SSE data: {data}")
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Any, Dict, List, Optional, Union
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
|
|
5
|
+
# Types for non-streaming inference responses
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class Usage:
|
|
10
|
+
input_tokens: int
|
|
11
|
+
output_tokens: int
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class Text:
|
|
16
|
+
text: str
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class ToolCall:
|
|
21
|
+
name: str
|
|
22
|
+
arguments: Dict[str, Any]
|
|
23
|
+
id: str
|
|
24
|
+
parsed_name: Optional[str]
|
|
25
|
+
parsed_arguments: Optional[Dict[str, Any]]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
ContentBlock = Union[Text, ToolCall]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class JsonInferenceOutput:
|
|
33
|
+
raw: str
|
|
34
|
+
parsed: Optional[Dict[str, Any]]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass
|
|
38
|
+
class ChatInferenceResponse:
|
|
39
|
+
inference_id: UUID
|
|
40
|
+
episode_id: UUID
|
|
41
|
+
variant_name: str
|
|
42
|
+
output: List[ContentBlock]
|
|
43
|
+
usage: Usage
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@dataclass
|
|
47
|
+
class JsonInferenceResponse:
|
|
48
|
+
inference_id: UUID
|
|
49
|
+
episode_id: UUID
|
|
50
|
+
variant_name: str
|
|
51
|
+
output: JsonInferenceOutput
|
|
52
|
+
usage: Usage
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
InferenceResponse = Union[ChatInferenceResponse, JsonInferenceResponse]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def parse_inference_response(data: Dict[str, Any]) -> InferenceResponse:
|
|
59
|
+
if "output" in data and isinstance(data["output"], list):
|
|
60
|
+
return ChatInferenceResponse(
|
|
61
|
+
inference_id=UUID(data["inference_id"]),
|
|
62
|
+
episode_id=UUID(data["episode_id"]),
|
|
63
|
+
variant_name=data["variant_name"],
|
|
64
|
+
output=[parse_content_block(block) for block in data["output"]],
|
|
65
|
+
usage=Usage(**data["usage"]),
|
|
66
|
+
)
|
|
67
|
+
elif "output" in data and isinstance(data["output"], dict):
|
|
68
|
+
return JsonInferenceResponse(
|
|
69
|
+
inference_id=UUID(data["inference_id"]),
|
|
70
|
+
episode_id=UUID(data["episode_id"]),
|
|
71
|
+
variant_name=data["variant_name"],
|
|
72
|
+
output=JsonInferenceOutput(**data["output"]),
|
|
73
|
+
usage=Usage(**data["usage"]),
|
|
74
|
+
)
|
|
75
|
+
else:
|
|
76
|
+
raise ValueError("Unable to determine response type")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def parse_content_block(block: Dict[str, Any]) -> ContentBlock:
|
|
80
|
+
block_type = block["type"]
|
|
81
|
+
if block_type == "text":
|
|
82
|
+
return Text(text=block["text"])
|
|
83
|
+
elif block_type == "tool_call":
|
|
84
|
+
return ToolCall(
|
|
85
|
+
name=block["name"],
|
|
86
|
+
arguments=block["arguments"],
|
|
87
|
+
id=block["id"],
|
|
88
|
+
parsed_name=block.get("parsed_name"),
|
|
89
|
+
parsed_arguments=block.get("parsed_arguments"),
|
|
90
|
+
)
|
|
91
|
+
else:
|
|
92
|
+
raise ValueError(f"Unknown content block type: {block}")
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
# Types for streaming inference responses
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@dataclass
|
|
99
|
+
class TextChunk:
|
|
100
|
+
# In the possibility that multiple text messages are sent in a single streaming response,
|
|
101
|
+
# this `id` will be used to disambiguate them
|
|
102
|
+
id: str
|
|
103
|
+
text: str
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@dataclass
|
|
107
|
+
class ToolCallChunk:
|
|
108
|
+
name: str
|
|
109
|
+
# This is the tool call ID that many LLM APIs use to associate tool calls with tool responses
|
|
110
|
+
id: str
|
|
111
|
+
# `arguments` will come as partial JSON
|
|
112
|
+
arguments: str
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
ContentBlockChunk = Union[TextChunk, ToolCallChunk]
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@dataclass
|
|
119
|
+
class ChatChunk:
|
|
120
|
+
inference_id: UUID
|
|
121
|
+
episode_id: UUID
|
|
122
|
+
variant_name: str
|
|
123
|
+
content: List[ContentBlockChunk]
|
|
124
|
+
usage: Optional[Usage]
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@dataclass
|
|
128
|
+
class JsonChunk:
|
|
129
|
+
inference_id: UUID
|
|
130
|
+
episode_id: UUID
|
|
131
|
+
variant_name: str
|
|
132
|
+
raw: str
|
|
133
|
+
usage: Optional[Usage]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
InferenceChunk = Union[ChatChunk, JsonChunk]
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def parse_inference_chunk(chunk: Dict[str, Any]) -> InferenceChunk:
|
|
140
|
+
if "content" in chunk:
|
|
141
|
+
return ChatChunk(
|
|
142
|
+
inference_id=UUID(chunk["inference_id"]),
|
|
143
|
+
episode_id=UUID(chunk["episode_id"]),
|
|
144
|
+
variant_name=chunk["variant_name"],
|
|
145
|
+
content=[parse_content_block_chunk(block) for block in chunk["content"]],
|
|
146
|
+
usage=Usage(**chunk["usage"]) if "usage" in chunk else None,
|
|
147
|
+
)
|
|
148
|
+
elif "raw" in chunk:
|
|
149
|
+
return JsonChunk(
|
|
150
|
+
inference_id=UUID(chunk["inference_id"]),
|
|
151
|
+
episode_id=UUID(chunk["episode_id"]),
|
|
152
|
+
variant_name=chunk["variant_name"],
|
|
153
|
+
raw=chunk["raw"],
|
|
154
|
+
usage=Usage(**chunk["usage"]) if "usage" in chunk else None,
|
|
155
|
+
)
|
|
156
|
+
else:
|
|
157
|
+
raise ValueError(f"Unable to determine response type: {chunk}")
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def parse_content_block_chunk(block: Dict[str, Any]) -> ContentBlockChunk:
|
|
161
|
+
block_type = block["type"]
|
|
162
|
+
if block_type == "text":
|
|
163
|
+
return TextChunk(id=block["id"], text=block["text"])
|
|
164
|
+
elif block_type == "tool_call":
|
|
165
|
+
return ToolCallChunk(
|
|
166
|
+
name=block["name"], id=block["id"], arguments=block["arguments"]
|
|
167
|
+
)
|
|
168
|
+
else:
|
|
169
|
+
raise ValueError(f"Unknown content block type: {block}")
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
# Types for feedback
|
|
173
|
+
@dataclass
|
|
174
|
+
class FeedbackResponse:
|
|
175
|
+
feedback_id: UUID
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for the TensorZero client
|
|
3
|
+
|
|
4
|
+
We use pytest and pytest-asyncio to run the tests.
|
|
5
|
+
|
|
6
|
+
These tests cover the major functionality of the client but do not
|
|
7
|
+
attempt to comprehensively cover all of TensorZero's functionality.
|
|
8
|
+
See the tests across the Rust codebase for more comprehensive tests.
|
|
9
|
+
|
|
10
|
+
To run:
|
|
11
|
+
```
|
|
12
|
+
pytest
|
|
13
|
+
```
|
|
14
|
+
or
|
|
15
|
+
```
|
|
16
|
+
uv run pytest
|
|
17
|
+
```
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from uuid import UUID
|
|
21
|
+
|
|
22
|
+
import pytest
|
|
23
|
+
import pytest_asyncio
|
|
24
|
+
from tensorzero import (
|
|
25
|
+
AsyncTensorZero,
|
|
26
|
+
FeedbackResponse,
|
|
27
|
+
Text,
|
|
28
|
+
TextChunk,
|
|
29
|
+
ToolCall,
|
|
30
|
+
ToolCallChunk,
|
|
31
|
+
)
|
|
32
|
+
from uuid_extensions import uuid7
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest_asyncio.fixture
|
|
36
|
+
async def client():
|
|
37
|
+
async with AsyncTensorZero("http://localhost:3000") as client:
|
|
38
|
+
yield client
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@pytest.mark.asyncio
|
|
42
|
+
async def test_basic_inference(client):
|
|
43
|
+
result = await client.inference(
|
|
44
|
+
function_name="basic_test",
|
|
45
|
+
input={
|
|
46
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
47
|
+
"messages": [{"role": "user", "content": "Hello"}],
|
|
48
|
+
},
|
|
49
|
+
)
|
|
50
|
+
assert result.variant_name == "test"
|
|
51
|
+
output = result.output
|
|
52
|
+
assert len(output) == 1
|
|
53
|
+
assert isinstance(output[0], Text)
|
|
54
|
+
assert (
|
|
55
|
+
output[0].text
|
|
56
|
+
== "Megumin gleefully chanted her spell, unleashing a thunderous explosion that lit up the sky and left a massive crater in its wake."
|
|
57
|
+
)
|
|
58
|
+
usage = result.usage
|
|
59
|
+
assert usage.input_tokens == 10
|
|
60
|
+
assert usage.output_tokens == 10
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@pytest.mark.asyncio
|
|
64
|
+
async def test_inference_streaming(client):
|
|
65
|
+
stream = await client.inference(
|
|
66
|
+
function_name="basic_test",
|
|
67
|
+
input={
|
|
68
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
69
|
+
"messages": [{"role": "user", "content": "Hello"}],
|
|
70
|
+
},
|
|
71
|
+
stream=True,
|
|
72
|
+
)
|
|
73
|
+
chunks = [chunk async for chunk in stream]
|
|
74
|
+
expected_text = [
|
|
75
|
+
"Wally,",
|
|
76
|
+
" the",
|
|
77
|
+
" golden",
|
|
78
|
+
" retriever,",
|
|
79
|
+
" wagged",
|
|
80
|
+
" his",
|
|
81
|
+
" tail",
|
|
82
|
+
" excitedly",
|
|
83
|
+
" as",
|
|
84
|
+
" he",
|
|
85
|
+
" devoured",
|
|
86
|
+
" a",
|
|
87
|
+
" slice",
|
|
88
|
+
" of",
|
|
89
|
+
" cheese",
|
|
90
|
+
" pizza.",
|
|
91
|
+
]
|
|
92
|
+
previous_inference_id = None
|
|
93
|
+
previous_episode_id = None
|
|
94
|
+
for i, chunk in enumerate(chunks):
|
|
95
|
+
if previous_inference_id is not None:
|
|
96
|
+
assert chunk.inference_id == previous_inference_id
|
|
97
|
+
if previous_episode_id is not None:
|
|
98
|
+
assert chunk.episode_id == previous_episode_id
|
|
99
|
+
previous_inference_id = chunk.inference_id
|
|
100
|
+
previous_episode_id = chunk.episode_id
|
|
101
|
+
variant_name = chunk.variant_name
|
|
102
|
+
assert variant_name == "test"
|
|
103
|
+
if i + 1 < len(chunks):
|
|
104
|
+
assert len(chunk.content) == 1
|
|
105
|
+
assert isinstance(chunk.content[0], TextChunk)
|
|
106
|
+
assert chunk.content[0].text == expected_text[i]
|
|
107
|
+
else:
|
|
108
|
+
assert len(chunk.content) == 0
|
|
109
|
+
assert chunk.usage.input_tokens == 10
|
|
110
|
+
assert chunk.usage.output_tokens == 16
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@pytest.mark.asyncio
|
|
114
|
+
async def test_tool_call_inference(client):
|
|
115
|
+
result = await client.inference(
|
|
116
|
+
function_name="weather_helper",
|
|
117
|
+
input={
|
|
118
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
119
|
+
"messages": [
|
|
120
|
+
{
|
|
121
|
+
"role": "user",
|
|
122
|
+
"content": "Hi I'm visiting Brooklyn from Brazil. What's the weather?",
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
)
|
|
127
|
+
assert result.variant_name == "variant"
|
|
128
|
+
output = result.output
|
|
129
|
+
assert len(output) == 1
|
|
130
|
+
assert isinstance(output[0], ToolCall)
|
|
131
|
+
assert output[0].name == "get_temperature"
|
|
132
|
+
assert output[0].id == "0"
|
|
133
|
+
assert output[0].arguments == '{"location":"Brooklyn","units":"celsius"}'
|
|
134
|
+
assert output[0].parsed_name == "get_temperature"
|
|
135
|
+
assert output[0].parsed_arguments == {"location": "Brooklyn", "units": "celsius"}
|
|
136
|
+
usage = result.usage
|
|
137
|
+
assert usage.input_tokens == 10
|
|
138
|
+
assert usage.output_tokens == 10
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@pytest.mark.asyncio
|
|
142
|
+
async def test_malformed_tool_call_inference(client):
|
|
143
|
+
result = await client.inference(
|
|
144
|
+
function_name="weather_helper",
|
|
145
|
+
input={
|
|
146
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
147
|
+
"messages": [
|
|
148
|
+
{
|
|
149
|
+
"role": "user",
|
|
150
|
+
"content": "Hi I'm visiting Brooklyn from Brazil. What's the weather?",
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
variant_name="bad_tool",
|
|
155
|
+
)
|
|
156
|
+
assert result.variant_name == "bad_tool"
|
|
157
|
+
output = result.output
|
|
158
|
+
assert len(output) == 1
|
|
159
|
+
assert isinstance(output[0], ToolCall)
|
|
160
|
+
assert output[0].name == "get_temperature"
|
|
161
|
+
assert output[0].id == "0"
|
|
162
|
+
assert output[0].arguments == '{"location":"Brooklyn","units":"Celsius"}'
|
|
163
|
+
assert output[0].parsed_name == "get_temperature"
|
|
164
|
+
assert output[0].parsed_arguments is None
|
|
165
|
+
usage = result.usage
|
|
166
|
+
assert usage.input_tokens == 10
|
|
167
|
+
assert usage.output_tokens == 10
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@pytest.mark.asyncio
|
|
171
|
+
async def test_tool_call_streaming(client):
|
|
172
|
+
stream = await client.inference(
|
|
173
|
+
function_name="weather_helper",
|
|
174
|
+
input={
|
|
175
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
176
|
+
"messages": [
|
|
177
|
+
{
|
|
178
|
+
"role": "user",
|
|
179
|
+
"content": "Hi I'm visiting Brooklyn from Brazil. What's the weather?",
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
stream=True,
|
|
184
|
+
)
|
|
185
|
+
chunks = [chunk async for chunk in stream]
|
|
186
|
+
expected_text = [
|
|
187
|
+
'{"location"',
|
|
188
|
+
':"Brooklyn"',
|
|
189
|
+
',"units"',
|
|
190
|
+
':"celsius',
|
|
191
|
+
'"}',
|
|
192
|
+
]
|
|
193
|
+
previous_inference_id = None
|
|
194
|
+
previous_episode_id = None
|
|
195
|
+
for i, chunk in enumerate(chunks):
|
|
196
|
+
if previous_inference_id is not None:
|
|
197
|
+
assert chunk.inference_id == previous_inference_id
|
|
198
|
+
if previous_episode_id is not None:
|
|
199
|
+
assert chunk.episode_id == previous_episode_id
|
|
200
|
+
previous_inference_id = chunk.inference_id
|
|
201
|
+
previous_episode_id = chunk.episode_id
|
|
202
|
+
variant_name = chunk.variant_name
|
|
203
|
+
assert variant_name == "variant"
|
|
204
|
+
if i + 1 < len(chunks):
|
|
205
|
+
assert len(chunk.content) == 1
|
|
206
|
+
assert isinstance(chunk.content[0], ToolCallChunk)
|
|
207
|
+
assert chunk.content[0].name == "get_temperature"
|
|
208
|
+
assert chunk.content[0].id == "0"
|
|
209
|
+
assert chunk.content[0].arguments == expected_text[i]
|
|
210
|
+
else:
|
|
211
|
+
assert len(chunk.content) == 0
|
|
212
|
+
assert chunk.usage.input_tokens == 10
|
|
213
|
+
assert chunk.usage.output_tokens == 5
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@pytest.mark.asyncio
|
|
217
|
+
async def test_json_streaming(client):
|
|
218
|
+
# We don't actually have a streaming JSON function implemented in `dummy.rs` but it doesn't matter for this test since
|
|
219
|
+
# TensorZero doesn't parse the JSON output of the function for streaming calls.
|
|
220
|
+
stream = await client.inference(
|
|
221
|
+
function_name="json_success",
|
|
222
|
+
input={
|
|
223
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
224
|
+
"messages": [{"role": "user", "content": "Hello, world!"}],
|
|
225
|
+
},
|
|
226
|
+
stream=True,
|
|
227
|
+
)
|
|
228
|
+
chunks = [chunk async for chunk in stream]
|
|
229
|
+
expected_text = [
|
|
230
|
+
"Wally,",
|
|
231
|
+
" the",
|
|
232
|
+
" golden",
|
|
233
|
+
" retriever,",
|
|
234
|
+
" wagged",
|
|
235
|
+
" his",
|
|
236
|
+
" tail",
|
|
237
|
+
" excitedly",
|
|
238
|
+
" as",
|
|
239
|
+
" he",
|
|
240
|
+
" devoured",
|
|
241
|
+
" a",
|
|
242
|
+
" slice",
|
|
243
|
+
" of",
|
|
244
|
+
" cheese",
|
|
245
|
+
" pizza.",
|
|
246
|
+
]
|
|
247
|
+
previous_inference_id = None
|
|
248
|
+
previous_episode_id = None
|
|
249
|
+
for i, chunk in enumerate(chunks):
|
|
250
|
+
if previous_inference_id is not None:
|
|
251
|
+
assert chunk.inference_id == previous_inference_id
|
|
252
|
+
if previous_episode_id is not None:
|
|
253
|
+
assert chunk.episode_id == previous_episode_id
|
|
254
|
+
previous_inference_id = chunk.inference_id
|
|
255
|
+
previous_episode_id = chunk.episode_id
|
|
256
|
+
variant_name = chunk.variant_name
|
|
257
|
+
assert variant_name == "test"
|
|
258
|
+
if i + 1 < len(chunks):
|
|
259
|
+
assert chunk.raw == expected_text[i]
|
|
260
|
+
else:
|
|
261
|
+
assert chunk.usage.input_tokens == 10
|
|
262
|
+
assert chunk.usage.output_tokens == 16
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
@pytest.mark.asyncio
|
|
266
|
+
async def test_json_sucess(client):
|
|
267
|
+
result = await client.inference(
|
|
268
|
+
function_name="json_success",
|
|
269
|
+
input={
|
|
270
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
271
|
+
"messages": [{"role": "user", "content": "Hello, world!"}],
|
|
272
|
+
},
|
|
273
|
+
stream=False,
|
|
274
|
+
)
|
|
275
|
+
assert result.variant_name == "test"
|
|
276
|
+
assert result.output.raw == '{"answer":"Hello"}'
|
|
277
|
+
assert result.output.parsed == {"answer": "Hello"}
|
|
278
|
+
assert result.usage.input_tokens == 10
|
|
279
|
+
assert result.usage.output_tokens == 10
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
@pytest.mark.asyncio
|
|
283
|
+
async def test_json_failure(client):
|
|
284
|
+
result = await client.inference(
|
|
285
|
+
function_name="json_fail",
|
|
286
|
+
input={
|
|
287
|
+
"system": {"assistant_name": "Alfred Pennyworth"},
|
|
288
|
+
"messages": [{"role": "user", "content": "Hello, world!"}],
|
|
289
|
+
},
|
|
290
|
+
stream=False,
|
|
291
|
+
)
|
|
292
|
+
assert result.variant_name == "test"
|
|
293
|
+
assert (
|
|
294
|
+
result.output.raw
|
|
295
|
+
== "Megumin gleefully chanted her spell, unleashing a thunderous explosion that lit up the sky and left a massive crater in its wake."
|
|
296
|
+
)
|
|
297
|
+
assert result.output.parsed is None
|
|
298
|
+
assert result.usage.input_tokens == 10
|
|
299
|
+
assert result.usage.output_tokens == 10
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
@pytest.mark.asyncio
|
|
303
|
+
async def test_feedback(client):
|
|
304
|
+
result = await client.feedback(
|
|
305
|
+
metric_name="user_rating", value=5, episode_id=uuid7()
|
|
306
|
+
)
|
|
307
|
+
assert isinstance(result, FeedbackResponse)
|
|
308
|
+
|
|
309
|
+
result = await client.feedback(
|
|
310
|
+
metric_name="task_success", value=True, inference_id=uuid7()
|
|
311
|
+
)
|
|
312
|
+
assert isinstance(result, FeedbackResponse)
|
|
313
|
+
|
|
314
|
+
result = await client.feedback(
|
|
315
|
+
metric_name="demonstration", value="hi how are you", inference_id=uuid7()
|
|
316
|
+
)
|
|
317
|
+
assert isinstance(result, FeedbackResponse)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
@pytest.mark.asyncio
|
|
321
|
+
async def test_feedback_invalid_input(client):
|
|
322
|
+
with pytest.raises(ValueError):
|
|
323
|
+
await client.feedback(metric_name="test_metric", value=5)
|
|
324
|
+
|
|
325
|
+
with pytest.raises(ValueError):
|
|
326
|
+
await client.feedback(
|
|
327
|
+
metric_name="test_metric",
|
|
328
|
+
value=5,
|
|
329
|
+
episode_id=UUID("123e4567-e89b-12d3-a456-426614174000"),
|
|
330
|
+
inference_id=UUID("123e4567-e89b-12d3-a456-426614174001"),
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
# Add more tests as needed for edge cases, error handling, etc.
|
tensorzero-0.0.1/uv.lock
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
version = 1
|
|
2
|
+
requires-python = ">=3.10"
|
|
3
|
+
|
|
4
|
+
[[package]]
|
|
5
|
+
name = "anyio"
|
|
6
|
+
version = "4.4.0"
|
|
7
|
+
source = { registry = "https://pypi.org/simple" }
|
|
8
|
+
dependencies = [
|
|
9
|
+
{ name = "exceptiongroup", marker = "python_full_version < '3.11'" },
|
|
10
|
+
{ name = "idna" },
|
|
11
|
+
{ name = "sniffio" },
|
|
12
|
+
{ name = "typing-extensions", marker = "python_full_version < '3.11'" },
|
|
13
|
+
]
|
|
14
|
+
sdist = { url = "https://files.pythonhosted.org/packages/e6/e3/c4c8d473d6780ef1853d630d581f70d655b4f8d7553c6997958c283039a2/anyio-4.4.0.tar.gz", hash = "sha256:5aadc6a1bbb7cdb0bede386cac5e2940f5e2ff3aa20277e991cf028e0585ce94", size = 163930 }
|
|
15
|
+
wheels = [
|
|
16
|
+
{ url = "https://files.pythonhosted.org/packages/7b/a2/10639a79341f6c019dedc95bd48a4928eed9f1d1197f4c04f546fc7ae0ff/anyio-4.4.0-py3-none-any.whl", hash = "sha256:c1b2d8f46a8a812513012e1107cb0e68c17159a7a594208005a57dc776e1bdc7", size = 86780 },
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[[package]]
|
|
20
|
+
name = "certifi"
|
|
21
|
+
version = "2024.7.4"
|
|
22
|
+
source = { registry = "https://pypi.org/simple" }
|
|
23
|
+
sdist = { url = "https://files.pythonhosted.org/packages/c2/02/a95f2b11e207f68bc64d7aae9666fed2e2b3f307748d5123dffb72a1bbea/certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b", size = 164065 }
|
|
24
|
+
wheels = [
|
|
25
|
+
{ url = "https://files.pythonhosted.org/packages/1c/d5/c84e1a17bf61d4df64ca866a1c9a913874b4e9bdc131ec689a0ad013fb36/certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90", size = 162960 },
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[[package]]
|
|
29
|
+
name = "colorama"
|
|
30
|
+
version = "0.4.6"
|
|
31
|
+
source = { registry = "https://pypi.org/simple" }
|
|
32
|
+
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697 }
|
|
33
|
+
wheels = [
|
|
34
|
+
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335 },
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[[package]]
|
|
38
|
+
name = "exceptiongroup"
|
|
39
|
+
version = "1.2.2"
|
|
40
|
+
source = { registry = "https://pypi.org/simple" }
|
|
41
|
+
sdist = { url = "https://files.pythonhosted.org/packages/09/35/2495c4ac46b980e4ca1f6ad6db102322ef3ad2410b79fdde159a4b0f3b92/exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc", size = 28883 }
|
|
42
|
+
wheels = [
|
|
43
|
+
{ url = "https://files.pythonhosted.org/packages/02/cc/b7e31358aac6ed1ef2bb790a9746ac2c69bcb3c8588b41616914eb106eaf/exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b", size = 16453 },
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[[package]]
|
|
47
|
+
name = "h11"
|
|
48
|
+
version = "0.14.0"
|
|
49
|
+
source = { registry = "https://pypi.org/simple" }
|
|
50
|
+
sdist = { url = "https://files.pythonhosted.org/packages/f5/38/3af3d3633a34a3316095b39c8e8fb4853a28a536e55d347bd8d8e9a14b03/h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d", size = 100418 }
|
|
51
|
+
wheels = [
|
|
52
|
+
{ url = "https://files.pythonhosted.org/packages/95/04/ff642e65ad6b90db43e668d70ffb6736436c7ce41fcc549f4e9472234127/h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761", size = 58259 },
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[[package]]
|
|
56
|
+
name = "httpcore"
|
|
57
|
+
version = "1.0.5"
|
|
58
|
+
source = { registry = "https://pypi.org/simple" }
|
|
59
|
+
dependencies = [
|
|
60
|
+
{ name = "certifi" },
|
|
61
|
+
{ name = "h11" },
|
|
62
|
+
]
|
|
63
|
+
sdist = { url = "https://files.pythonhosted.org/packages/17/b0/5e8b8674f8d203335a62fdfcfa0d11ebe09e23613c3391033cbba35f7926/httpcore-1.0.5.tar.gz", hash = "sha256:34a38e2f9291467ee3b44e89dd52615370e152954ba21721378a87b2960f7a61", size = 83234 }
|
|
64
|
+
wheels = [
|
|
65
|
+
{ url = "https://files.pythonhosted.org/packages/78/d4/e5d7e4f2174f8a4d63c8897d79eb8fe2503f7ecc03282fee1fa2719c2704/httpcore-1.0.5-py3-none-any.whl", hash = "sha256:421f18bac248b25d310f3cacd198d55b8e6125c107797b609ff9b7a6ba7991b5", size = 77926 },
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
[[package]]
|
|
69
|
+
name = "httpx"
|
|
70
|
+
version = "0.27.0"
|
|
71
|
+
source = { registry = "https://pypi.org/simple" }
|
|
72
|
+
dependencies = [
|
|
73
|
+
{ name = "anyio" },
|
|
74
|
+
{ name = "certifi" },
|
|
75
|
+
{ name = "httpcore" },
|
|
76
|
+
{ name = "idna" },
|
|
77
|
+
{ name = "sniffio" },
|
|
78
|
+
]
|
|
79
|
+
sdist = { url = "https://files.pythonhosted.org/packages/5c/2d/3da5bdf4408b8b2800061c339f240c1802f2e82d55e50bd39c5a881f47f0/httpx-0.27.0.tar.gz", hash = "sha256:a0cb88a46f32dc874e04ee956e4c2764aba2aa228f650b06788ba6bda2962ab5", size = 126413 }
|
|
80
|
+
wheels = [
|
|
81
|
+
{ url = "https://files.pythonhosted.org/packages/41/7b/ddacf6dcebb42466abd03f368782142baa82e08fc0c1f8eaa05b4bae87d5/httpx-0.27.0-py3-none-any.whl", hash = "sha256:71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5", size = 75590 },
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
[[package]]
|
|
85
|
+
name = "idna"
|
|
86
|
+
version = "3.8"
|
|
87
|
+
source = { registry = "https://pypi.org/simple" }
|
|
88
|
+
sdist = { url = "https://files.pythonhosted.org/packages/e8/ac/e349c5e6d4543326c6883ee9491e3921e0d07b55fdf3cce184b40d63e72a/idna-3.8.tar.gz", hash = "sha256:d838c2c0ed6fced7693d5e8ab8e734d5f8fda53a039c0164afb0b82e771e3603", size = 189467 }
|
|
89
|
+
wheels = [
|
|
90
|
+
{ url = "https://files.pythonhosted.org/packages/22/7e/d71db821f177828df9dea8c42ac46473366f191be53080e552e628aad991/idna-3.8-py3-none-any.whl", hash = "sha256:050b4e5baadcd44d760cedbd2b8e639f2ff89bbc7a5730fcc662954303377aac", size = 66894 },
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
[[package]]
|
|
94
|
+
name = "iniconfig"
|
|
95
|
+
version = "2.0.0"
|
|
96
|
+
source = { registry = "https://pypi.org/simple" }
|
|
97
|
+
sdist = { url = "https://files.pythonhosted.org/packages/d7/4b/cbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913/iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", size = 4646 }
|
|
98
|
+
wheels = [
|
|
99
|
+
{ url = "https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892 },
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
[[package]]
|
|
103
|
+
name = "packaging"
|
|
104
|
+
version = "24.1"
|
|
105
|
+
source = { registry = "https://pypi.org/simple" }
|
|
106
|
+
sdist = { url = "https://files.pythonhosted.org/packages/51/65/50db4dda066951078f0a96cf12f4b9ada6e4b811516bf0262c0f4f7064d4/packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002", size = 148788 }
|
|
107
|
+
wheels = [
|
|
108
|
+
{ url = "https://files.pythonhosted.org/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124", size = 53985 },
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
[[package]]
|
|
112
|
+
name = "pluggy"
|
|
113
|
+
version = "1.5.0"
|
|
114
|
+
source = { registry = "https://pypi.org/simple" }
|
|
115
|
+
sdist = { url = "https://files.pythonhosted.org/packages/96/2d/02d4312c973c6050a18b314a5ad0b3210edb65a906f868e31c111dede4a6/pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1", size = 67955 }
|
|
116
|
+
wheels = [
|
|
117
|
+
{ url = "https://files.pythonhosted.org/packages/88/5f/e351af9a41f866ac3f1fac4ca0613908d9a41741cfcf2228f4ad853b697d/pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669", size = 20556 },
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
[[package]]
|
|
121
|
+
name = "pytest"
|
|
122
|
+
version = "8.3.2"
|
|
123
|
+
source = { registry = "https://pypi.org/simple" }
|
|
124
|
+
dependencies = [
|
|
125
|
+
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
|
126
|
+
{ name = "exceptiongroup", marker = "python_full_version < '3.11'" },
|
|
127
|
+
{ name = "iniconfig" },
|
|
128
|
+
{ name = "packaging" },
|
|
129
|
+
{ name = "pluggy" },
|
|
130
|
+
{ name = "tomli", marker = "python_full_version < '3.11'" },
|
|
131
|
+
]
|
|
132
|
+
sdist = { url = "https://files.pythonhosted.org/packages/b4/8c/9862305bdcd6020bc7b45b1b5e7397a6caf1a33d3025b9a003b39075ffb2/pytest-8.3.2.tar.gz", hash = "sha256:c132345d12ce551242c87269de812483f5bcc87cdbb4722e48487ba194f9fdce", size = 1439314 }
|
|
133
|
+
wheels = [
|
|
134
|
+
{ url = "https://files.pythonhosted.org/packages/0f/f9/cf155cf32ca7d6fa3601bc4c5dd19086af4b320b706919d48a4c79081cf9/pytest-8.3.2-py3-none-any.whl", hash = "sha256:4ba08f9ae7dcf84ded419494d229b48d0903ea6407b030eaec46df5e6a73bba5", size = 341802 },
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
[[package]]
|
|
138
|
+
name = "pytest-asyncio"
|
|
139
|
+
version = "0.24.0"
|
|
140
|
+
source = { registry = "https://pypi.org/simple" }
|
|
141
|
+
dependencies = [
|
|
142
|
+
{ name = "pytest" },
|
|
143
|
+
]
|
|
144
|
+
sdist = { url = "https://files.pythonhosted.org/packages/52/6d/c6cf50ce320cf8611df7a1254d86233b3df7cc07f9b5f5cbcb82e08aa534/pytest_asyncio-0.24.0.tar.gz", hash = "sha256:d081d828e576d85f875399194281e92bf8a68d60d72d1a2faf2feddb6c46b276", size = 49855 }
|
|
145
|
+
wheels = [
|
|
146
|
+
{ url = "https://files.pythonhosted.org/packages/96/31/6607dab48616902f76885dfcf62c08d929796fc3b2d2318faf9fd54dbed9/pytest_asyncio-0.24.0-py3-none-any.whl", hash = "sha256:a811296ed596b69bf0b6f3dc40f83bcaf341b155a269052d82efa2b25ac7037b", size = 18024 },
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
[[package]]
|
|
150
|
+
name = "sniffio"
|
|
151
|
+
version = "1.3.1"
|
|
152
|
+
source = { registry = "https://pypi.org/simple" }
|
|
153
|
+
sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372 }
|
|
154
|
+
wheels = [
|
|
155
|
+
{ url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235 },
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
[[package]]
|
|
159
|
+
name = "tensorzero"
|
|
160
|
+
version = "0.1.0"
|
|
161
|
+
source = { editable = "." }
|
|
162
|
+
dependencies = [
|
|
163
|
+
{ name = "httpx" },
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
[package.dev-dependencies]
|
|
167
|
+
dev = [
|
|
168
|
+
{ name = "pytest" },
|
|
169
|
+
{ name = "pytest-asyncio" },
|
|
170
|
+
{ name = "uuid7" },
|
|
171
|
+
]
|
|
172
|
+
|
|
173
|
+
[package.metadata]
|
|
174
|
+
requires-dist = [{ name = "httpx", specifier = ">=0.27.0" }]
|
|
175
|
+
|
|
176
|
+
[package.metadata.requires-dev]
|
|
177
|
+
dev = [
|
|
178
|
+
{ name = "pytest", specifier = ">=8.3.2" },
|
|
179
|
+
{ name = "pytest-asyncio", specifier = ">=0.24.0" },
|
|
180
|
+
{ name = "uuid7", specifier = ">=0.1.0" },
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
[[package]]
|
|
184
|
+
name = "tomli"
|
|
185
|
+
version = "2.0.1"
|
|
186
|
+
source = { registry = "https://pypi.org/simple" }
|
|
187
|
+
sdist = { url = "https://files.pythonhosted.org/packages/c0/3f/d7af728f075fb08564c5949a9c95e44352e23dee646869fa104a3b2060a3/tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f", size = 15164 }
|
|
188
|
+
wheels = [
|
|
189
|
+
{ url = "https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", size = 12757 },
|
|
190
|
+
]
|
|
191
|
+
|
|
192
|
+
[[package]]
|
|
193
|
+
name = "typing-extensions"
|
|
194
|
+
version = "4.12.2"
|
|
195
|
+
source = { registry = "https://pypi.org/simple" }
|
|
196
|
+
sdist = { url = "https://files.pythonhosted.org/packages/df/db/f35a00659bc03fec321ba8bce9420de607a1d37f8342eee1863174c69557/typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8", size = 85321 }
|
|
197
|
+
wheels = [
|
|
198
|
+
{ url = "https://files.pythonhosted.org/packages/26/9f/ad63fc0248c5379346306f8668cda6e2e2e9c95e01216d2b8ffd9ff037d0/typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d", size = 37438 },
|
|
199
|
+
]
|
|
200
|
+
|
|
201
|
+
[[package]]
|
|
202
|
+
name = "uuid7"
|
|
203
|
+
version = "0.1.0"
|
|
204
|
+
source = { registry = "https://pypi.org/simple" }
|
|
205
|
+
sdist = { url = "https://files.pythonhosted.org/packages/5c/19/7472bd526591e2192926247109dbf78692e709d3e56775792fec877a7720/uuid7-0.1.0.tar.gz", hash = "sha256:8c57aa32ee7456d3cc68c95c4530bc571646defac01895cfc73545449894a63c", size = 14052 }
|
|
206
|
+
wheels = [
|
|
207
|
+
{ url = "https://files.pythonhosted.org/packages/b5/77/8852f89a91453956582a85024d80ad96f30a41fed4c2b3dce0c9f12ecc7e/uuid7-0.1.0-py2.py3-none-any.whl", hash = "sha256:5e259bb63c8cb4aded5927ff41b444a80d0c7124e8a0ced7cf44efa1f5cccf61", size = 7477 },
|
|
208
|
+
]
|