Skip to content

Commit 0eedb02

Browse files
authored
Merge branch 'main' into feat/ollama-provider
2 parents 2dd7490 + dee5f59 commit 0eedb02

File tree

111 files changed

+1635
-1177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1635
-1177
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ resolver = "2"
2323
version = "2025.11.6"
2424
rust-version = "1.88.0"
2525
license = "Apache-2.0"
26+
edition = "2024"
2627

2728
[workspace.dependencies]
2829
reqwest = { version = "0.12.24", features = [

clients/python/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
name = "tensorzero-python"
66
version.workspace = true
77
rust-version.workspace = true
8-
edition = "2021"
8+
edition.workspace = true
99
license.workspace = true
1010

1111
[lints]

clients/python/DEVELOPER_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,5 @@ The generated python is:
133133
```python
134134
@dataclass
135135
class DatapointMetadataUpdate:
136-
name: str | None | UnsetType = UNSET
136+
name: str | None | OmitType = OMIT
137137
```

clients/python/generate_schema_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
2. When merging the schema files, some references are recursive (e.g. `InferenceFilter`) that point to the root schema of these
3434
types, so we need to rewrite the `$ref`s to point to the schema definition itself instead of the root schema (which becomes
3535
`Any` after python dataclass generation).
36-
3. We generate a custom header file for the generated types to include the `UNSET` sentinel value.
36+
3. We generate a custom header file for the generated types to include the `OMIT` sentinel value.
3737
3838
3939
To run this script: run `pnpm generate-python-schemas` from the root of the repository.

clients/python/src/evaluation_handlers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::sync::Arc;
22

33
use evaluations::{
4-
stats::{EvaluationError, EvaluationInfo, EvaluationStats, EvaluationUpdate},
54
OutputFormat, RunInfo,
5+
stats::{EvaluationError, EvaluationInfo, EvaluationStats, EvaluationUpdate},
66
};
77
use pyo3::{
88
exceptions::{PyStopAsyncIteration, PyStopIteration},

clients/python/src/gil_helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::future::Future;
22

3-
use pyo3::{marker::Ungil, Python};
3+
use pyo3::{Python, marker::Ungil};
44
/// Runs a function inside the Tokio runtime, with the GIL released.
55
/// This is used when we need to drop a TensorZero client (or a type that holds it),
66
/// so that we can block on the ClickHouse batcher shutting down, without holding the GIL.

clients/python/src/lib.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
/// and defines methods on them.
1212
use std::{collections::HashMap, path::PathBuf, sync::Arc, time::Duration};
1313

14-
use evaluations::{run_evaluation_core_streaming, EvaluationCoreArgs, EvaluationVariant};
14+
use evaluations::{EvaluationCoreArgs, EvaluationVariant, run_evaluation_core_streaming};
1515
use futures::StreamExt;
1616
use pyo3::{
17+
IntoPyObjectExt,
1718
exceptions::{PyDeprecationWarning, PyStopAsyncIteration, PyStopIteration, PyValueError},
1819
ffi::c_str,
1920
prelude::*,
2021
types::{PyDict, PyList, PyString, PyType},
21-
IntoPyObjectExt,
2222
};
2323
use python_helpers::{
2424
convert_response_to_python_dataclass, parse_feedback_response, parse_inference_chunk,
@@ -32,20 +32,19 @@ use tensorzero_core::{
3232
db::clickhouse::query_builder::OrderBy,
3333
function::{FunctionConfigChatPyClass, FunctionConfigJsonPyClass, VariantsConfigPyClass},
3434
inference::types::{
35+
ResolvedInput, ResolvedInputMessage,
3536
pyo3_helpers::{
36-
deserialize_from_pyobj, deserialize_from_rendered_sample,
37+
JSON_DUMPS, JSON_LOADS, deserialize_from_pyobj, deserialize_from_rendered_sample,
3738
deserialize_from_stored_sample, deserialize_optimization_config, serialize_to_dict,
38-
tensorzero_core_error, tensorzero_core_error_class, tensorzero_error_class, JSON_DUMPS,
39-
JSON_LOADS,
39+
tensorzero_core_error, tensorzero_core_error_class, tensorzero_error_class,
4040
},
41-
ResolvedInput, ResolvedInputMessage,
4241
},
4342
optimization::{
43+
OptimizationJobInfoPyClass, OptimizationJobStatus, UninitializedOptimizerInfo,
4444
dicl::UninitializedDiclOptimizationConfig, fireworks_sft::UninitializedFireworksSFTConfig,
4545
gcp_vertex_gemini_sft::UninitializedGCPVertexGeminiSFTConfig,
4646
openai_rft::UninitializedOpenAIRFTConfig, openai_sft::UninitializedOpenAISFTConfig,
47-
together_sft::UninitializedTogetherSFTConfig, OptimizationJobInfoPyClass,
48-
OptimizationJobStatus, UninitializedOptimizerInfo,
47+
together_sft::UninitializedTogetherSFTConfig,
4948
},
5049
tool::ProviderTool,
5150
variant::{
@@ -64,11 +63,11 @@ use tensorzero_core::{
6463
utils::gateway::ShutdownHandle,
6564
};
6665
use tensorzero_rust::{
67-
err_to_http, observability::LogFormat, CacheParamsOptions, Client, ClientBuilder,
68-
ClientBuilderMode, ClientExt, ClientInferenceParams, ClientSecretString, Datapoint,
69-
DynamicToolParams, FeedbackParams, InferenceOutput, InferenceParams, InferenceStream, Input,
70-
LaunchOptimizationParams, ListDatapointsRequest, ListInferencesParams, OptimizationJobHandle,
71-
RenderedSample, StoredInference, TensorZeroError, Tool, WorkflowEvaluationRunParams,
66+
CacheParamsOptions, Client, ClientBuilder, ClientBuilderMode, ClientExt, ClientInferenceParams,
67+
ClientSecretString, Datapoint, DynamicToolParams, FeedbackParams, InferenceOutput,
68+
InferenceParams, InferenceStream, Input, LaunchOptimizationParams, ListDatapointsRequest,
69+
ListInferencesParams, OptimizationJobHandle, RenderedSample, StoredInference, TensorZeroError,
70+
Tool, WorkflowEvaluationRunParams, err_to_http, observability::LogFormat,
7271
};
7372
use tokio::sync::Mutex;
7473
use url::Url;
@@ -79,7 +78,7 @@ mod gil_helpers;
7978
mod python_helpers;
8079

8180
use crate::evaluation_handlers::{AsyncEvaluationJobHandler, EvaluationJobHandler};
82-
use crate::gil_helpers::{tokio_block_on_without_gil, DropInTokio};
81+
use crate::gil_helpers::{DropInTokio, tokio_block_on_without_gil};
8382

8483
#[pymodule]
8584
fn tensorzero(m: &Bound<'_, PyModule>) -> PyResult<()> {
@@ -3015,7 +3014,10 @@ fn warn_no_config(py: Python<'_>, config: Option<&str>) -> PyResult<()> {
30153014
PyErr::warn(
30163015
py,
30173016
&user_warning,
3018-
c_str!("No config file provided, so only default functions will be available. Use `config_file=\"path/to/tensorzero.toml\"` to specify a config file."), 0
3017+
c_str!(
3018+
"No config file provided, so only default functions will be available. Use `config_file=\"path/to/tensorzero.toml\"` to specify a config file."
3019+
),
3020+
0,
30193021
)?;
30203022
}
30213023
Ok(())

clients/python/templates/dataclass.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class {{ class_name }}:
2727
{{ field.name }}: {{ field.type_hint }} = {{ field.field }}
2828
{%- else %}
2929
{%- if field.extras and field.extras.get('x_double_option') %}
30-
{{ field.name }}: {{ field.type_hint }} | UnsetType = UNSET
30+
{{ field.name }}: {{ field.type_hint }} | OmitType = OMIT
3131
{%- else %}
3232
{{ field.name }}: {{ field.type_hint }}
3333
{%- if not (field.required or (field.represented_default == 'None' and field.strip_default_none))

clients/python/templates/generated_types_header.py.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ To regenerate, run:
1111
"""
1212

1313
from __future__ import annotations
14-
from .unset_type import UNSET, UnsetType
14+
from .omit_type import OMIT, OmitType

clients/python/tensorzero/generated_types.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from dataclasses import dataclass, field
1616
from typing import Any, Literal
1717

18-
from .unset_type import UNSET, UnsetType
18+
from .omit_type import OMIT, OmitType
1919

2020
Model = Any
2121

@@ -77,11 +77,11 @@ class DatapointMetadataUpdate:
7777
A request to update the metadata of a datapoint.
7878
"""
7979

80-
name: str | None | UnsetType = UNSET
80+
name: str | None | OmitType = OMIT
8181
"""
8282
Datapoint name.
8383
84-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared. If specified as a value, it will
84+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared. If specified as a value, it will
8585
be set to the provided value.
8686
"""
8787

@@ -871,11 +871,11 @@ class UpdateDatapointMetadataRequest:
871871
"""
872872
The ID of the datapoint to update. Required.
873873
"""
874-
name: str | None | UnsetType = UNSET
874+
name: str | None | OmitType = OMIT
875875
"""
876876
Datapoint name.
877877
878-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared. If specified as a value, it will
878+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared. If specified as a value, it will
879879
be set to the provided value.
880880
"""
881881

@@ -1348,30 +1348,30 @@ class UpdateDynamicToolParamsRequest:
13481348
new tools or exclude removed tools.
13491349
If omitted, it will be left unchanged. If specified as a value, it will be set to the provided value.
13501350
"""
1351-
allowed_tools: list[str] | None | UnsetType = UNSET
1351+
allowed_tools: list[str] | None | OmitType = OMIT
13521352
"""
13531353
A subset of static tools configured for the function that the inference is explicitly allowed to use.
13541354
1355-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared (we allow function-configured tools
1355+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared (we allow function-configured tools
13561356
plus additional tools provided at inference time). If specified as a value, it will be set to the provided value.
13571357
"""
1358-
parallel_tool_calls: bool | None | UnsetType = UNSET
1358+
parallel_tool_calls: bool | None | OmitType = OMIT
13591359
"""
13601360
Whether to use parallel tool calls in the inference.
13611361
1362-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared (we will use function-configured
1362+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared (we will use function-configured
13631363
parallel tool calls). If specified as a value, it will be set to the provided value.
13641364
"""
13651365
provider_tools: list[ProviderTool] | None = None
13661366
"""
13671367
Provider-specific tool configurations
13681368
If omitted, it will be left unchanged. If specified as a value, it will be set to the provided value.
13691369
"""
1370-
tool_choice: ToolChoice | None | UnsetType = UNSET
1370+
tool_choice: ToolChoice | None | OmitType = OMIT
13711371
"""
13721372
User-specified tool choice strategy.
13731373
1374-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared (we will use function-configured
1374+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared (we will use function-configured
13751375
tool choice). If specified as a value, it will be set to the provided value.
13761376
"""
13771377

@@ -1575,11 +1575,11 @@ class UpdateChatDatapointRequestInternal:
15751575
new tools or exclude removed tools.
15761576
If omitted, it will be left unchanged. If specified as a value, it will be set to the provided value.
15771577
"""
1578-
allowed_tools: list[str] | None | UnsetType = UNSET
1578+
allowed_tools: list[str] | None | OmitType = OMIT
15791579
"""
15801580
A subset of static tools configured for the function that the inference is explicitly allowed to use.
15811581
1582-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared (we allow function-configured tools
1582+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared (we allow function-configured tools
15831583
plus additional tools provided at inference time). If specified as a value, it will be set to the provided value.
15841584
"""
15851585
input: Input | None = None
@@ -1591,25 +1591,25 @@ class UpdateChatDatapointRequestInternal:
15911591
DEPRECATED (#4725 / 2026.2+): Metadata fields to update.
15921592
Moving forward, don't nest these fields.
15931593
"""
1594-
name: str | None | UnsetType = UNSET
1594+
name: str | None | OmitType = OMIT
15951595
"""
15961596
Datapoint name.
15971597
1598-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared. If specified as a value, it will
1598+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared. If specified as a value, it will
15991599
be set to the provided value.
16001600
"""
1601-
output: list[ContentBlockChatOutput] | None | UnsetType = UNSET
1601+
output: list[ContentBlockChatOutput] | None | OmitType = OMIT
16021602
"""
16031603
Chat datapoint output.
16041604
1605-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared.
1605+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared.
16061606
Otherwise, it will overwrite the existing output (and can be an empty list).
16071607
"""
1608-
parallel_tool_calls: bool | None | UnsetType = UNSET
1608+
parallel_tool_calls: bool | None | OmitType = OMIT
16091609
"""
16101610
Whether to use parallel tool calls in the inference.
16111611
1612-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared (we will use function-configured
1612+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared (we will use function-configured
16131613
parallel tool calls). If specified as a value, it will be set to the provided value.
16141614
"""
16151615
provider_tools: list[ProviderTool] | None = None
@@ -1621,14 +1621,14 @@ class UpdateChatDatapointRequestInternal:
16211621
"""
16221622
Datapoint tags.
16231623
1624-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared.
1624+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared.
16251625
Otherwise, it will overwrite the existing tags.
16261626
"""
1627-
tool_choice: ToolChoice | None | UnsetType = UNSET
1627+
tool_choice: ToolChoice | None | OmitType = OMIT
16281628
"""
16291629
User-specified tool choice strategy.
16301630
1631-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared (we will use function-configured
1631+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared (we will use function-configured
16321632
tool choice). If specified as a value, it will be set to the provided value.
16331633
"""
16341634
tool_params: UpdateDynamicToolParamsRequest | None = None
@@ -1666,17 +1666,17 @@ class UpdateJsonDatapointRequestInternal:
16661666
DEPRECATED (#4725 / 2026.2+): Metadata fields to update.
16671667
Moving forward, don't nest these fields.
16681668
"""
1669-
name: str | None | UnsetType = UNSET
1669+
name: str | None | OmitType = OMIT
16701670
"""
16711671
Datapoint name.
16721672
1673-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared. If specified as a value, it will
1673+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared. If specified as a value, it will
16741674
be set to the provided value.
16751675
"""
1676-
output: JsonDatapointOutputUpdate | None | UnsetType = UNSET
1676+
output: JsonDatapointOutputUpdate | None | OmitType = OMIT
16771677
"""
16781678
JSON datapoint output.
1679-
If omitted (which uses the default value `UNSET`), it will be left unchanged. If set to `None`, it will be cleared (represents edge case where
1679+
If omitted (which uses the default value `OMIT`), it will be left unchanged. If set to `None`, it will be cleared (represents edge case where
16801680
inference succeeded but model didn't output relevant content blocks). Otherwise, it will overwrite the existing output.
16811681
"""
16821682
output_schema: Any | None = None

0 commit comments

Comments
 (0)