diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 14d98ddb..9ec1b3eb 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.4.23" + ".": "0.4.24" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index db98622c..36a55644 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 34 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-76382de80057321dae48471054ca469af8b5b5b1b0b252e92fd70d7a9998dd6d.yml -openapi_spec_hash: c1e34098e62dee3304ba1d49233e4e9d -config_hash: aeabb3a919ad2763f5d0f41961a2520a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-24426221ca34bef99c2533d049fc93a3b28718229d79339ff4a6f613a4f44ef6.yml +openapi_spec_hash: cb4a09c023345455749bfc45040951d6 +config_hash: 6481ea6b42040f435dedcb00a98f35f8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d9c334a..fc68ba84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Changelog +## 0.4.24 (2025-10-10) + +Full Changelog: [v0.4.23...v0.4.24](https://github.com/scaleapi/agentex-python/compare/v0.4.23...v0.4.24) + +### Features + +* **api:** manual updates ([09996ea](https://github.com/scaleapi/agentex-python/commit/09996ea688a7225670bdd9d944b64801fac7acce)) + + +### Bug Fixes + +* health check port handling ([#138](https://github.com/scaleapi/agentex-python/issues/138)) ([fe22301](https://github.com/scaleapi/agentex-python/commit/fe223012db49768f38c4de56b5d5744031b631d1)) + + +### Chores + +* do not install brew dependencies in ./scripts/bootstrap by default ([2675e14](https://github.com/scaleapi/agentex-python/commit/2675e14bf9f3a0113a849caf2283376c448f9d03)) +* improve example values ([6997fe5](https://github.com/scaleapi/agentex-python/commit/6997fe57910ea54d6d71b25fdea4497925c8ec63)) +* **internal:** detect missing future annotations with ruff ([f1aa71f](https://github.com/scaleapi/agentex-python/commit/f1aa71f89bb0e8369e6d895b5111dc15fd1e2c12)) +* **internal:** update pydantic dependency ([156ea64](https://github.com/scaleapi/agentex-python/commit/156ea64a4fa317d3ab483e7b9b6ba63471b618ef)) +* **internal:** version bump ([8567752](https://github.com/scaleapi/agentex-python/commit/85677527f5c8d393f0eea0a2a629da48fb56f4a9)) +* **internal:** version bump ([45206dd](https://github.com/scaleapi/agentex-python/commit/45206dd28643403800c386b75e1c9a442c8978ae)) +* **internal:** version bump ([98354ba](https://github.com/scaleapi/agentex-python/commit/98354ba2e7630798e25a8e278cba44c1aacc1e08)) +* **internal:** version bump ([aa2a8db](https://github.com/scaleapi/agentex-python/commit/aa2a8db5907f78b4b39849a1900dae27412359bb)) +* **internal:** version bump ([73bba2a](https://github.com/scaleapi/agentex-python/commit/73bba2a59e77fa31caab5b668781b71bc7c5ec2d)) +* **types:** change optional parameter type from NotGiven to Omit ([2117d77](https://github.com/scaleapi/agentex-python/commit/2117d77219da097e784d5d2deab1632a2855dae9)) + ## 0.4.23 (2025-10-02) Full Changelog: [v0.4.22...v0.4.23](https://github.com/scaleapi/agentex-python/compare/v0.4.22...v0.4.23) diff --git a/README.md b/README.md index 0ccc5f62..50ff2e44 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ It is generated with [Stainless](https://www.stainless.com/). ## Documentation -The full API of this library can be found in [api.md](api.md). +The REST API documentation can be found on [docs.gp.scale.com](https://docs.gp.scale.com). The full API of this library can be found in [api.md](api.md). ## Installation diff --git a/SECURITY.md b/SECURITY.md index d7ff1dab..95eca20a 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -18,6 +18,10 @@ before making any information public. If you encounter security issues that are not directly related to SDKs but pertain to the services or products provided by Agentex, please follow the respective company's security reporting guidelines. +### Agentex Terms and Policies + +Please contact roxanne.farhad@scale.com for any questions or concerns regarding the security of our services. + --- Thank you for helping us keep the SDKs and systems they interact with secure. diff --git a/pyproject.toml b/pyproject.toml index db829ecc..af6e4ddf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,11 @@ [project] name = "agentex-sdk" -version = "0.4.23" +version = "0.4.24" description = "The official Python library for the agentex API" dynamic = ["readme"] license = "Apache-2.0" authors = [ -{ name = "Agentex", email = "" }, +{ name = "Agentex", email = "roxanne.farhad@scale.com" }, ] dependencies = [ "httpx>=0.27.2,<0.28", @@ -292,6 +292,8 @@ select = [ "B", # remove unused imports "F401", + # check for missing future annotations + "FA102", # bare except statements "E722", # unused arguments @@ -314,6 +316,8 @@ unfixable = [ "T203", ] +extend-safe-fixes = ["FA102"] + [tool.ruff.lint.flake8-tidy-imports.banned-api] "functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead" diff --git a/requirements-dev.lock b/requirements-dev.lock index 3baf1c05..8057bb29 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -219,6 +219,20 @@ prompt-toolkit==3.0.51 propcache==0.3.1 # via aiohttp # via yarl +pydantic==2.11.9 + # via agentex-sdk + # via agentex-sdk + # via fastapi + # via litellm + # via mcp + # via openai + # via openai-agents + # via pydantic-settings + # via python-on-whales + # via scale-gp + # via scale-gp-beta +pydantic-core==2.33.2 + # via pydantic protobuf==5.29.5 # via ddtrace # via temporalio @@ -233,19 +247,6 @@ pyasn1==0.6.1 # via rsa pyasn1-modules==0.4.2 # via google-auth -pydantic==2.10.3 - # via agentex-sdk - # via fastapi - # via litellm - # via mcp - # via openai - # via openai-agents - # via pydantic-settings - # via python-on-whales - # via scale-gp - # via scale-gp-beta -pydantic-core==2.27.1 - # via pydantic pydantic-settings==2.10.1 # via mcp pygments==2.18.0 @@ -382,6 +383,9 @@ typing-extensions==4.12.2 # via pydantic # via pydantic-core # via pyright + # via typing-inspection +typing-inspection==0.4.1 + # via pydantic # via python-on-whales # via referencing # via scale-gp @@ -389,7 +393,6 @@ typing-extensions==4.12.2 # via temporalio # via typer # via typing-inspection -typing-inspection==0.4.1 # via pydantic-settings tzdata==2025.2 # via agentex-sdk diff --git a/requirements.lock b/requirements.lock index e055b69f..50e7ea25 100644 --- a/requirements.lock +++ b/requirements.lock @@ -200,6 +200,19 @@ prompt-toolkit==3.0.51 propcache==0.3.1 # via aiohttp # via yarl +pydantic==2.11.9 + # via agentex-sdk + # via fastapi + # via litellm + # via mcp + # via openai + # via openai-agents + # via pydantic-settings + # via python-on-whales + # via scale-gp + # via scale-gp-beta +pydantic-core==2.33.2 + # via pydantic protobuf==5.29.5 # via ddtrace # via temporalio @@ -214,19 +227,6 @@ pyasn1==0.6.1 # via rsa pyasn1-modules==0.4.2 # via google-auth -pydantic==2.10.3 - # via agentex-sdk - # via fastapi - # via litellm - # via mcp - # via openai - # via openai-agents - # via pydantic-settings - # via python-on-whales - # via scale-gp - # via scale-gp-beta -pydantic-core==2.27.1 - # via pydantic pydantic-settings==2.10.1 # via mcp pygments==2.19.2 @@ -351,6 +351,9 @@ typing-extensions==4.12.2 # via opentelemetry-api # via pydantic # via pydantic-core + # via typing-inspection +typing-inspection==0.4.1 + # via pydantic # via python-on-whales # via referencing # via scale-gp @@ -358,7 +361,6 @@ typing-extensions==4.12.2 # via temporalio # via typer # via typing-inspection -typing-inspection==0.4.1 # via pydantic-settings tzdata==2025.2 # via agentex-sdk diff --git a/scripts/bootstrap b/scripts/bootstrap index e84fe62c..b430fee3 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,10 +4,18 @@ set -e cd "$(dirname "$0")/.." -if ! command -v rye >/dev/null 2>&1 && [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { - echo "==> Installing Homebrew dependencies…" - brew bundle + echo -n "==> Install Homebrew dependencies? (y/N): " + read -r response + case "$response" in + [yY][eE][sS]|[yY]) + brew bundle + ;; + *) + ;; + esac + echo } fi diff --git a/src/agentex/__init__.py b/src/agentex/__init__.py index 50fd7ec6..772c2c0f 100644 --- a/src/agentex/__init__.py +++ b/src/agentex/__init__.py @@ -3,7 +3,7 @@ import typing as _t from . import types -from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes +from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given from ._utils import file_from_path from ._client import ( ENVIRONMENTS, @@ -49,7 +49,9 @@ "ProxiesTypes", "NotGiven", "NOT_GIVEN", + "not_given", "Omit", + "omit", "AgentexError", "APIError", "APIStatusError", diff --git a/src/agentex/_base_client.py b/src/agentex/_base_client.py index df53be60..108a8a52 100644 --- a/src/agentex/_base_client.py +++ b/src/agentex/_base_client.py @@ -42,7 +42,6 @@ from ._qs import Querystring from ._files import to_httpx_files, async_to_httpx_files from ._types import ( - NOT_GIVEN, Body, Omit, Query, @@ -57,6 +56,7 @@ RequestOptions, HttpxRequestFiles, ModelBuilderProtocol, + not_given, ) from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping from ._compat import PYDANTIC_V1, model_copy, model_dump @@ -145,9 +145,9 @@ def __init__( def __init__( self, *, - url: URL | NotGiven = NOT_GIVEN, - json: Body | NotGiven = NOT_GIVEN, - params: Query | NotGiven = NOT_GIVEN, + url: URL | NotGiven = not_given, + json: Body | NotGiven = not_given, + params: Query | NotGiven = not_given, ) -> None: self.url = url self.json = json @@ -595,7 +595,7 @@ def _maybe_override_cast_to(self, cast_to: type[ResponseT], options: FinalReques # we internally support defining a temporary header to override the # default `cast_to` type for use with `.with_raw_response` and `.with_streaming_response` # see _response.py for implementation details - override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, NOT_GIVEN) + override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, not_given) if is_given(override_cast_to): options.headers = headers return cast(Type[ResponseT], override_cast_to) @@ -825,7 +825,7 @@ def __init__( version: str, base_url: str | URL, max_retries: int = DEFAULT_MAX_RETRIES, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.Client | None = None, custom_headers: Mapping[str, str] | None = None, custom_query: Mapping[str, object] | None = None, @@ -1356,7 +1356,7 @@ def __init__( base_url: str | URL, _strict_response_validation: bool, max_retries: int = DEFAULT_MAX_RETRIES, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.AsyncClient | None = None, custom_headers: Mapping[str, str] | None = None, custom_query: Mapping[str, object] | None = None, @@ -1818,8 +1818,8 @@ def make_request_options( extra_query: Query | None = None, extra_body: Body | None = None, idempotency_key: str | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - post_parser: PostParser | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + post_parser: PostParser | NotGiven = not_given, ) -> RequestOptions: """Create a dict of type RequestOptions without keys of NotGiven values.""" options: RequestOptions = {} diff --git a/src/agentex/_client.py b/src/agentex/_client.py index 51ebb5e8..a87f6cbf 100644 --- a/src/agentex/_client.py +++ b/src/agentex/_client.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Dict, Union, Mapping, cast +from typing import Any, Dict, Mapping, cast from typing_extensions import Self, Literal, override import httpx @@ -11,13 +11,13 @@ from . import _exceptions from ._qs import Querystring from ._types import ( - NOT_GIVEN, Omit, Timeout, NotGiven, Transport, ProxiesTypes, RequestOptions, + not_given, ) from ._utils import is_given, get_async_library from ._version import __version__ @@ -69,9 +69,9 @@ def __init__( self, *, api_key: str | None = None, - environment: Literal["production", "development"] | NotGiven = NOT_GIVEN, - base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN, - timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, + environment: Literal["production", "development"] | NotGiven = not_given, + base_url: str | httpx.URL | None | NotGiven = not_given, + timeout: float | Timeout | None | NotGiven = not_given, max_retries: int = DEFAULT_MAX_RETRIES, default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -172,9 +172,9 @@ def copy( api_key: str | None = None, environment: Literal["production", "development"] | None = None, base_url: str | httpx.URL | None = None, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.Client | None = None, - max_retries: int | NotGiven = NOT_GIVEN, + max_retries: int | NotGiven = not_given, default_headers: Mapping[str, str] | None = None, set_default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -273,9 +273,9 @@ def __init__( self, *, api_key: str | None = None, - environment: Literal["production", "development"] | NotGiven = NOT_GIVEN, - base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN, - timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, + environment: Literal["production", "development"] | NotGiven = not_given, + base_url: str | httpx.URL | None | NotGiven = not_given, + timeout: float | Timeout | None | NotGiven = not_given, max_retries: int = DEFAULT_MAX_RETRIES, default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -376,9 +376,9 @@ def copy( api_key: str | None = None, environment: Literal["production", "development"] | None = None, base_url: str | httpx.URL | None = None, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.AsyncClient | None = None, - max_retries: int | NotGiven = NOT_GIVEN, + max_retries: int | NotGiven = not_given, default_headers: Mapping[str, str] | None = None, set_default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, diff --git a/src/agentex/_models.py b/src/agentex/_models.py index 3a6017ef..6a3cd1d2 100644 --- a/src/agentex/_models.py +++ b/src/agentex/_models.py @@ -256,7 +256,7 @@ def model_dump( mode: Literal["json", "python"] | str = "python", include: IncEx | None = None, exclude: IncEx | None = None, - by_alias: bool = False, + by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, @@ -264,6 +264,7 @@ def model_dump( warnings: bool | Literal["none", "warn", "error"] = True, context: dict[str, Any] | None = None, serialize_as_any: bool = False, + fallback: Callable[[Any], Any] | None = None, ) -> dict[str, Any]: """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump @@ -295,10 +296,12 @@ def model_dump( raise ValueError("context is only supported in Pydantic v2") if serialize_as_any != False: raise ValueError("serialize_as_any is only supported in Pydantic v2") + if fallback is not None: + raise ValueError("fallback is only supported in Pydantic v2") dumped = super().dict( # pyright: ignore[reportDeprecated] include=include, exclude=exclude, - by_alias=by_alias, + by_alias=by_alias if by_alias is not None else False, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, exclude_none=exclude_none, @@ -313,13 +316,14 @@ def model_dump_json( indent: int | None = None, include: IncEx | None = None, exclude: IncEx | None = None, - by_alias: bool = False, + by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal["none", "warn", "error"] = True, context: dict[str, Any] | None = None, + fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False, ) -> str: """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json @@ -348,11 +352,13 @@ def model_dump_json( raise ValueError("context is only supported in Pydantic v2") if serialize_as_any != False: raise ValueError("serialize_as_any is only supported in Pydantic v2") + if fallback is not None: + raise ValueError("fallback is only supported in Pydantic v2") return super().json( # type: ignore[reportDeprecated] indent=indent, include=include, exclude=exclude, - by_alias=by_alias, + by_alias=by_alias if by_alias is not None else False, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, exclude_none=exclude_none, diff --git a/src/agentex/_qs.py b/src/agentex/_qs.py index 274320ca..ada6fd3f 100644 --- a/src/agentex/_qs.py +++ b/src/agentex/_qs.py @@ -4,7 +4,7 @@ from urllib.parse import parse_qs, urlencode from typing_extensions import Literal, get_args -from ._types import NOT_GIVEN, NotGiven, NotGivenOr +from ._types import NotGiven, not_given from ._utils import flatten _T = TypeVar("_T") @@ -41,8 +41,8 @@ def stringify( self, params: Params, *, - array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN, - nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN, + array_format: ArrayFormat | NotGiven = not_given, + nested_format: NestedFormat | NotGiven = not_given, ) -> str: return urlencode( self.stringify_items( @@ -56,8 +56,8 @@ def stringify_items( self, params: Params, *, - array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN, - nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN, + array_format: ArrayFormat | NotGiven = not_given, + nested_format: NestedFormat | NotGiven = not_given, ) -> list[tuple[str, str]]: opts = Options( qs=self, @@ -143,8 +143,8 @@ def __init__( self, qs: Querystring = _qs, *, - array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN, - nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN, + array_format: ArrayFormat | NotGiven = not_given, + nested_format: NestedFormat | NotGiven = not_given, ) -> None: self.array_format = qs.array_format if isinstance(array_format, NotGiven) else array_format self.nested_format = qs.nested_format if isinstance(nested_format, NotGiven) else nested_format diff --git a/src/agentex/_types.py b/src/agentex/_types.py index 002a10d8..e546d27f 100644 --- a/src/agentex/_types.py +++ b/src/agentex/_types.py @@ -117,18 +117,21 @@ class RequestOptions(TypedDict, total=False): # Sentinel class used until PEP 0661 is accepted class NotGiven: """ - A sentinel singleton class used to distinguish omitted keyword arguments - from those passed in with the value None (which may have different behavior). + For parameters with a meaningful None value, we need to distinguish between + the user explicitly passing None, and the user not passing the parameter at + all. + + User code shouldn't need to use not_given directly. For example: ```py - def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: ... + def create(timeout: Timeout | None | NotGiven = not_given): ... - get(timeout=1) # 1s timeout - get(timeout=None) # No timeout - get() # Default timeout behavior, which may not be statically known at the method definition. + create(timeout=1) # 1s timeout + create(timeout=None) # No timeout + create() # Default timeout behavior ``` """ @@ -140,13 +143,14 @@ def __repr__(self) -> str: return "NOT_GIVEN" -NotGivenOr = Union[_T, NotGiven] +not_given = NotGiven() +# for backwards compatibility: NOT_GIVEN = NotGiven() class Omit: - """In certain situations you need to be able to represent a case where a default value has - to be explicitly removed and `None` is not an appropriate substitute, for example: + """ + To explicitly omit something from being sent in a request, use `omit`. ```py # as the default `Content-Type` header is `application/json` that will be sent @@ -156,8 +160,8 @@ class Omit: # to look something like: 'multipart/form-data; boundary=0d8382fcf5f8c3be01ca2e11002d2983' client.post(..., headers={"Content-Type": "multipart/form-data"}) - # instead you can remove the default `application/json` header by passing Omit - client.post(..., headers={"Content-Type": Omit()}) + # instead you can remove the default `application/json` header by passing omit + client.post(..., headers={"Content-Type": omit}) ``` """ @@ -165,6 +169,9 @@ def __bool__(self) -> Literal[False]: return False +omit = Omit() + + @runtime_checkable class ModelBuilderProtocol(Protocol): @classmethod diff --git a/src/agentex/_utils/_transform.py b/src/agentex/_utils/_transform.py index c19124f0..52075492 100644 --- a/src/agentex/_utils/_transform.py +++ b/src/agentex/_utils/_transform.py @@ -268,7 +268,7 @@ def _transform_typeddict( annotations = get_type_hints(expected_type, include_extras=True) for key, value in data.items(): if not is_given(value): - # we don't need to include `NotGiven` values here as they'll + # we don't need to include omitted values here as they'll # be stripped out before the request is sent anyway continue @@ -434,7 +434,7 @@ async def _async_transform_typeddict( annotations = get_type_hints(expected_type, include_extras=True) for key, value in data.items(): if not is_given(value): - # we don't need to include `NotGiven` values here as they'll + # we don't need to include omitted values here as they'll # be stripped out before the request is sent anyway continue diff --git a/src/agentex/_utils/_utils.py b/src/agentex/_utils/_utils.py index f0818595..50d59269 100644 --- a/src/agentex/_utils/_utils.py +++ b/src/agentex/_utils/_utils.py @@ -21,7 +21,7 @@ import sniffio -from .._types import NotGiven, FileTypes, NotGivenOr, HeadersLike +from .._types import Omit, NotGiven, FileTypes, HeadersLike _T = TypeVar("_T") _TupleT = TypeVar("_TupleT", bound=Tuple[object, ...]) @@ -63,7 +63,7 @@ def _extract_items( try: key = path[index] except IndexError: - if isinstance(obj, NotGiven): + if not is_given(obj): # no value was provided - we can safely ignore return [] @@ -126,8 +126,8 @@ def _extract_items( return [] -def is_given(obj: NotGivenOr[_T]) -> TypeGuard[_T]: - return not isinstance(obj, NotGiven) +def is_given(obj: _T | NotGiven | Omit) -> TypeGuard[_T]: + return not isinstance(obj, NotGiven) and not isinstance(obj, Omit) # Type safe methods for narrowing types with TypeVars. diff --git a/src/agentex/_version.py b/src/agentex/_version.py index 7a7ba507..316c2cf8 100644 --- a/src/agentex/_version.py +++ b/src/agentex/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "agentex" -__version__ = "0.4.23" # x-release-please-version \ No newline at end of file +__version__ = "0.4.24" # x-release-please-version diff --git a/src/agentex/resources/agents.py b/src/agentex/resources/agents.py index ad13186d..f1e2ccc2 100644 --- a/src/agentex/resources/agents.py +++ b/src/agentex/resources/agents.py @@ -10,7 +10,7 @@ from pydantic import ValidationError from ..types import agent_rpc_params, agent_list_params, agent_rpc_by_name_params -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -65,7 +65,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Agent: """ Get an agent by its unique ID. @@ -92,13 +92,13 @@ def retrieve( def list( self, *, - task_id: Optional[str] | NotGiven = NOT_GIVEN, + task_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AgentListResponse: """ List all registered agents, optionally filtered by query parameters. @@ -135,7 +135,7 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DeleteResponse: """ Delete an agent by its unique ID. @@ -168,7 +168,7 @@ def delete_by_name( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DeleteResponse: """ Delete an agent by its unique name. @@ -201,7 +201,7 @@ def retrieve_by_name( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Agent: """ Get an agent by its unique name. @@ -231,14 +231,14 @@ def rpc( *, method: Literal["event/send", "task/create", "message/send", "task/cancel"], params: agent_rpc_params.Params, - id: Union[int, str, None] | NotGiven = NOT_GIVEN, - jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, + id: Union[int, str, None] | Omit = omit, + jsonrpc: Literal["2.0"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AgentRpcResponse: """ Handle JSON-RPC requests for an agent by its unique ID. @@ -279,14 +279,14 @@ def rpc_by_name( *, method: Literal["event/send", "task/create", "message/send", "task/cancel"], params: agent_rpc_by_name_params.Params, - id: Union[int, str, None] | NotGiven = NOT_GIVEN, - jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, + id: Union[int, str, None] | Omit = omit, + jsonrpc: Literal["2.0"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AgentRpcResponse: """ Handle JSON-RPC requests for an agent by its unique name. @@ -612,7 +612,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Agent: """ Get an agent by its unique ID. @@ -639,13 +639,13 @@ async def retrieve( async def list( self, *, - task_id: Optional[str] | NotGiven = NOT_GIVEN, + task_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AgentListResponse: """ List all registered agents, optionally filtered by query parameters. @@ -682,7 +682,7 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DeleteResponse: """ Delete an agent by its unique ID. @@ -715,7 +715,7 @@ async def delete_by_name( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DeleteResponse: """ Delete an agent by its unique name. @@ -748,7 +748,7 @@ async def retrieve_by_name( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Agent: """ Get an agent by its unique name. @@ -778,14 +778,14 @@ async def rpc( *, method: Literal["event/send", "task/create", "message/send", "task/cancel"], params: agent_rpc_params.Params, - id: Union[int, str, None] | NotGiven = NOT_GIVEN, - jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, + id: Union[int, str, None] | Omit = omit, + jsonrpc: Literal["2.0"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AgentRpcResponse: """ Handle JSON-RPC requests for an agent by its unique ID. @@ -826,14 +826,14 @@ async def rpc_by_name( *, method: Literal["event/send", "task/create", "message/send", "task/cancel"], params: agent_rpc_by_name_params.Params, - id: Union[int, str, None] | NotGiven = NOT_GIVEN, - jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, + id: Union[int, str, None] | Omit = omit, + jsonrpc: Literal["2.0"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AgentRpcResponse: """ Handle JSON-RPC requests for an agent by its unique name. diff --git a/src/agentex/resources/events.py b/src/agentex/resources/events.py index 79f6fa1b..f6740590 100644 --- a/src/agentex/resources/events.py +++ b/src/agentex/resources/events.py @@ -7,7 +7,7 @@ import httpx from ..types import event_list_params -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -53,7 +53,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Event: """ Get Event @@ -82,14 +82,14 @@ def list( *, agent_id: str, task_id: str, - last_processed_event_id: Optional[str] | NotGiven = NOT_GIVEN, - limit: Optional[int] | NotGiven = NOT_GIVEN, + last_processed_event_id: Optional[str] | Omit = omit, + limit: Optional[int] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EventListResponse: """ List events for a specific task and agent. @@ -164,7 +164,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Event: """ Get Event @@ -193,14 +193,14 @@ async def list( *, agent_id: str, task_id: str, - last_processed_event_id: Optional[str] | NotGiven = NOT_GIVEN, - limit: Optional[int] | NotGiven = NOT_GIVEN, + last_processed_event_id: Optional[str] | Omit = omit, + limit: Optional[int] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EventListResponse: """ List events for a specific task and agent. diff --git a/src/agentex/resources/messages/batch.py b/src/agentex/resources/messages/batch.py index 58412663..f6c06ced 100644 --- a/src/agentex/resources/messages/batch.py +++ b/src/agentex/resources/messages/batch.py @@ -6,7 +6,7 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._types import Body, Query, Headers, NotGiven, not_given from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource @@ -55,7 +55,7 @@ def create( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BatchCreateResponse: """ Batch Create Messages @@ -94,7 +94,7 @@ def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BatchUpdateResponse: """ Batch Update Messages @@ -154,7 +154,7 @@ async def create( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BatchCreateResponse: """ Batch Create Messages @@ -193,7 +193,7 @@ async def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BatchUpdateResponse: """ Batch Update Messages diff --git a/src/agentex/resources/messages/messages.py b/src/agentex/resources/messages/messages.py index d85f63e1..a3b856d9 100644 --- a/src/agentex/resources/messages/messages.py +++ b/src/agentex/resources/messages/messages.py @@ -16,7 +16,7 @@ AsyncBatchResourceWithStreamingResponse, ) from ...types import message_list_params, message_create_params, message_update_params -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource @@ -63,13 +63,13 @@ def create( *, content: TaskMessageContentParam, task_id: str, - streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, + streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TaskMessage: """ Create Message @@ -108,7 +108,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TaskMessage: """ Get Message @@ -138,13 +138,13 @@ def update( *, content: TaskMessageContentParam, task_id: str, - streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, + streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TaskMessage: """ Update Message @@ -180,13 +180,13 @@ def list( self, *, task_id: str, - limit: Optional[int] | NotGiven = NOT_GIVEN, + limit: Optional[int] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> MessageListResponse: """ List Messages @@ -250,13 +250,13 @@ async def create( *, content: TaskMessageContentParam, task_id: str, - streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, + streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TaskMessage: """ Create Message @@ -295,7 +295,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TaskMessage: """ Get Message @@ -325,13 +325,13 @@ async def update( *, content: TaskMessageContentParam, task_id: str, - streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, + streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TaskMessage: """ Update Message @@ -367,13 +367,13 @@ async def list( self, *, task_id: str, - limit: Optional[int] | NotGiven = NOT_GIVEN, + limit: Optional[int] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> MessageListResponse: """ List Messages diff --git a/src/agentex/resources/spans.py b/src/agentex/resources/spans.py index 00327697..d88ed9e7 100644 --- a/src/agentex/resources/spans.py +++ b/src/agentex/resources/spans.py @@ -8,7 +8,7 @@ import httpx from ..types import span_list_params, span_create_params, span_update_params -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -51,18 +51,18 @@ def create( name: str, start_time: Union[str, datetime], trace_id: str, - id: Optional[str] | NotGiven = NOT_GIVEN, - data: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - end_time: Union[str, datetime, None] | NotGiven = NOT_GIVEN, - input: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - output: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - parent_id: Optional[str] | NotGiven = NOT_GIVEN, + id: Optional[str] | Omit = omit, + data: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + end_time: Union[str, datetime, None] | Omit = omit, + input: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + output: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + parent_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Span: """ Create a new span with the provided parameters @@ -125,7 +125,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Span: """ Get a span by ID @@ -153,20 +153,20 @@ def update( self, span_id: str, *, - data: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - end_time: Union[str, datetime, None] | NotGiven = NOT_GIVEN, - input: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - name: Optional[str] | NotGiven = NOT_GIVEN, - output: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - parent_id: Optional[str] | NotGiven = NOT_GIVEN, - start_time: Union[str, datetime, None] | NotGiven = NOT_GIVEN, - trace_id: Optional[str] | NotGiven = NOT_GIVEN, + data: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + end_time: Union[str, datetime, None] | Omit = omit, + input: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + name: Optional[str] | Omit = omit, + output: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + parent_id: Optional[str] | Omit = omit, + start_time: Union[str, datetime, None] | Omit = omit, + trace_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Span: """ Update a span with the provided output data and mark it as complete @@ -222,13 +222,13 @@ def update( def list( self, *, - trace_id: Optional[str] | NotGiven = NOT_GIVEN, + trace_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SpanListResponse: """ List all spans for a given trace ID @@ -281,18 +281,18 @@ async def create( name: str, start_time: Union[str, datetime], trace_id: str, - id: Optional[str] | NotGiven = NOT_GIVEN, - data: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - end_time: Union[str, datetime, None] | NotGiven = NOT_GIVEN, - input: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - output: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - parent_id: Optional[str] | NotGiven = NOT_GIVEN, + id: Optional[str] | Omit = omit, + data: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + end_time: Union[str, datetime, None] | Omit = omit, + input: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + output: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + parent_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Span: """ Create a new span with the provided parameters @@ -355,7 +355,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Span: """ Get a span by ID @@ -383,20 +383,20 @@ async def update( self, span_id: str, *, - data: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - end_time: Union[str, datetime, None] | NotGiven = NOT_GIVEN, - input: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - name: Optional[str] | NotGiven = NOT_GIVEN, - output: Union[Dict[str, object], Iterable[Dict[str, object]], None] | NotGiven = NOT_GIVEN, - parent_id: Optional[str] | NotGiven = NOT_GIVEN, - start_time: Union[str, datetime, None] | NotGiven = NOT_GIVEN, - trace_id: Optional[str] | NotGiven = NOT_GIVEN, + data: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + end_time: Union[str, datetime, None] | Omit = omit, + input: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + name: Optional[str] | Omit = omit, + output: Union[Dict[str, object], Iterable[Dict[str, object]], None] | Omit = omit, + parent_id: Optional[str] | Omit = omit, + start_time: Union[str, datetime, None] | Omit = omit, + trace_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Span: """ Update a span with the provided output data and mark it as complete @@ -452,13 +452,13 @@ async def update( async def list( self, *, - trace_id: Optional[str] | NotGiven = NOT_GIVEN, + trace_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SpanListResponse: """ List all spans for a given trace ID diff --git a/src/agentex/resources/states.py b/src/agentex/resources/states.py index 6147890a..3100adba 100644 --- a/src/agentex/resources/states.py +++ b/src/agentex/resources/states.py @@ -7,7 +7,7 @@ import httpx from ..types import state_list_params, state_create_params, state_update_params -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -55,7 +55,7 @@ def create( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> State: """ Create Task State @@ -94,7 +94,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> State: """ Get a state by its unique state ID. @@ -130,7 +130,7 @@ def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> State: """ Update Task State @@ -165,14 +165,14 @@ def update( def list( self, *, - agent_id: Optional[str] | NotGiven = NOT_GIVEN, - task_id: Optional[str] | NotGiven = NOT_GIVEN, + agent_id: Optional[str] | Omit = omit, + task_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> StateListResponse: """ List all states, optionally filtered by query parameters. @@ -217,7 +217,7 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> State: """ Delete Task State @@ -273,7 +273,7 @@ async def create( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> State: """ Create Task State @@ -312,7 +312,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> State: """ Get a state by its unique state ID. @@ -348,7 +348,7 @@ async def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> State: """ Update Task State @@ -383,14 +383,14 @@ async def update( async def list( self, *, - agent_id: Optional[str] | NotGiven = NOT_GIVEN, - task_id: Optional[str] | NotGiven = NOT_GIVEN, + agent_id: Optional[str] | Omit = omit, + task_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> StateListResponse: """ List all states, optionally filtered by query parameters. @@ -435,7 +435,7 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> State: """ Delete Task State diff --git a/src/agentex/resources/tasks.py b/src/agentex/resources/tasks.py index 031053b6..0a12e8c3 100644 --- a/src/agentex/resources/tasks.py +++ b/src/agentex/resources/tasks.py @@ -7,7 +7,7 @@ import httpx from ..types import task_list_params -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -55,7 +55,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Task: """ Get a task by its unique ID. @@ -82,14 +82,14 @@ def retrieve( def list( self, *, - agent_id: Optional[str] | NotGiven = NOT_GIVEN, - agent_name: Optional[str] | NotGiven = NOT_GIVEN, + agent_id: Optional[str] | Omit = omit, + agent_name: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TaskListResponse: """ List all tasks. @@ -130,7 +130,7 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DeleteResponse: """ Delete a task by its unique ID. @@ -163,7 +163,7 @@ def delete_by_name( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DeleteResponse: """ Delete a task by its unique name. @@ -196,7 +196,7 @@ def retrieve_by_name( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Task: """ Get a task by its unique name. @@ -229,7 +229,7 @@ def stream_events( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Stream[object]: """ Stream events for a task by its unique ID. @@ -264,7 +264,7 @@ def stream_events_by_name( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Stream[object]: """ Stream events for a task by its unique name. @@ -320,7 +320,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Task: """ Get a task by its unique ID. @@ -347,14 +347,14 @@ async def retrieve( async def list( self, *, - agent_id: Optional[str] | NotGiven = NOT_GIVEN, - agent_name: Optional[str] | NotGiven = NOT_GIVEN, + agent_id: Optional[str] | Omit = omit, + agent_name: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TaskListResponse: """ List all tasks. @@ -395,7 +395,7 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DeleteResponse: """ Delete a task by its unique ID. @@ -428,7 +428,7 @@ async def delete_by_name( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DeleteResponse: """ Delete a task by its unique name. @@ -461,7 +461,7 @@ async def retrieve_by_name( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Task: """ Get a task by its unique name. @@ -494,7 +494,7 @@ async def stream_events( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncStream[object]: """ Stream events for a task by its unique ID. @@ -529,7 +529,7 @@ async def stream_events_by_name( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncStream[object]: """ Stream events for a task by its unique name. diff --git a/src/agentex/resources/tracker.py b/src/agentex/resources/tracker.py index 1a74df21..ddaf573a 100644 --- a/src/agentex/resources/tracker.py +++ b/src/agentex/resources/tracker.py @@ -7,7 +7,7 @@ import httpx from ..types import tracker_list_params, tracker_update_params -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -53,7 +53,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AgentTaskTracker: """ Get agent task tracker by tracker ID @@ -81,15 +81,15 @@ def update( self, tracker_id: str, *, - last_processed_event_id: Optional[str] | NotGiven = NOT_GIVEN, - status: Optional[str] | NotGiven = NOT_GIVEN, - status_reason: Optional[str] | NotGiven = NOT_GIVEN, + last_processed_event_id: Optional[str] | Omit = omit, + status: Optional[str] | Omit = omit, + status_reason: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AgentTaskTracker: """ Update agent task tracker by tracker ID @@ -130,14 +130,14 @@ def update( def list( self, *, - agent_id: Optional[str] | NotGiven = NOT_GIVEN, - task_id: Optional[str] | NotGiven = NOT_GIVEN, + agent_id: Optional[str] | Omit = omit, + task_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrackerListResponse: """ List all agent task trackers, optionally filtered by query parameters. @@ -203,7 +203,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AgentTaskTracker: """ Get agent task tracker by tracker ID @@ -231,15 +231,15 @@ async def update( self, tracker_id: str, *, - last_processed_event_id: Optional[str] | NotGiven = NOT_GIVEN, - status: Optional[str] | NotGiven = NOT_GIVEN, - status_reason: Optional[str] | NotGiven = NOT_GIVEN, + last_processed_event_id: Optional[str] | Omit = omit, + status: Optional[str] | Omit = omit, + status_reason: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AgentTaskTracker: """ Update agent task tracker by tracker ID @@ -280,14 +280,14 @@ async def update( async def list( self, *, - agent_id: Optional[str] | NotGiven = NOT_GIVEN, - task_id: Optional[str] | NotGiven = NOT_GIVEN, + agent_id: Optional[str] | Omit = omit, + task_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrackerListResponse: """ List all agent task trackers, optionally filtered by query parameters. diff --git a/tests/api_resources/messages/test_batch.py b/tests/api_resources/messages/test_batch.py index 01ac574a..da404855 100644 --- a/tests/api_resources/messages/test_batch.py +++ b/tests/api_resources/messages/test_batch.py @@ -26,6 +26,7 @@ def test_method_create(self, client: Agentex) -> None: { "author": "user", "content": "content", + "type": "text", } ], task_id="task_id", @@ -40,6 +41,7 @@ def test_raw_response_create(self, client: Agentex) -> None: { "author": "user", "content": "content", + "type": "text", } ], task_id="task_id", @@ -58,6 +60,7 @@ def test_streaming_response_create(self, client: Agentex) -> None: { "author": "user", "content": "content", + "type": "text", } ], task_id="task_id", @@ -79,6 +82,7 @@ def test_method_update(self, client: Agentex) -> None: "foo": { "author": "user", "content": "content", + "type": "text", } }, ) @@ -93,6 +97,7 @@ def test_raw_response_update(self, client: Agentex) -> None: "foo": { "author": "user", "content": "content", + "type": "text", } }, ) @@ -111,6 +116,7 @@ def test_streaming_response_update(self, client: Agentex) -> None: "foo": { "author": "user", "content": "content", + "type": "text", } }, ) as response: @@ -136,6 +142,7 @@ async def test_method_create(self, async_client: AsyncAgentex) -> None: { "author": "user", "content": "content", + "type": "text", } ], task_id="task_id", @@ -150,6 +157,7 @@ async def test_raw_response_create(self, async_client: AsyncAgentex) -> None: { "author": "user", "content": "content", + "type": "text", } ], task_id="task_id", @@ -168,6 +176,7 @@ async def test_streaming_response_create(self, async_client: AsyncAgentex) -> No { "author": "user", "content": "content", + "type": "text", } ], task_id="task_id", @@ -189,6 +198,7 @@ async def test_method_update(self, async_client: AsyncAgentex) -> None: "foo": { "author": "user", "content": "content", + "type": "text", } }, ) @@ -203,6 +213,7 @@ async def test_raw_response_update(self, async_client: AsyncAgentex) -> None: "foo": { "author": "user", "content": "content", + "type": "text", } }, ) @@ -221,6 +232,7 @@ async def test_streaming_response_update(self, async_client: AsyncAgentex) -> No "foo": { "author": "user", "content": "content", + "type": "text", } }, ) as response: diff --git a/tests/test_transform.py b/tests/test_transform.py index 20ef1c66..beafc1b8 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -8,7 +8,7 @@ import pytest -from agentex._types import NOT_GIVEN, Base64FileInput +from agentex._types import Base64FileInput, omit, not_given from agentex._utils import ( PropertyInfo, transform as _transform, @@ -450,4 +450,11 @@ async def test_transform_skipping(use_async: bool) -> None: @pytest.mark.asyncio async def test_strips_notgiven(use_async: bool) -> None: assert await transform({"foo_bar": "bar"}, Foo1, use_async) == {"fooBar": "bar"} - assert await transform({"foo_bar": NOT_GIVEN}, Foo1, use_async) == {} + assert await transform({"foo_bar": not_given}, Foo1, use_async) == {} + + +@parametrize +@pytest.mark.asyncio +async def test_strips_omit(use_async: bool) -> None: + assert await transform({"foo_bar": "bar"}, Foo1, use_async) == {"fooBar": "bar"} + assert await transform({"foo_bar": omit}, Foo1, use_async) == {}