agentex-sdk 0.1.0__py3-none-any.whl
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.
- agentex/__init__.py +103 -0
- agentex/_base_client.py +1992 -0
- agentex/_client.py +506 -0
- agentex/_compat.py +219 -0
- agentex/_constants.py +14 -0
- agentex/_exceptions.py +108 -0
- agentex/_files.py +123 -0
- agentex/_models.py +829 -0
- agentex/_qs.py +150 -0
- agentex/_resource.py +43 -0
- agentex/_response.py +830 -0
- agentex/_streaming.py +333 -0
- agentex/_types.py +219 -0
- agentex/_utils/__init__.py +57 -0
- agentex/_utils/_logs.py +25 -0
- agentex/_utils/_proxy.py +65 -0
- agentex/_utils/_reflection.py +42 -0
- agentex/_utils/_resources_proxy.py +24 -0
- agentex/_utils/_streams.py +12 -0
- agentex/_utils/_sync.py +86 -0
- agentex/_utils/_transform.py +447 -0
- agentex/_utils/_typing.py +151 -0
- agentex/_utils/_utils.py +422 -0
- agentex/_version.py +4 -0
- agentex/lib/.keep +4 -0
- agentex/lib/__init__.py +0 -0
- agentex/lib/adk/__init__.py +41 -0
- agentex/lib/adk/_modules/__init__.py +0 -0
- agentex/lib/adk/_modules/acp.py +247 -0
- agentex/lib/adk/_modules/agent_task_tracker.py +176 -0
- agentex/lib/adk/_modules/agents.py +77 -0
- agentex/lib/adk/_modules/events.py +141 -0
- agentex/lib/adk/_modules/messages.py +285 -0
- agentex/lib/adk/_modules/state.py +291 -0
- agentex/lib/adk/_modules/streaming.py +75 -0
- agentex/lib/adk/_modules/tasks.py +124 -0
- agentex/lib/adk/_modules/tracing.py +194 -0
- agentex/lib/adk/providers/__init__.py +9 -0
- agentex/lib/adk/providers/_modules/__init__.py +0 -0
- agentex/lib/adk/providers/_modules/litellm.py +232 -0
- agentex/lib/adk/providers/_modules/openai.py +416 -0
- agentex/lib/adk/providers/_modules/sgp.py +85 -0
- agentex/lib/adk/utils/__init__.py +5 -0
- agentex/lib/adk/utils/_modules/__init__.py +0 -0
- agentex/lib/adk/utils/_modules/templating.py +94 -0
- agentex/lib/cli/__init__.py +0 -0
- agentex/lib/cli/commands/__init__.py +0 -0
- agentex/lib/cli/commands/agents.py +328 -0
- agentex/lib/cli/commands/init.py +227 -0
- agentex/lib/cli/commands/main.py +33 -0
- agentex/lib/cli/commands/secrets.py +169 -0
- agentex/lib/cli/commands/tasks.py +118 -0
- agentex/lib/cli/commands/uv.py +133 -0
- agentex/lib/cli/handlers/__init__.py +0 -0
- agentex/lib/cli/handlers/agent_handlers.py +160 -0
- agentex/lib/cli/handlers/cleanup_handlers.py +186 -0
- agentex/lib/cli/handlers/deploy_handlers.py +351 -0
- agentex/lib/cli/handlers/run_handlers.py +452 -0
- agentex/lib/cli/handlers/secret_handlers.py +670 -0
- agentex/lib/cli/templates/default/.dockerignore.j2 +43 -0
- agentex/lib/cli/templates/default/Dockerfile-uv.j2 +42 -0
- agentex/lib/cli/templates/default/Dockerfile.j2 +42 -0
- agentex/lib/cli/templates/default/README.md.j2 +193 -0
- agentex/lib/cli/templates/default/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/default/manifest.yaml.j2 +116 -0
- agentex/lib/cli/templates/default/project/acp.py.j2 +29 -0
- agentex/lib/cli/templates/default/pyproject.toml.j2 +33 -0
- agentex/lib/cli/templates/default/requirements.txt.j2 +5 -0
- agentex/lib/cli/templates/deploy/Screenshot 2025-03-19 at 10.36.57/342/200/257AM.png +0 -0
- agentex/lib/cli/templates/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/sync/.dockerignore.j2 +43 -0
- agentex/lib/cli/templates/sync/Dockerfile-uv.j2 +42 -0
- agentex/lib/cli/templates/sync/Dockerfile.j2 +42 -0
- agentex/lib/cli/templates/sync/README.md.j2 +293 -0
- agentex/lib/cli/templates/sync/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/sync/manifest.yaml.j2 +116 -0
- agentex/lib/cli/templates/sync/project/acp.py.j2 +26 -0
- agentex/lib/cli/templates/sync/pyproject.toml.j2 +33 -0
- agentex/lib/cli/templates/sync/requirements.txt.j2 +5 -0
- agentex/lib/cli/templates/temporal/.dockerignore.j2 +43 -0
- agentex/lib/cli/templates/temporal/Dockerfile-uv.j2 +48 -0
- agentex/lib/cli/templates/temporal/Dockerfile.j2 +48 -0
- agentex/lib/cli/templates/temporal/README.md.j2 +316 -0
- agentex/lib/cli/templates/temporal/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/temporal/manifest.yaml.j2 +137 -0
- agentex/lib/cli/templates/temporal/project/acp.py.j2 +30 -0
- agentex/lib/cli/templates/temporal/project/run_worker.py.j2 +33 -0
- agentex/lib/cli/templates/temporal/project/workflow.py.j2 +66 -0
- agentex/lib/cli/templates/temporal/pyproject.toml.j2 +34 -0
- agentex/lib/cli/templates/temporal/requirements.txt.j2 +5 -0
- agentex/lib/cli/utils/cli_utils.py +14 -0
- agentex/lib/cli/utils/credential_utils.py +103 -0
- agentex/lib/cli/utils/exceptions.py +6 -0
- agentex/lib/cli/utils/kubectl_utils.py +135 -0
- agentex/lib/cli/utils/kubernetes_secrets_utils.py +185 -0
- agentex/lib/core/__init__.py +0 -0
- agentex/lib/core/adapters/__init__.py +0 -0
- agentex/lib/core/adapters/llm/__init__.py +1 -0
- agentex/lib/core/adapters/llm/adapter_litellm.py +46 -0
- agentex/lib/core/adapters/llm/adapter_sgp.py +55 -0
- agentex/lib/core/adapters/llm/port.py +24 -0
- agentex/lib/core/adapters/streams/adapter_redis.py +128 -0
- agentex/lib/core/adapters/streams/port.py +50 -0
- agentex/lib/core/clients/__init__.py +1 -0
- agentex/lib/core/clients/temporal/__init__.py +0 -0
- agentex/lib/core/clients/temporal/temporal_client.py +181 -0
- agentex/lib/core/clients/temporal/types.py +47 -0
- agentex/lib/core/clients/temporal/utils.py +56 -0
- agentex/lib/core/services/__init__.py +0 -0
- agentex/lib/core/services/adk/__init__.py +0 -0
- agentex/lib/core/services/adk/acp/__init__.py +0 -0
- agentex/lib/core/services/adk/acp/acp.py +210 -0
- agentex/lib/core/services/adk/agent_task_tracker.py +85 -0
- agentex/lib/core/services/adk/agents.py +43 -0
- agentex/lib/core/services/adk/events.py +61 -0
- agentex/lib/core/services/adk/messages.py +164 -0
- agentex/lib/core/services/adk/providers/__init__.py +0 -0
- agentex/lib/core/services/adk/providers/litellm.py +256 -0
- agentex/lib/core/services/adk/providers/openai.py +723 -0
- agentex/lib/core/services/adk/providers/sgp.py +99 -0
- agentex/lib/core/services/adk/state.py +120 -0
- agentex/lib/core/services/adk/streaming.py +262 -0
- agentex/lib/core/services/adk/tasks.py +69 -0
- agentex/lib/core/services/adk/tracing.py +36 -0
- agentex/lib/core/services/adk/utils/__init__.py +0 -0
- agentex/lib/core/services/adk/utils/templating.py +58 -0
- agentex/lib/core/temporal/__init__.py +0 -0
- agentex/lib/core/temporal/activities/__init__.py +207 -0
- agentex/lib/core/temporal/activities/activity_helpers.py +37 -0
- agentex/lib/core/temporal/activities/adk/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/acp/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/acp/acp_activities.py +86 -0
- agentex/lib/core/temporal/activities/adk/agent_task_tracker_activities.py +76 -0
- agentex/lib/core/temporal/activities/adk/agents_activities.py +35 -0
- agentex/lib/core/temporal/activities/adk/events_activities.py +50 -0
- agentex/lib/core/temporal/activities/adk/messages_activities.py +94 -0
- agentex/lib/core/temporal/activities/adk/providers/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/providers/litellm_activities.py +71 -0
- agentex/lib/core/temporal/activities/adk/providers/openai_activities.py +210 -0
- agentex/lib/core/temporal/activities/adk/providers/sgp_activities.py +42 -0
- agentex/lib/core/temporal/activities/adk/state_activities.py +85 -0
- agentex/lib/core/temporal/activities/adk/streaming_activities.py +33 -0
- agentex/lib/core/temporal/activities/adk/tasks_activities.py +48 -0
- agentex/lib/core/temporal/activities/adk/tracing_activities.py +55 -0
- agentex/lib/core/temporal/activities/adk/utils/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/utils/templating_activities.py +41 -0
- agentex/lib/core/temporal/services/__init__.py +0 -0
- agentex/lib/core/temporal/services/temporal_task_service.py +69 -0
- agentex/lib/core/temporal/types/__init__.py +0 -0
- agentex/lib/core/temporal/types/workflow.py +5 -0
- agentex/lib/core/temporal/workers/__init__.py +0 -0
- agentex/lib/core/temporal/workers/worker.py +162 -0
- agentex/lib/core/temporal/workflows/workflow.py +26 -0
- agentex/lib/core/tracing/__init__.py +5 -0
- agentex/lib/core/tracing/processors/agentex_tracing_processor.py +117 -0
- agentex/lib/core/tracing/processors/sgp_tracing_processor.py +119 -0
- agentex/lib/core/tracing/processors/tracing_processor_interface.py +40 -0
- agentex/lib/core/tracing/trace.py +311 -0
- agentex/lib/core/tracing/tracer.py +70 -0
- agentex/lib/core/tracing/tracing_processor_manager.py +62 -0
- agentex/lib/environment_variables.py +87 -0
- agentex/lib/py.typed +0 -0
- agentex/lib/sdk/__init__.py +0 -0
- agentex/lib/sdk/config/__init__.py +0 -0
- agentex/lib/sdk/config/agent_config.py +61 -0
- agentex/lib/sdk/config/agent_manifest.py +219 -0
- agentex/lib/sdk/config/build_config.py +35 -0
- agentex/lib/sdk/config/deployment_config.py +117 -0
- agentex/lib/sdk/config/local_development_config.py +56 -0
- agentex/lib/sdk/config/project_config.py +103 -0
- agentex/lib/sdk/fastacp/__init__.py +3 -0
- agentex/lib/sdk/fastacp/base/base_acp_server.py +406 -0
- agentex/lib/sdk/fastacp/fastacp.py +74 -0
- agentex/lib/sdk/fastacp/impl/agentic_base_acp.py +72 -0
- agentex/lib/sdk/fastacp/impl/sync_acp.py +109 -0
- agentex/lib/sdk/fastacp/impl/temporal_acp.py +97 -0
- agentex/lib/sdk/fastacp/tests/README.md +297 -0
- agentex/lib/sdk/fastacp/tests/conftest.py +307 -0
- agentex/lib/sdk/fastacp/tests/pytest.ini +10 -0
- agentex/lib/sdk/fastacp/tests/run_tests.py +227 -0
- agentex/lib/sdk/fastacp/tests/test_base_acp_server.py +450 -0
- agentex/lib/sdk/fastacp/tests/test_fastacp_factory.py +344 -0
- agentex/lib/sdk/fastacp/tests/test_integration.py +477 -0
- agentex/lib/sdk/state_machine/__init__.py +6 -0
- agentex/lib/sdk/state_machine/noop_workflow.py +21 -0
- agentex/lib/sdk/state_machine/state.py +10 -0
- agentex/lib/sdk/state_machine/state_machine.py +189 -0
- agentex/lib/sdk/state_machine/state_workflow.py +16 -0
- agentex/lib/sdk/utils/__init__.py +0 -0
- agentex/lib/sdk/utils/messages.py +223 -0
- agentex/lib/types/__init__.py +0 -0
- agentex/lib/types/acp.py +94 -0
- agentex/lib/types/agent_configs.py +79 -0
- agentex/lib/types/agent_results.py +29 -0
- agentex/lib/types/credentials.py +34 -0
- agentex/lib/types/fastacp.py +61 -0
- agentex/lib/types/files.py +13 -0
- agentex/lib/types/json_rpc.py +49 -0
- agentex/lib/types/llm_messages.py +354 -0
- agentex/lib/types/task_message_updates.py +171 -0
- agentex/lib/types/tracing.py +34 -0
- agentex/lib/utils/__init__.py +0 -0
- agentex/lib/utils/completions.py +131 -0
- agentex/lib/utils/console.py +14 -0
- agentex/lib/utils/io.py +29 -0
- agentex/lib/utils/iterables.py +14 -0
- agentex/lib/utils/json_schema.py +23 -0
- agentex/lib/utils/logging.py +31 -0
- agentex/lib/utils/mcp.py +17 -0
- agentex/lib/utils/model_utils.py +46 -0
- agentex/lib/utils/parsing.py +15 -0
- agentex/lib/utils/regex.py +6 -0
- agentex/lib/utils/temporal.py +13 -0
- agentex/py.typed +0 -0
- agentex/resources/__init__.py +103 -0
- agentex/resources/agents.py +707 -0
- agentex/resources/events.py +294 -0
- agentex/resources/messages/__init__.py +33 -0
- agentex/resources/messages/batch.py +271 -0
- agentex/resources/messages/messages.py +492 -0
- agentex/resources/spans.py +557 -0
- agentex/resources/states.py +544 -0
- agentex/resources/tasks.py +615 -0
- agentex/resources/tracker.py +384 -0
- agentex/types/__init__.py +56 -0
- agentex/types/acp_type.py +7 -0
- agentex/types/agent.py +29 -0
- agentex/types/agent_list_params.py +13 -0
- agentex/types/agent_list_response.py +10 -0
- agentex/types/agent_rpc_by_name_params.py +21 -0
- agentex/types/agent_rpc_params.py +51 -0
- agentex/types/agent_rpc_params1.py +21 -0
- agentex/types/agent_rpc_response.py +20 -0
- agentex/types/agent_rpc_result.py +90 -0
- agentex/types/agent_task_tracker.py +34 -0
- agentex/types/data_content.py +30 -0
- agentex/types/data_content_param.py +31 -0
- agentex/types/data_delta.py +14 -0
- agentex/types/event.py +29 -0
- agentex/types/event_list_params.py +22 -0
- agentex/types/event_list_response.py +10 -0
- agentex/types/message_author.py +7 -0
- agentex/types/message_create_params.py +18 -0
- agentex/types/message_list_params.py +14 -0
- agentex/types/message_list_response.py +10 -0
- agentex/types/message_style.py +7 -0
- agentex/types/message_update_params.py +18 -0
- agentex/types/messages/__init__.py +8 -0
- agentex/types/messages/batch_create_params.py +16 -0
- agentex/types/messages/batch_create_response.py +10 -0
- agentex/types/messages/batch_update_params.py +16 -0
- agentex/types/messages/batch_update_response.py +10 -0
- agentex/types/shared/__init__.py +3 -0
- agentex/types/shared/task_message_update.py +83 -0
- agentex/types/span.py +36 -0
- agentex/types/span_create_params.py +40 -0
- agentex/types/span_list_params.py +12 -0
- agentex/types/span_list_response.py +10 -0
- agentex/types/span_update_params.py +37 -0
- agentex/types/state.py +25 -0
- agentex/types/state_create_params.py +16 -0
- agentex/types/state_list_params.py +16 -0
- agentex/types/state_list_response.py +10 -0
- agentex/types/state_update_params.py +16 -0
- agentex/types/task.py +23 -0
- agentex/types/task_delete_by_name_response.py +8 -0
- agentex/types/task_delete_response.py +8 -0
- agentex/types/task_list_response.py +10 -0
- agentex/types/task_message.py +33 -0
- agentex/types/task_message_content.py +16 -0
- agentex/types/task_message_content_param.py +17 -0
- agentex/types/task_message_delta.py +16 -0
- agentex/types/text_content.py +53 -0
- agentex/types/text_content_param.py +54 -0
- agentex/types/text_delta.py +14 -0
- agentex/types/tool_request_content.py +36 -0
- agentex/types/tool_request_content_param.py +37 -0
- agentex/types/tool_request_delta.py +18 -0
- agentex/types/tool_response_content.py +36 -0
- agentex/types/tool_response_content_param.py +36 -0
- agentex/types/tool_response_delta.py +18 -0
- agentex/types/tracker_list_params.py +16 -0
- agentex/types/tracker_list_response.py +10 -0
- agentex/types/tracker_update_params.py +19 -0
- agentex_sdk-0.1.0.dist-info/METADATA +423 -0
- agentex_sdk-0.1.0.dist-info/RECORD +289 -0
- agentex_sdk-0.1.0.dist-info/WHEEL +4 -0
- agentex_sdk-0.1.0.dist-info/entry_points.txt +2 -0
- agentex_sdk-0.1.0.dist-info/licenses/LICENSE +201 -0
agentex/_client.py
ADDED
@@ -0,0 +1,506 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
import os
|
6
|
+
from typing import Any, Dict, Union, Mapping, cast
|
7
|
+
from typing_extensions import Self, Literal, override
|
8
|
+
|
9
|
+
import httpx
|
10
|
+
|
11
|
+
from . import _exceptions
|
12
|
+
from ._qs import Querystring
|
13
|
+
from ._types import (
|
14
|
+
NOT_GIVEN,
|
15
|
+
Omit,
|
16
|
+
Timeout,
|
17
|
+
NotGiven,
|
18
|
+
Transport,
|
19
|
+
ProxiesTypes,
|
20
|
+
RequestOptions,
|
21
|
+
)
|
22
|
+
from ._utils import is_given, get_async_library
|
23
|
+
from ._version import __version__
|
24
|
+
from .resources import spans, tasks, agents, events, states, tracker
|
25
|
+
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
|
26
|
+
from ._exceptions import APIStatusError
|
27
|
+
from ._base_client import (
|
28
|
+
DEFAULT_MAX_RETRIES,
|
29
|
+
SyncAPIClient,
|
30
|
+
AsyncAPIClient,
|
31
|
+
)
|
32
|
+
from .resources.messages import messages
|
33
|
+
|
34
|
+
__all__ = [
|
35
|
+
"ENVIRONMENTS",
|
36
|
+
"Timeout",
|
37
|
+
"Transport",
|
38
|
+
"ProxiesTypes",
|
39
|
+
"RequestOptions",
|
40
|
+
"Agentex",
|
41
|
+
"AsyncAgentex",
|
42
|
+
"Client",
|
43
|
+
"AsyncClient",
|
44
|
+
]
|
45
|
+
|
46
|
+
ENVIRONMENTS: Dict[str, str] = {
|
47
|
+
"production": "http://localhost:5003",
|
48
|
+
"development": "http://localhost:5003",
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
class Agentex(SyncAPIClient):
|
53
|
+
agents: agents.AgentsResource
|
54
|
+
tasks: tasks.TasksResource
|
55
|
+
messages: messages.MessagesResource
|
56
|
+
spans: spans.SpansResource
|
57
|
+
states: states.StatesResource
|
58
|
+
events: events.EventsResource
|
59
|
+
tracker: tracker.TrackerResource
|
60
|
+
with_raw_response: AgentexWithRawResponse
|
61
|
+
with_streaming_response: AgentexWithStreamedResponse
|
62
|
+
|
63
|
+
# client options
|
64
|
+
api_key: str | None
|
65
|
+
|
66
|
+
_environment: Literal["production", "development"] | NotGiven
|
67
|
+
|
68
|
+
def __init__(
|
69
|
+
self,
|
70
|
+
*,
|
71
|
+
api_key: str | None = None,
|
72
|
+
environment: Literal["production", "development"] | NotGiven = NOT_GIVEN,
|
73
|
+
base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
|
74
|
+
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
|
75
|
+
max_retries: int = DEFAULT_MAX_RETRIES,
|
76
|
+
default_headers: Mapping[str, str] | None = None,
|
77
|
+
default_query: Mapping[str, object] | None = None,
|
78
|
+
# Configure a custom httpx client.
|
79
|
+
# We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
|
80
|
+
# See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
|
81
|
+
http_client: httpx.Client | None = None,
|
82
|
+
# Enable or disable schema validation for data returned by the API.
|
83
|
+
# When enabled an error APIResponseValidationError is raised
|
84
|
+
# if the API responds with invalid data for the expected schema.
|
85
|
+
#
|
86
|
+
# This parameter may be removed or changed in the future.
|
87
|
+
# If you rely on this feature, please open a GitHub issue
|
88
|
+
# outlining your use-case to help us decide if it should be
|
89
|
+
# part of our public interface in the future.
|
90
|
+
_strict_response_validation: bool = False,
|
91
|
+
) -> None:
|
92
|
+
"""Construct a new synchronous Agentex client instance.
|
93
|
+
|
94
|
+
This automatically infers the `api_key` argument from the `AGENTEX_SDK_API_KEY` environment variable if it is not provided.
|
95
|
+
"""
|
96
|
+
if api_key is None:
|
97
|
+
api_key = os.environ.get("AGENTEX_SDK_API_KEY")
|
98
|
+
self.api_key = api_key
|
99
|
+
|
100
|
+
self._environment = environment
|
101
|
+
|
102
|
+
base_url_env = os.environ.get("AGENTEX_BASE_URL")
|
103
|
+
if is_given(base_url) and base_url is not None:
|
104
|
+
# cast required because mypy doesn't understand the type narrowing
|
105
|
+
base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
|
106
|
+
elif is_given(environment):
|
107
|
+
if base_url_env and base_url is not None:
|
108
|
+
raise ValueError(
|
109
|
+
"Ambiguous URL; The `AGENTEX_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
|
110
|
+
)
|
111
|
+
|
112
|
+
try:
|
113
|
+
base_url = ENVIRONMENTS[environment]
|
114
|
+
except KeyError as exc:
|
115
|
+
raise ValueError(f"Unknown environment: {environment}") from exc
|
116
|
+
elif base_url_env is not None:
|
117
|
+
base_url = base_url_env
|
118
|
+
else:
|
119
|
+
self._environment = environment = "production"
|
120
|
+
|
121
|
+
try:
|
122
|
+
base_url = ENVIRONMENTS[environment]
|
123
|
+
except KeyError as exc:
|
124
|
+
raise ValueError(f"Unknown environment: {environment}") from exc
|
125
|
+
|
126
|
+
super().__init__(
|
127
|
+
version=__version__,
|
128
|
+
base_url=base_url,
|
129
|
+
max_retries=max_retries,
|
130
|
+
timeout=timeout,
|
131
|
+
http_client=http_client,
|
132
|
+
custom_headers=default_headers,
|
133
|
+
custom_query=default_query,
|
134
|
+
_strict_response_validation=_strict_response_validation,
|
135
|
+
)
|
136
|
+
|
137
|
+
self.agents = agents.AgentsResource(self)
|
138
|
+
self.tasks = tasks.TasksResource(self)
|
139
|
+
self.messages = messages.MessagesResource(self)
|
140
|
+
self.spans = spans.SpansResource(self)
|
141
|
+
self.states = states.StatesResource(self)
|
142
|
+
self.events = events.EventsResource(self)
|
143
|
+
self.tracker = tracker.TrackerResource(self)
|
144
|
+
self.with_raw_response = AgentexWithRawResponse(self)
|
145
|
+
self.with_streaming_response = AgentexWithStreamedResponse(self)
|
146
|
+
|
147
|
+
@property
|
148
|
+
@override
|
149
|
+
def qs(self) -> Querystring:
|
150
|
+
return Querystring(array_format="comma")
|
151
|
+
|
152
|
+
@property
|
153
|
+
@override
|
154
|
+
def auth_headers(self) -> dict[str, str]:
|
155
|
+
api_key = self.api_key
|
156
|
+
if api_key is None:
|
157
|
+
return {}
|
158
|
+
return {"Authorization": f"Bearer {api_key}"}
|
159
|
+
|
160
|
+
@property
|
161
|
+
@override
|
162
|
+
def default_headers(self) -> dict[str, str | Omit]:
|
163
|
+
return {
|
164
|
+
**super().default_headers,
|
165
|
+
"X-Stainless-Async": "false",
|
166
|
+
**self._custom_headers,
|
167
|
+
}
|
168
|
+
|
169
|
+
def copy(
|
170
|
+
self,
|
171
|
+
*,
|
172
|
+
api_key: str | None = None,
|
173
|
+
environment: Literal["production", "development"] | None = None,
|
174
|
+
base_url: str | httpx.URL | None = None,
|
175
|
+
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
|
176
|
+
http_client: httpx.Client | None = None,
|
177
|
+
max_retries: int | NotGiven = NOT_GIVEN,
|
178
|
+
default_headers: Mapping[str, str] | None = None,
|
179
|
+
set_default_headers: Mapping[str, str] | None = None,
|
180
|
+
default_query: Mapping[str, object] | None = None,
|
181
|
+
set_default_query: Mapping[str, object] | None = None,
|
182
|
+
_extra_kwargs: Mapping[str, Any] = {},
|
183
|
+
) -> Self:
|
184
|
+
"""
|
185
|
+
Create a new client instance re-using the same options given to the current client with optional overriding.
|
186
|
+
"""
|
187
|
+
if default_headers is not None and set_default_headers is not None:
|
188
|
+
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
|
189
|
+
|
190
|
+
if default_query is not None and set_default_query is not None:
|
191
|
+
raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
|
192
|
+
|
193
|
+
headers = self._custom_headers
|
194
|
+
if default_headers is not None:
|
195
|
+
headers = {**headers, **default_headers}
|
196
|
+
elif set_default_headers is not None:
|
197
|
+
headers = set_default_headers
|
198
|
+
|
199
|
+
params = self._custom_query
|
200
|
+
if default_query is not None:
|
201
|
+
params = {**params, **default_query}
|
202
|
+
elif set_default_query is not None:
|
203
|
+
params = set_default_query
|
204
|
+
|
205
|
+
http_client = http_client or self._client
|
206
|
+
return self.__class__(
|
207
|
+
api_key=api_key or self.api_key,
|
208
|
+
base_url=base_url or self.base_url,
|
209
|
+
environment=environment or self._environment,
|
210
|
+
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
211
|
+
http_client=http_client,
|
212
|
+
max_retries=max_retries if is_given(max_retries) else self.max_retries,
|
213
|
+
default_headers=headers,
|
214
|
+
default_query=params,
|
215
|
+
**_extra_kwargs,
|
216
|
+
)
|
217
|
+
|
218
|
+
# Alias for `copy` for nicer inline usage, e.g.
|
219
|
+
# client.with_options(timeout=10).foo.create(...)
|
220
|
+
with_options = copy
|
221
|
+
|
222
|
+
@override
|
223
|
+
def _make_status_error(
|
224
|
+
self,
|
225
|
+
err_msg: str,
|
226
|
+
*,
|
227
|
+
body: object,
|
228
|
+
response: httpx.Response,
|
229
|
+
) -> APIStatusError:
|
230
|
+
if response.status_code == 400:
|
231
|
+
return _exceptions.BadRequestError(err_msg, response=response, body=body)
|
232
|
+
|
233
|
+
if response.status_code == 401:
|
234
|
+
return _exceptions.AuthenticationError(err_msg, response=response, body=body)
|
235
|
+
|
236
|
+
if response.status_code == 403:
|
237
|
+
return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
|
238
|
+
|
239
|
+
if response.status_code == 404:
|
240
|
+
return _exceptions.NotFoundError(err_msg, response=response, body=body)
|
241
|
+
|
242
|
+
if response.status_code == 409:
|
243
|
+
return _exceptions.ConflictError(err_msg, response=response, body=body)
|
244
|
+
|
245
|
+
if response.status_code == 422:
|
246
|
+
return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
|
247
|
+
|
248
|
+
if response.status_code == 429:
|
249
|
+
return _exceptions.RateLimitError(err_msg, response=response, body=body)
|
250
|
+
|
251
|
+
if response.status_code >= 500:
|
252
|
+
return _exceptions.InternalServerError(err_msg, response=response, body=body)
|
253
|
+
return APIStatusError(err_msg, response=response, body=body)
|
254
|
+
|
255
|
+
|
256
|
+
class AsyncAgentex(AsyncAPIClient):
|
257
|
+
agents: agents.AsyncAgentsResource
|
258
|
+
tasks: tasks.AsyncTasksResource
|
259
|
+
messages: messages.AsyncMessagesResource
|
260
|
+
spans: spans.AsyncSpansResource
|
261
|
+
states: states.AsyncStatesResource
|
262
|
+
events: events.AsyncEventsResource
|
263
|
+
tracker: tracker.AsyncTrackerResource
|
264
|
+
with_raw_response: AsyncAgentexWithRawResponse
|
265
|
+
with_streaming_response: AsyncAgentexWithStreamedResponse
|
266
|
+
|
267
|
+
# client options
|
268
|
+
api_key: str | None
|
269
|
+
|
270
|
+
_environment: Literal["production", "development"] | NotGiven
|
271
|
+
|
272
|
+
def __init__(
|
273
|
+
self,
|
274
|
+
*,
|
275
|
+
api_key: str | None = None,
|
276
|
+
environment: Literal["production", "development"] | NotGiven = NOT_GIVEN,
|
277
|
+
base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
|
278
|
+
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
|
279
|
+
max_retries: int = DEFAULT_MAX_RETRIES,
|
280
|
+
default_headers: Mapping[str, str] | None = None,
|
281
|
+
default_query: Mapping[str, object] | None = None,
|
282
|
+
# Configure a custom httpx client.
|
283
|
+
# We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
|
284
|
+
# See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
|
285
|
+
http_client: httpx.AsyncClient | None = None,
|
286
|
+
# Enable or disable schema validation for data returned by the API.
|
287
|
+
# When enabled an error APIResponseValidationError is raised
|
288
|
+
# if the API responds with invalid data for the expected schema.
|
289
|
+
#
|
290
|
+
# This parameter may be removed or changed in the future.
|
291
|
+
# If you rely on this feature, please open a GitHub issue
|
292
|
+
# outlining your use-case to help us decide if it should be
|
293
|
+
# part of our public interface in the future.
|
294
|
+
_strict_response_validation: bool = False,
|
295
|
+
) -> None:
|
296
|
+
"""Construct a new async AsyncAgentex client instance.
|
297
|
+
|
298
|
+
This automatically infers the `api_key` argument from the `AGENTEX_SDK_API_KEY` environment variable if it is not provided.
|
299
|
+
"""
|
300
|
+
if api_key is None:
|
301
|
+
api_key = os.environ.get("AGENTEX_SDK_API_KEY")
|
302
|
+
self.api_key = api_key
|
303
|
+
|
304
|
+
self._environment = environment
|
305
|
+
|
306
|
+
base_url_env = os.environ.get("AGENTEX_BASE_URL")
|
307
|
+
if is_given(base_url) and base_url is not None:
|
308
|
+
# cast required because mypy doesn't understand the type narrowing
|
309
|
+
base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
|
310
|
+
elif is_given(environment):
|
311
|
+
if base_url_env and base_url is not None:
|
312
|
+
raise ValueError(
|
313
|
+
"Ambiguous URL; The `AGENTEX_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
|
314
|
+
)
|
315
|
+
|
316
|
+
try:
|
317
|
+
base_url = ENVIRONMENTS[environment]
|
318
|
+
except KeyError as exc:
|
319
|
+
raise ValueError(f"Unknown environment: {environment}") from exc
|
320
|
+
elif base_url_env is not None:
|
321
|
+
base_url = base_url_env
|
322
|
+
else:
|
323
|
+
self._environment = environment = "production"
|
324
|
+
|
325
|
+
try:
|
326
|
+
base_url = ENVIRONMENTS[environment]
|
327
|
+
except KeyError as exc:
|
328
|
+
raise ValueError(f"Unknown environment: {environment}") from exc
|
329
|
+
|
330
|
+
super().__init__(
|
331
|
+
version=__version__,
|
332
|
+
base_url=base_url,
|
333
|
+
max_retries=max_retries,
|
334
|
+
timeout=timeout,
|
335
|
+
http_client=http_client,
|
336
|
+
custom_headers=default_headers,
|
337
|
+
custom_query=default_query,
|
338
|
+
_strict_response_validation=_strict_response_validation,
|
339
|
+
)
|
340
|
+
|
341
|
+
self.agents = agents.AsyncAgentsResource(self)
|
342
|
+
self.tasks = tasks.AsyncTasksResource(self)
|
343
|
+
self.messages = messages.AsyncMessagesResource(self)
|
344
|
+
self.spans = spans.AsyncSpansResource(self)
|
345
|
+
self.states = states.AsyncStatesResource(self)
|
346
|
+
self.events = events.AsyncEventsResource(self)
|
347
|
+
self.tracker = tracker.AsyncTrackerResource(self)
|
348
|
+
self.with_raw_response = AsyncAgentexWithRawResponse(self)
|
349
|
+
self.with_streaming_response = AsyncAgentexWithStreamedResponse(self)
|
350
|
+
|
351
|
+
@property
|
352
|
+
@override
|
353
|
+
def qs(self) -> Querystring:
|
354
|
+
return Querystring(array_format="comma")
|
355
|
+
|
356
|
+
@property
|
357
|
+
@override
|
358
|
+
def auth_headers(self) -> dict[str, str]:
|
359
|
+
api_key = self.api_key
|
360
|
+
if api_key is None:
|
361
|
+
return {}
|
362
|
+
return {"Authorization": f"Bearer {api_key}"}
|
363
|
+
|
364
|
+
@property
|
365
|
+
@override
|
366
|
+
def default_headers(self) -> dict[str, str | Omit]:
|
367
|
+
return {
|
368
|
+
**super().default_headers,
|
369
|
+
"X-Stainless-Async": f"async:{get_async_library()}",
|
370
|
+
**self._custom_headers,
|
371
|
+
}
|
372
|
+
|
373
|
+
def copy(
|
374
|
+
self,
|
375
|
+
*,
|
376
|
+
api_key: str | None = None,
|
377
|
+
environment: Literal["production", "development"] | None = None,
|
378
|
+
base_url: str | httpx.URL | None = None,
|
379
|
+
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
|
380
|
+
http_client: httpx.AsyncClient | None = None,
|
381
|
+
max_retries: int | NotGiven = NOT_GIVEN,
|
382
|
+
default_headers: Mapping[str, str] | None = None,
|
383
|
+
set_default_headers: Mapping[str, str] | None = None,
|
384
|
+
default_query: Mapping[str, object] | None = None,
|
385
|
+
set_default_query: Mapping[str, object] | None = None,
|
386
|
+
_extra_kwargs: Mapping[str, Any] = {},
|
387
|
+
) -> Self:
|
388
|
+
"""
|
389
|
+
Create a new client instance re-using the same options given to the current client with optional overriding.
|
390
|
+
"""
|
391
|
+
if default_headers is not None and set_default_headers is not None:
|
392
|
+
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
|
393
|
+
|
394
|
+
if default_query is not None and set_default_query is not None:
|
395
|
+
raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
|
396
|
+
|
397
|
+
headers = self._custom_headers
|
398
|
+
if default_headers is not None:
|
399
|
+
headers = {**headers, **default_headers}
|
400
|
+
elif set_default_headers is not None:
|
401
|
+
headers = set_default_headers
|
402
|
+
|
403
|
+
params = self._custom_query
|
404
|
+
if default_query is not None:
|
405
|
+
params = {**params, **default_query}
|
406
|
+
elif set_default_query is not None:
|
407
|
+
params = set_default_query
|
408
|
+
|
409
|
+
http_client = http_client or self._client
|
410
|
+
return self.__class__(
|
411
|
+
api_key=api_key or self.api_key,
|
412
|
+
base_url=base_url or self.base_url,
|
413
|
+
environment=environment or self._environment,
|
414
|
+
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
415
|
+
http_client=http_client,
|
416
|
+
max_retries=max_retries if is_given(max_retries) else self.max_retries,
|
417
|
+
default_headers=headers,
|
418
|
+
default_query=params,
|
419
|
+
**_extra_kwargs,
|
420
|
+
)
|
421
|
+
|
422
|
+
# Alias for `copy` for nicer inline usage, e.g.
|
423
|
+
# client.with_options(timeout=10).foo.create(...)
|
424
|
+
with_options = copy
|
425
|
+
|
426
|
+
@override
|
427
|
+
def _make_status_error(
|
428
|
+
self,
|
429
|
+
err_msg: str,
|
430
|
+
*,
|
431
|
+
body: object,
|
432
|
+
response: httpx.Response,
|
433
|
+
) -> APIStatusError:
|
434
|
+
if response.status_code == 400:
|
435
|
+
return _exceptions.BadRequestError(err_msg, response=response, body=body)
|
436
|
+
|
437
|
+
if response.status_code == 401:
|
438
|
+
return _exceptions.AuthenticationError(err_msg, response=response, body=body)
|
439
|
+
|
440
|
+
if response.status_code == 403:
|
441
|
+
return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
|
442
|
+
|
443
|
+
if response.status_code == 404:
|
444
|
+
return _exceptions.NotFoundError(err_msg, response=response, body=body)
|
445
|
+
|
446
|
+
if response.status_code == 409:
|
447
|
+
return _exceptions.ConflictError(err_msg, response=response, body=body)
|
448
|
+
|
449
|
+
if response.status_code == 422:
|
450
|
+
return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
|
451
|
+
|
452
|
+
if response.status_code == 429:
|
453
|
+
return _exceptions.RateLimitError(err_msg, response=response, body=body)
|
454
|
+
|
455
|
+
if response.status_code >= 500:
|
456
|
+
return _exceptions.InternalServerError(err_msg, response=response, body=body)
|
457
|
+
return APIStatusError(err_msg, response=response, body=body)
|
458
|
+
|
459
|
+
|
460
|
+
class AgentexWithRawResponse:
|
461
|
+
def __init__(self, client: Agentex) -> None:
|
462
|
+
self.agents = agents.AgentsResourceWithRawResponse(client.agents)
|
463
|
+
self.tasks = tasks.TasksResourceWithRawResponse(client.tasks)
|
464
|
+
self.messages = messages.MessagesResourceWithRawResponse(client.messages)
|
465
|
+
self.spans = spans.SpansResourceWithRawResponse(client.spans)
|
466
|
+
self.states = states.StatesResourceWithRawResponse(client.states)
|
467
|
+
self.events = events.EventsResourceWithRawResponse(client.events)
|
468
|
+
self.tracker = tracker.TrackerResourceWithRawResponse(client.tracker)
|
469
|
+
|
470
|
+
|
471
|
+
class AsyncAgentexWithRawResponse:
|
472
|
+
def __init__(self, client: AsyncAgentex) -> None:
|
473
|
+
self.agents = agents.AsyncAgentsResourceWithRawResponse(client.agents)
|
474
|
+
self.tasks = tasks.AsyncTasksResourceWithRawResponse(client.tasks)
|
475
|
+
self.messages = messages.AsyncMessagesResourceWithRawResponse(client.messages)
|
476
|
+
self.spans = spans.AsyncSpansResourceWithRawResponse(client.spans)
|
477
|
+
self.states = states.AsyncStatesResourceWithRawResponse(client.states)
|
478
|
+
self.events = events.AsyncEventsResourceWithRawResponse(client.events)
|
479
|
+
self.tracker = tracker.AsyncTrackerResourceWithRawResponse(client.tracker)
|
480
|
+
|
481
|
+
|
482
|
+
class AgentexWithStreamedResponse:
|
483
|
+
def __init__(self, client: Agentex) -> None:
|
484
|
+
self.agents = agents.AgentsResourceWithStreamingResponse(client.agents)
|
485
|
+
self.tasks = tasks.TasksResourceWithStreamingResponse(client.tasks)
|
486
|
+
self.messages = messages.MessagesResourceWithStreamingResponse(client.messages)
|
487
|
+
self.spans = spans.SpansResourceWithStreamingResponse(client.spans)
|
488
|
+
self.states = states.StatesResourceWithStreamingResponse(client.states)
|
489
|
+
self.events = events.EventsResourceWithStreamingResponse(client.events)
|
490
|
+
self.tracker = tracker.TrackerResourceWithStreamingResponse(client.tracker)
|
491
|
+
|
492
|
+
|
493
|
+
class AsyncAgentexWithStreamedResponse:
|
494
|
+
def __init__(self, client: AsyncAgentex) -> None:
|
495
|
+
self.agents = agents.AsyncAgentsResourceWithStreamingResponse(client.agents)
|
496
|
+
self.tasks = tasks.AsyncTasksResourceWithStreamingResponse(client.tasks)
|
497
|
+
self.messages = messages.AsyncMessagesResourceWithStreamingResponse(client.messages)
|
498
|
+
self.spans = spans.AsyncSpansResourceWithStreamingResponse(client.spans)
|
499
|
+
self.states = states.AsyncStatesResourceWithStreamingResponse(client.states)
|
500
|
+
self.events = events.AsyncEventsResourceWithStreamingResponse(client.events)
|
501
|
+
self.tracker = tracker.AsyncTrackerResourceWithStreamingResponse(client.tracker)
|
502
|
+
|
503
|
+
|
504
|
+
Client = Agentex
|
505
|
+
|
506
|
+
AsyncClient = AsyncAgentex
|