c63a5cfe-b235-4fbe-8bbb-82a9e02a482a-python 0.1.0a3__py3-none-any.whl → 0.1.0a4__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.
- {c63a5cfe_b235_4fbe_8bbb_82a9e02a482a_python-0.1.0a3.dist-info → c63a5cfe_b235_4fbe_8bbb_82a9e02a482a_python-0.1.0a4.dist-info}/METADATA +91 -59
- c63a5cfe_b235_4fbe_8bbb_82a9e02a482a_python-0.1.0a4.dist-info/RECORD +217 -0
- {c63a5cfe_b235_4fbe_8bbb_82a9e02a482a_python-0.1.0a3.dist-info → c63a5cfe_b235_4fbe_8bbb_82a9e02a482a_python-0.1.0a4.dist-info}/licenses/LICENSE +1 -1
- {digitalocean_genai_sdk → gradientai}/__init__.py +10 -9
- {digitalocean_genai_sdk → gradientai}/_base_client.py +39 -3
- {digitalocean_genai_sdk → gradientai}/_client.py +69 -148
- {digitalocean_genai_sdk → gradientai}/_exceptions.py +2 -2
- {digitalocean_genai_sdk → gradientai}/_resource.py +5 -5
- {digitalocean_genai_sdk → gradientai}/_response.py +6 -6
- {digitalocean_genai_sdk → gradientai}/_streaming.py +3 -3
- {digitalocean_genai_sdk → gradientai}/_types.py +1 -1
- {digitalocean_genai_sdk → gradientai}/_utils/_logs.py +3 -3
- gradientai/_utils/_resources_proxy.py +24 -0
- digitalocean_genai_sdk/types/providers/__init__.py → gradientai/_version.py +2 -1
- {digitalocean_genai_sdk → gradientai}/resources/__init__.py +13 -41
- {digitalocean_genai_sdk → gradientai}/resources/agents/agents.py +40 -16
- {digitalocean_genai_sdk → gradientai}/resources/agents/api_keys.py +34 -14
- {digitalocean_genai_sdk → gradientai}/resources/agents/child_agents.py +28 -12
- {digitalocean_genai_sdk → gradientai}/resources/agents/functions.py +22 -10
- {digitalocean_genai_sdk → gradientai}/resources/agents/knowledge_bases.py +22 -10
- {digitalocean_genai_sdk → gradientai}/resources/agents/versions.py +16 -8
- gradientai/resources/chat/__init__.py +33 -0
- gradientai/resources/chat/chat.py +102 -0
- digitalocean_genai_sdk/resources/chat.py → gradientai/resources/chat/completions.py +61 -57
- {digitalocean_genai_sdk → gradientai}/resources/indexing_jobs.py +34 -14
- gradientai/resources/inference/__init__.py +47 -0
- digitalocean_genai_sdk/resources/api_keys/api_keys_.py → gradientai/resources/inference/api_keys.py +40 -20
- gradientai/resources/inference/inference.py +134 -0
- {digitalocean_genai_sdk/resources → gradientai/resources/inference}/models.py +19 -15
- {digitalocean_genai_sdk → gradientai}/resources/knowledge_bases/data_sources.py +25 -12
- {digitalocean_genai_sdk → gradientai}/resources/knowledge_bases/knowledge_bases.py +34 -14
- digitalocean_genai_sdk/resources/api_keys/api_keys.py → gradientai/resources/models.py +51 -72
- {digitalocean_genai_sdk → gradientai}/resources/providers/anthropic/anthropic.py +4 -4
- {digitalocean_genai_sdk → gradientai}/resources/providers/anthropic/keys.py +40 -16
- {digitalocean_genai_sdk → gradientai}/resources/providers/openai/keys.py +40 -16
- {digitalocean_genai_sdk → gradientai}/resources/providers/openai/openai.py +4 -4
- {digitalocean_genai_sdk → gradientai}/resources/providers/providers.py +4 -4
- gradientai/resources/regions/__init__.py +61 -0
- gradientai/resources/regions/evaluation_datasets.py +292 -0
- gradientai/resources/regions/evaluation_runs/__init__.py +33 -0
- gradientai/resources/regions/evaluation_runs/evaluation_runs.py +316 -0
- gradientai/resources/regions/evaluation_runs/results.py +264 -0
- gradientai/resources/regions/evaluation_test_cases.py +618 -0
- gradientai/resources/regions/regions.py +352 -0
- {digitalocean_genai_sdk → gradientai}/types/__init__.py +7 -11
- {digitalocean_genai_sdk → gradientai}/types/agent_list_response.py +3 -3
- {digitalocean_genai_sdk → gradientai}/types/api_agent.py +8 -3
- digitalocean_genai_sdk/types/api_model.py → gradientai/types/api_agent_model.py +2 -2
- gradientai/types/api_evaluation_metric.py +24 -0
- digitalocean_genai_sdk/types/api_key_list_response.py → gradientai/types/api_model.py +3 -13
- {digitalocean_genai_sdk → gradientai}/types/api_openai_api_key_info.py +2 -2
- gradientai/types/api_workspace.py +36 -0
- gradientai/types/chat/__init__.py +7 -0
- {digitalocean_genai_sdk/types → gradientai/types/chat}/chat_completion_token_logprob.py +1 -1
- digitalocean_genai_sdk/types/chat_create_completion_params.py → gradientai/types/chat/completion_create_params.py +6 -29
- digitalocean_genai_sdk/types/chat_create_completion_response.py → gradientai/types/chat/completion_create_response.py +3 -3
- {digitalocean_genai_sdk/types/api_keys → gradientai/types/inference}/__init__.py +2 -0
- {digitalocean_genai_sdk/types → gradientai/types/inference}/model.py +1 -1
- {digitalocean_genai_sdk/types → gradientai/types/inference}/model_list_response.py +1 -1
- {digitalocean_genai_sdk → gradientai}/types/knowledge_base_create_params.py +3 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/__init__.py +1 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/api_knowledge_base_data_source.py +11 -1
- gradientai/types/knowledge_bases/aws_data_source_param.py +19 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/data_source_create_params.py +3 -14
- digitalocean_genai_sdk/types/api_key_list_params.py → gradientai/types/model_list_params.py +2 -2
- gradientai/types/model_list_response.py +18 -0
- gradientai/types/region_list_evaluation_metrics_response.py +12 -0
- gradientai/types/regions/__init__.py +32 -0
- gradientai/types/regions/api_evaluation_test_case.py +46 -0
- gradientai/types/regions/api_star_metric.py +19 -0
- gradientai/types/regions/api_star_metric_param.py +19 -0
- gradientai/types/regions/evaluation_dataset_create_file_upload_presigned_urls_params.py +20 -0
- gradientai/types/regions/evaluation_dataset_create_file_upload_presigned_urls_response.py +30 -0
- gradientai/types/regions/evaluation_dataset_create_params.py +17 -0
- gradientai/types/regions/evaluation_dataset_create_response.py +12 -0
- gradientai/types/regions/evaluation_run_create_params.py +17 -0
- gradientai/types/regions/evaluation_run_create_response.py +11 -0
- gradientai/types/regions/evaluation_run_retrieve_response.py +12 -0
- gradientai/types/regions/evaluation_runs/__init__.py +9 -0
- gradientai/types/regions/evaluation_runs/api_evaluation_metric_result.py +17 -0
- gradientai/types/regions/evaluation_runs/api_evaluation_run.py +56 -0
- gradientai/types/regions/evaluation_runs/api_prompt.py +42 -0
- gradientai/types/regions/evaluation_runs/result_retrieve_prompt_response.py +12 -0
- gradientai/types/regions/evaluation_runs/result_retrieve_response.py +16 -0
- gradientai/types/regions/evaluation_test_case_create_params.py +29 -0
- gradientai/types/regions/evaluation_test_case_create_response.py +12 -0
- gradientai/types/regions/evaluation_test_case_list_evaluation_runs_params.py +12 -0
- gradientai/types/regions/evaluation_test_case_list_evaluation_runs_response.py +13 -0
- gradientai/types/regions/evaluation_test_case_list_response.py +12 -0
- gradientai/types/regions/evaluation_test_case_retrieve_response.py +12 -0
- gradientai/types/regions/evaluation_test_case_update_params.py +32 -0
- gradientai/types/regions/evaluation_test_case_update_response.py +14 -0
- c63a5cfe_b235_4fbe_8bbb_82a9e02a482a_python-0.1.0a3.dist-info/RECORD +0 -190
- digitalocean_genai_sdk/_utils/_resources_proxy.py +0 -24
- digitalocean_genai_sdk/_version.py +0 -4
- digitalocean_genai_sdk/resources/api_keys/__init__.py +0 -19
- digitalocean_genai_sdk/resources/auth/__init__.py +0 -33
- digitalocean_genai_sdk/resources/auth/agents/__init__.py +0 -33
- digitalocean_genai_sdk/resources/auth/agents/agents.py +0 -102
- digitalocean_genai_sdk/resources/auth/agents/token.py +0 -173
- digitalocean_genai_sdk/resources/auth/auth.py +0 -102
- digitalocean_genai_sdk/resources/embeddings.py +0 -201
- digitalocean_genai_sdk/resources/regions.py +0 -191
- digitalocean_genai_sdk/types/auth/agents/__init__.py +0 -6
- digitalocean_genai_sdk/types/auth/agents/token_create_params.py +0 -13
- digitalocean_genai_sdk/types/auth/agents/token_create_response.py +0 -13
- digitalocean_genai_sdk/types/chat_completion_request_message_content_part_text_param.py +0 -15
- digitalocean_genai_sdk/types/embedding_create_params.py +0 -28
- digitalocean_genai_sdk/types/embedding_create_response.py +0 -41
- {c63a5cfe_b235_4fbe_8bbb_82a9e02a482a_python-0.1.0a3.dist-info → c63a5cfe_b235_4fbe_8bbb_82a9e02a482a_python-0.1.0a4.dist-info}/WHEEL +0 -0
- {digitalocean_genai_sdk → gradientai}/_compat.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_constants.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_files.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_models.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_qs.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_utils/__init__.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_utils/_proxy.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_utils/_reflection.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_utils/_streams.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_utils/_sync.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_utils/_transform.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_utils/_typing.py +0 -0
- {digitalocean_genai_sdk → gradientai}/_utils/_utils.py +0 -0
- {digitalocean_genai_sdk → gradientai}/lib/.keep +0 -0
- {digitalocean_genai_sdk → gradientai}/py.typed +0 -0
- {digitalocean_genai_sdk → gradientai}/resources/agents/__init__.py +0 -0
- {digitalocean_genai_sdk → gradientai}/resources/knowledge_bases/__init__.py +0 -0
- {digitalocean_genai_sdk → gradientai}/resources/providers/__init__.py +0 -0
- {digitalocean_genai_sdk → gradientai}/resources/providers/anthropic/__init__.py +0 -0
- {digitalocean_genai_sdk → gradientai}/resources/providers/openai/__init__.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agent_create_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agent_create_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agent_delete_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agent_list_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agent_retrieve_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agent_update_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agent_update_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agent_update_status_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agent_update_status_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/__init__.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/api_key_create_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/api_key_create_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/api_key_delete_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/api_key_list_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/api_key_list_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/api_key_regenerate_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/api_key_update_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/api_key_update_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/api_link_knowledge_base_output.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/api_links.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/api_meta.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/child_agent_add_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/child_agent_add_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/child_agent_delete_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/child_agent_update_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/child_agent_update_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/child_agent_view_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/function_create_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/function_create_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/function_delete_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/function_update_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/function_update_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/knowledge_base_detach_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/version_list_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/version_list_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/version_update_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/agents/version_update_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/api_agent_api_key_info.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/api_agreement.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/api_anthropic_api_key_info.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/api_deployment_visibility.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/api_indexing_job.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/api_knowledge_base.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/api_model_version.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/api_retrieval_method.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/indexing_job_create_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/indexing_job_create_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/indexing_job_list_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/indexing_job_list_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/indexing_job_retrieve_data_sources_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/indexing_job_retrieve_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/indexing_job_update_cancel_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/indexing_job_update_cancel_response.py +0 -0
- {digitalocean_genai_sdk/types/api_keys → gradientai/types/inference}/api_key_create_params.py +0 -0
- {digitalocean_genai_sdk/types/api_keys → gradientai/types/inference}/api_key_create_response.py +0 -0
- {digitalocean_genai_sdk/types/api_keys → gradientai/types/inference}/api_key_delete_response.py +0 -0
- {digitalocean_genai_sdk/types/api_keys → gradientai/types/inference}/api_key_list_params.py +0 -0
- {digitalocean_genai_sdk/types/api_keys → gradientai/types/inference}/api_key_list_response.py +0 -0
- {digitalocean_genai_sdk/types/api_keys → gradientai/types/inference}/api_key_update_params.py +0 -0
- {digitalocean_genai_sdk/types/api_keys → gradientai/types/inference}/api_key_update_regenerate_response.py +0 -0
- {digitalocean_genai_sdk/types/api_keys → gradientai/types/inference}/api_key_update_response.py +0 -0
- {digitalocean_genai_sdk/types/api_keys → gradientai/types/inference}/api_model_api_key_info.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_base_create_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_base_delete_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_base_list_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_base_list_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_base_retrieve_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_base_update_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_base_update_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/api_file_upload_data_source.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/api_file_upload_data_source_param.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/api_spaces_data_source.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/api_spaces_data_source_param.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/api_web_crawler_data_source.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/api_web_crawler_data_source_param.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/data_source_create_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/data_source_delete_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/data_source_list_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/knowledge_bases/data_source_list_response.py +0 -0
- {digitalocean_genai_sdk/types/auth → gradientai/types/providers}/__init__.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/anthropic/__init__.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/anthropic/key_create_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/anthropic/key_create_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/anthropic/key_delete_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/anthropic/key_list_agents_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/anthropic/key_list_agents_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/anthropic/key_list_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/anthropic/key_list_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/anthropic/key_retrieve_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/anthropic/key_update_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/anthropic/key_update_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/openai/__init__.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/openai/key_create_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/openai/key_create_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/openai/key_delete_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/openai/key_list_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/openai/key_list_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/openai/key_retrieve_agents_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/openai/key_retrieve_agents_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/openai/key_retrieve_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/openai/key_update_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/providers/openai/key_update_response.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/region_list_params.py +0 -0
- {digitalocean_genai_sdk → gradientai}/types/region_list_response.py +0 -0
@@ -389,7 +389,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
389
389
|
|
390
390
|
if max_retries is None: # pyright: ignore[reportUnnecessaryComparison]
|
391
391
|
raise TypeError(
|
392
|
-
"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `
|
392
|
+
"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `gradientai.DEFAULT_MAX_RETRIES`"
|
393
393
|
)
|
394
394
|
|
395
395
|
def _enforce_trailing_slash(self, url: URL) -> URL:
|
@@ -1071,7 +1071,14 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
|
|
1071
1071
|
) -> ResponseT:
|
1072
1072
|
origin = get_origin(cast_to) or cast_to
|
1073
1073
|
|
1074
|
-
if
|
1074
|
+
if (
|
1075
|
+
inspect.isclass(origin)
|
1076
|
+
and issubclass(origin, BaseAPIResponse)
|
1077
|
+
# we only want to actually return the custom BaseAPIResponse class if we're
|
1078
|
+
# returning the raw response, or if we're not streaming SSE, as if we're streaming
|
1079
|
+
# SSE then `cast_to` doesn't actively reflect the type we need to parse into
|
1080
|
+
and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
|
1081
|
+
):
|
1075
1082
|
if not issubclass(origin, APIResponse):
|
1076
1083
|
raise TypeError(f"API Response types must subclass {APIResponse}; Received {origin}")
|
1077
1084
|
|
@@ -1282,6 +1289,24 @@ class _DefaultAsyncHttpxClient(httpx.AsyncClient):
|
|
1282
1289
|
super().__init__(**kwargs)
|
1283
1290
|
|
1284
1291
|
|
1292
|
+
try:
|
1293
|
+
import httpx_aiohttp
|
1294
|
+
except ImportError:
|
1295
|
+
|
1296
|
+
class _DefaultAioHttpClient(httpx.AsyncClient):
|
1297
|
+
def __init__(self, **_kwargs: Any) -> None:
|
1298
|
+
raise RuntimeError("To use the aiohttp client you must have installed the package with the `aiohttp` extra")
|
1299
|
+
else:
|
1300
|
+
|
1301
|
+
class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
|
1302
|
+
def __init__(self, **kwargs: Any) -> None:
|
1303
|
+
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
|
1304
|
+
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
|
1305
|
+
kwargs.setdefault("follow_redirects", True)
|
1306
|
+
|
1307
|
+
super().__init__(**kwargs)
|
1308
|
+
|
1309
|
+
|
1285
1310
|
if TYPE_CHECKING:
|
1286
1311
|
DefaultAsyncHttpxClient = httpx.AsyncClient
|
1287
1312
|
"""An alias to `httpx.AsyncClient` that provides the same defaults that this SDK
|
@@ -1290,8 +1315,12 @@ if TYPE_CHECKING:
|
|
1290
1315
|
This is useful because overriding the `http_client` with your own instance of
|
1291
1316
|
`httpx.AsyncClient` will result in httpx's defaults being used, not ours.
|
1292
1317
|
"""
|
1318
|
+
|
1319
|
+
DefaultAioHttpClient = httpx.AsyncClient
|
1320
|
+
"""An alias to `httpx.AsyncClient` that changes the default HTTP transport to `aiohttp`."""
|
1293
1321
|
else:
|
1294
1322
|
DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient
|
1323
|
+
DefaultAioHttpClient = _DefaultAioHttpClient
|
1295
1324
|
|
1296
1325
|
|
1297
1326
|
class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
|
@@ -1574,7 +1603,14 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
|
|
1574
1603
|
) -> ResponseT:
|
1575
1604
|
origin = get_origin(cast_to) or cast_to
|
1576
1605
|
|
1577
|
-
if
|
1606
|
+
if (
|
1607
|
+
inspect.isclass(origin)
|
1608
|
+
and issubclass(origin, BaseAPIResponse)
|
1609
|
+
# we only want to actually return the custom BaseAPIResponse class if we're
|
1610
|
+
# returning the raw response, or if we're not streaming SSE, as if we're streaming
|
1611
|
+
# SSE then `cast_to` doesn't actively reflect the type we need to parse into
|
1612
|
+
and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
|
1613
|
+
):
|
1578
1614
|
if not issubclass(origin, AsyncAPIResponse):
|
1579
1615
|
raise TypeError(f"API Response types must subclass {AsyncAPIResponse}; Received {origin}")
|
1580
1616
|
|
@@ -23,7 +23,7 @@ from ._utils import is_given, get_async_library
|
|
23
23
|
from ._compat import cached_property
|
24
24
|
from ._version import __version__
|
25
25
|
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
|
26
|
-
from ._exceptions import APIStatusError,
|
26
|
+
from ._exceptions import APIStatusError, GradientAIError
|
27
27
|
from ._base_client import (
|
28
28
|
DEFAULT_MAX_RETRIES,
|
29
29
|
SyncAPIClient,
|
@@ -31,26 +31,13 @@ from ._base_client import (
|
|
31
31
|
)
|
32
32
|
|
33
33
|
if TYPE_CHECKING:
|
34
|
-
from .resources import
|
35
|
-
auth,
|
36
|
-
chat,
|
37
|
-
agents,
|
38
|
-
models,
|
39
|
-
regions,
|
40
|
-
api_keys,
|
41
|
-
providers,
|
42
|
-
embeddings,
|
43
|
-
indexing_jobs,
|
44
|
-
knowledge_bases,
|
45
|
-
)
|
46
|
-
from .resources.chat import ChatResource, AsyncChatResource
|
34
|
+
from .resources import chat, agents, models, regions, inference, providers, indexing_jobs, knowledge_bases
|
47
35
|
from .resources.models import ModelsResource, AsyncModelsResource
|
48
|
-
from .resources.
|
49
|
-
from .resources.auth.auth import AuthResource, AsyncAuthResource
|
50
|
-
from .resources.embeddings import EmbeddingsResource, AsyncEmbeddingsResource
|
36
|
+
from .resources.chat.chat import ChatResource, AsyncChatResource
|
51
37
|
from .resources.agents.agents import AgentsResource, AsyncAgentsResource
|
52
38
|
from .resources.indexing_jobs import IndexingJobsResource, AsyncIndexingJobsResource
|
53
|
-
from .resources.
|
39
|
+
from .resources.regions.regions import RegionsResource, AsyncRegionsResource
|
40
|
+
from .resources.inference.inference import InferenceResource, AsyncInferenceResource
|
54
41
|
from .resources.providers.providers import ProvidersResource, AsyncProvidersResource
|
55
42
|
from .resources.knowledge_bases.knowledge_bases import KnowledgeBasesResource, AsyncKnowledgeBasesResource
|
56
43
|
|
@@ -59,14 +46,14 @@ __all__ = [
|
|
59
46
|
"Transport",
|
60
47
|
"ProxiesTypes",
|
61
48
|
"RequestOptions",
|
62
|
-
"
|
63
|
-
"
|
49
|
+
"GradientAI",
|
50
|
+
"AsyncGradientAI",
|
64
51
|
"Client",
|
65
52
|
"AsyncClient",
|
66
53
|
]
|
67
54
|
|
68
55
|
|
69
|
-
class
|
56
|
+
class GradientAI(SyncAPIClient):
|
70
57
|
# client options
|
71
58
|
api_key: str
|
72
59
|
|
@@ -93,20 +80,21 @@ class DigitaloceanGenaiSDK(SyncAPIClient):
|
|
93
80
|
# part of our public interface in the future.
|
94
81
|
_strict_response_validation: bool = False,
|
95
82
|
) -> None:
|
96
|
-
"""Construct a new synchronous
|
83
|
+
"""Construct a new synchronous GradientAI client instance.
|
97
84
|
|
98
|
-
This automatically infers the `api_key` argument from the `
|
85
|
+
This automatically infers the `api_key` argument from the `GRADIENTAI_API_KEY` environment variable if it is not provided.
|
99
86
|
"""
|
100
87
|
if api_key is None:
|
101
|
-
api_key = os.environ.get("
|
88
|
+
api_key = os.environ.get("GRADIENTAI_API_KEY")
|
102
89
|
if api_key is None:
|
103
|
-
raise
|
104
|
-
"The api_key client option must be set either by passing api_key to the client or by setting the
|
90
|
+
raise GradientAIError(
|
91
|
+
"The api_key client option must be set either by passing api_key to the client or by setting the GRADIENTAI_API_KEY environment variable"
|
105
92
|
)
|
106
93
|
self.api_key = api_key
|
107
94
|
|
108
95
|
if base_url is None:
|
109
|
-
base_url = os.environ.get("
|
96
|
+
base_url = os.environ.get("GRADIENT_AI_BASE_URL")
|
97
|
+
self._base_url_overridden = base_url is not None
|
110
98
|
if base_url is None:
|
111
99
|
base_url = f"https://api.digitalocean.com/"
|
112
100
|
|
@@ -133,12 +121,6 @@ class DigitaloceanGenaiSDK(SyncAPIClient):
|
|
133
121
|
|
134
122
|
return ProvidersResource(self)
|
135
123
|
|
136
|
-
@cached_property
|
137
|
-
def auth(self) -> AuthResource:
|
138
|
-
from .resources.auth import AuthResource
|
139
|
-
|
140
|
-
return AuthResource(self)
|
141
|
-
|
142
124
|
@cached_property
|
143
125
|
def regions(self) -> RegionsResource:
|
144
126
|
from .resources.regions import RegionsResource
|
@@ -157,12 +139,6 @@ class DigitaloceanGenaiSDK(SyncAPIClient):
|
|
157
139
|
|
158
140
|
return KnowledgeBasesResource(self)
|
159
141
|
|
160
|
-
@cached_property
|
161
|
-
def api_keys(self) -> APIKeysResource:
|
162
|
-
from .resources.api_keys import APIKeysResource
|
163
|
-
|
164
|
-
return APIKeysResource(self)
|
165
|
-
|
166
142
|
@cached_property
|
167
143
|
def chat(self) -> ChatResource:
|
168
144
|
from .resources.chat import ChatResource
|
@@ -170,10 +146,10 @@ class DigitaloceanGenaiSDK(SyncAPIClient):
|
|
170
146
|
return ChatResource(self)
|
171
147
|
|
172
148
|
@cached_property
|
173
|
-
def
|
174
|
-
from .resources.
|
149
|
+
def inference(self) -> InferenceResource:
|
150
|
+
from .resources.inference import InferenceResource
|
175
151
|
|
176
|
-
return
|
152
|
+
return InferenceResource(self)
|
177
153
|
|
178
154
|
@cached_property
|
179
155
|
def models(self) -> ModelsResource:
|
@@ -182,12 +158,12 @@ class DigitaloceanGenaiSDK(SyncAPIClient):
|
|
182
158
|
return ModelsResource(self)
|
183
159
|
|
184
160
|
@cached_property
|
185
|
-
def with_raw_response(self) ->
|
186
|
-
return
|
161
|
+
def with_raw_response(self) -> GradientAIWithRawResponse:
|
162
|
+
return GradientAIWithRawResponse(self)
|
187
163
|
|
188
164
|
@cached_property
|
189
|
-
def with_streaming_response(self) ->
|
190
|
-
return
|
165
|
+
def with_streaming_response(self) -> GradientAIWithStreamedResponse:
|
166
|
+
return GradientAIWithStreamedResponse(self)
|
191
167
|
|
192
168
|
@property
|
193
169
|
@override
|
@@ -245,7 +221,7 @@ class DigitaloceanGenaiSDK(SyncAPIClient):
|
|
245
221
|
params = set_default_query
|
246
222
|
|
247
223
|
http_client = http_client or self._client
|
248
|
-
|
224
|
+
client = self.__class__(
|
249
225
|
api_key=api_key or self.api_key,
|
250
226
|
base_url=base_url or self.base_url,
|
251
227
|
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
@@ -255,6 +231,8 @@ class DigitaloceanGenaiSDK(SyncAPIClient):
|
|
255
231
|
default_query=params,
|
256
232
|
**_extra_kwargs,
|
257
233
|
)
|
234
|
+
client._base_url_overridden = self._base_url_overridden or base_url is not None
|
235
|
+
return client
|
258
236
|
|
259
237
|
# Alias for `copy` for nicer inline usage, e.g.
|
260
238
|
# client.with_options(timeout=10).foo.create(...)
|
@@ -294,7 +272,7 @@ class DigitaloceanGenaiSDK(SyncAPIClient):
|
|
294
272
|
return APIStatusError(err_msg, response=response, body=body)
|
295
273
|
|
296
274
|
|
297
|
-
class
|
275
|
+
class AsyncGradientAI(AsyncAPIClient):
|
298
276
|
# client options
|
299
277
|
api_key: str
|
300
278
|
|
@@ -321,20 +299,21 @@ class AsyncDigitaloceanGenaiSDK(AsyncAPIClient):
|
|
321
299
|
# part of our public interface in the future.
|
322
300
|
_strict_response_validation: bool = False,
|
323
301
|
) -> None:
|
324
|
-
"""Construct a new async
|
302
|
+
"""Construct a new async AsyncGradientAI client instance.
|
325
303
|
|
326
|
-
This automatically infers the `api_key` argument from the `
|
304
|
+
This automatically infers the `api_key` argument from the `GRADIENTAI_API_KEY` environment variable if it is not provided.
|
327
305
|
"""
|
328
306
|
if api_key is None:
|
329
|
-
api_key = os.environ.get("
|
307
|
+
api_key = os.environ.get("GRADIENTAI_API_KEY")
|
330
308
|
if api_key is None:
|
331
|
-
raise
|
332
|
-
"The api_key client option must be set either by passing api_key to the client or by setting the
|
309
|
+
raise GradientAIError(
|
310
|
+
"The api_key client option must be set either by passing api_key to the client or by setting the GRADIENTAI_API_KEY environment variable"
|
333
311
|
)
|
334
312
|
self.api_key = api_key
|
335
313
|
|
336
314
|
if base_url is None:
|
337
|
-
base_url = os.environ.get("
|
315
|
+
base_url = os.environ.get("GRADIENT_AI_BASE_URL")
|
316
|
+
self._base_url_overridden = base_url is not None
|
338
317
|
if base_url is None:
|
339
318
|
base_url = f"https://api.digitalocean.com/"
|
340
319
|
|
@@ -361,12 +340,6 @@ class AsyncDigitaloceanGenaiSDK(AsyncAPIClient):
|
|
361
340
|
|
362
341
|
return AsyncProvidersResource(self)
|
363
342
|
|
364
|
-
@cached_property
|
365
|
-
def auth(self) -> AsyncAuthResource:
|
366
|
-
from .resources.auth import AsyncAuthResource
|
367
|
-
|
368
|
-
return AsyncAuthResource(self)
|
369
|
-
|
370
343
|
@cached_property
|
371
344
|
def regions(self) -> AsyncRegionsResource:
|
372
345
|
from .resources.regions import AsyncRegionsResource
|
@@ -385,12 +358,6 @@ class AsyncDigitaloceanGenaiSDK(AsyncAPIClient):
|
|
385
358
|
|
386
359
|
return AsyncKnowledgeBasesResource(self)
|
387
360
|
|
388
|
-
@cached_property
|
389
|
-
def api_keys(self) -> AsyncAPIKeysResource:
|
390
|
-
from .resources.api_keys import AsyncAPIKeysResource
|
391
|
-
|
392
|
-
return AsyncAPIKeysResource(self)
|
393
|
-
|
394
361
|
@cached_property
|
395
362
|
def chat(self) -> AsyncChatResource:
|
396
363
|
from .resources.chat import AsyncChatResource
|
@@ -398,10 +365,10 @@ class AsyncDigitaloceanGenaiSDK(AsyncAPIClient):
|
|
398
365
|
return AsyncChatResource(self)
|
399
366
|
|
400
367
|
@cached_property
|
401
|
-
def
|
402
|
-
from .resources.
|
368
|
+
def inference(self) -> AsyncInferenceResource:
|
369
|
+
from .resources.inference import AsyncInferenceResource
|
403
370
|
|
404
|
-
return
|
371
|
+
return AsyncInferenceResource(self)
|
405
372
|
|
406
373
|
@cached_property
|
407
374
|
def models(self) -> AsyncModelsResource:
|
@@ -410,12 +377,12 @@ class AsyncDigitaloceanGenaiSDK(AsyncAPIClient):
|
|
410
377
|
return AsyncModelsResource(self)
|
411
378
|
|
412
379
|
@cached_property
|
413
|
-
def with_raw_response(self) ->
|
414
|
-
return
|
380
|
+
def with_raw_response(self) -> AsyncGradientAIWithRawResponse:
|
381
|
+
return AsyncGradientAIWithRawResponse(self)
|
415
382
|
|
416
383
|
@cached_property
|
417
|
-
def with_streaming_response(self) ->
|
418
|
-
return
|
384
|
+
def with_streaming_response(self) -> AsyncGradientAIWithStreamedResponse:
|
385
|
+
return AsyncGradientAIWithStreamedResponse(self)
|
419
386
|
|
420
387
|
@property
|
421
388
|
@override
|
@@ -473,7 +440,7 @@ class AsyncDigitaloceanGenaiSDK(AsyncAPIClient):
|
|
473
440
|
params = set_default_query
|
474
441
|
|
475
442
|
http_client = http_client or self._client
|
476
|
-
|
443
|
+
client = self.__class__(
|
477
444
|
api_key=api_key or self.api_key,
|
478
445
|
base_url=base_url or self.base_url,
|
479
446
|
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
@@ -483,6 +450,8 @@ class AsyncDigitaloceanGenaiSDK(AsyncAPIClient):
|
|
483
450
|
default_query=params,
|
484
451
|
**_extra_kwargs,
|
485
452
|
)
|
453
|
+
client._base_url_overridden = self._base_url_overridden or base_url is not None
|
454
|
+
return client
|
486
455
|
|
487
456
|
# Alias for `copy` for nicer inline usage, e.g.
|
488
457
|
# client.with_options(timeout=10).foo.create(...)
|
@@ -522,10 +491,10 @@ class AsyncDigitaloceanGenaiSDK(AsyncAPIClient):
|
|
522
491
|
return APIStatusError(err_msg, response=response, body=body)
|
523
492
|
|
524
493
|
|
525
|
-
class
|
526
|
-
_client:
|
494
|
+
class GradientAIWithRawResponse:
|
495
|
+
_client: GradientAI
|
527
496
|
|
528
|
-
def __init__(self, client:
|
497
|
+
def __init__(self, client: GradientAI) -> None:
|
529
498
|
self._client = client
|
530
499
|
|
531
500
|
@cached_property
|
@@ -540,12 +509,6 @@ class DigitaloceanGenaiSDKWithRawResponse:
|
|
540
509
|
|
541
510
|
return ProvidersResourceWithRawResponse(self._client.providers)
|
542
511
|
|
543
|
-
@cached_property
|
544
|
-
def auth(self) -> auth.AuthResourceWithRawResponse:
|
545
|
-
from .resources.auth import AuthResourceWithRawResponse
|
546
|
-
|
547
|
-
return AuthResourceWithRawResponse(self._client.auth)
|
548
|
-
|
549
512
|
@cached_property
|
550
513
|
def regions(self) -> regions.RegionsResourceWithRawResponse:
|
551
514
|
from .resources.regions import RegionsResourceWithRawResponse
|
@@ -564,12 +527,6 @@ class DigitaloceanGenaiSDKWithRawResponse:
|
|
564
527
|
|
565
528
|
return KnowledgeBasesResourceWithRawResponse(self._client.knowledge_bases)
|
566
529
|
|
567
|
-
@cached_property
|
568
|
-
def api_keys(self) -> api_keys.APIKeysResourceWithRawResponse:
|
569
|
-
from .resources.api_keys import APIKeysResourceWithRawResponse
|
570
|
-
|
571
|
-
return APIKeysResourceWithRawResponse(self._client.api_keys)
|
572
|
-
|
573
530
|
@cached_property
|
574
531
|
def chat(self) -> chat.ChatResourceWithRawResponse:
|
575
532
|
from .resources.chat import ChatResourceWithRawResponse
|
@@ -577,10 +534,10 @@ class DigitaloceanGenaiSDKWithRawResponse:
|
|
577
534
|
return ChatResourceWithRawResponse(self._client.chat)
|
578
535
|
|
579
536
|
@cached_property
|
580
|
-
def
|
581
|
-
from .resources.
|
537
|
+
def inference(self) -> inference.InferenceResourceWithRawResponse:
|
538
|
+
from .resources.inference import InferenceResourceWithRawResponse
|
582
539
|
|
583
|
-
return
|
540
|
+
return InferenceResourceWithRawResponse(self._client.inference)
|
584
541
|
|
585
542
|
@cached_property
|
586
543
|
def models(self) -> models.ModelsResourceWithRawResponse:
|
@@ -589,10 +546,10 @@ class DigitaloceanGenaiSDKWithRawResponse:
|
|
589
546
|
return ModelsResourceWithRawResponse(self._client.models)
|
590
547
|
|
591
548
|
|
592
|
-
class
|
593
|
-
_client:
|
549
|
+
class AsyncGradientAIWithRawResponse:
|
550
|
+
_client: AsyncGradientAI
|
594
551
|
|
595
|
-
def __init__(self, client:
|
552
|
+
def __init__(self, client: AsyncGradientAI) -> None:
|
596
553
|
self._client = client
|
597
554
|
|
598
555
|
@cached_property
|
@@ -607,12 +564,6 @@ class AsyncDigitaloceanGenaiSDKWithRawResponse:
|
|
607
564
|
|
608
565
|
return AsyncProvidersResourceWithRawResponse(self._client.providers)
|
609
566
|
|
610
|
-
@cached_property
|
611
|
-
def auth(self) -> auth.AsyncAuthResourceWithRawResponse:
|
612
|
-
from .resources.auth import AsyncAuthResourceWithRawResponse
|
613
|
-
|
614
|
-
return AsyncAuthResourceWithRawResponse(self._client.auth)
|
615
|
-
|
616
567
|
@cached_property
|
617
568
|
def regions(self) -> regions.AsyncRegionsResourceWithRawResponse:
|
618
569
|
from .resources.regions import AsyncRegionsResourceWithRawResponse
|
@@ -631,12 +582,6 @@ class AsyncDigitaloceanGenaiSDKWithRawResponse:
|
|
631
582
|
|
632
583
|
return AsyncKnowledgeBasesResourceWithRawResponse(self._client.knowledge_bases)
|
633
584
|
|
634
|
-
@cached_property
|
635
|
-
def api_keys(self) -> api_keys.AsyncAPIKeysResourceWithRawResponse:
|
636
|
-
from .resources.api_keys import AsyncAPIKeysResourceWithRawResponse
|
637
|
-
|
638
|
-
return AsyncAPIKeysResourceWithRawResponse(self._client.api_keys)
|
639
|
-
|
640
585
|
@cached_property
|
641
586
|
def chat(self) -> chat.AsyncChatResourceWithRawResponse:
|
642
587
|
from .resources.chat import AsyncChatResourceWithRawResponse
|
@@ -644,10 +589,10 @@ class AsyncDigitaloceanGenaiSDKWithRawResponse:
|
|
644
589
|
return AsyncChatResourceWithRawResponse(self._client.chat)
|
645
590
|
|
646
591
|
@cached_property
|
647
|
-
def
|
648
|
-
from .resources.
|
592
|
+
def inference(self) -> inference.AsyncInferenceResourceWithRawResponse:
|
593
|
+
from .resources.inference import AsyncInferenceResourceWithRawResponse
|
649
594
|
|
650
|
-
return
|
595
|
+
return AsyncInferenceResourceWithRawResponse(self._client.inference)
|
651
596
|
|
652
597
|
@cached_property
|
653
598
|
def models(self) -> models.AsyncModelsResourceWithRawResponse:
|
@@ -656,10 +601,10 @@ class AsyncDigitaloceanGenaiSDKWithRawResponse:
|
|
656
601
|
return AsyncModelsResourceWithRawResponse(self._client.models)
|
657
602
|
|
658
603
|
|
659
|
-
class
|
660
|
-
_client:
|
604
|
+
class GradientAIWithStreamedResponse:
|
605
|
+
_client: GradientAI
|
661
606
|
|
662
|
-
def __init__(self, client:
|
607
|
+
def __init__(self, client: GradientAI) -> None:
|
663
608
|
self._client = client
|
664
609
|
|
665
610
|
@cached_property
|
@@ -674,12 +619,6 @@ class DigitaloceanGenaiSDKWithStreamedResponse:
|
|
674
619
|
|
675
620
|
return ProvidersResourceWithStreamingResponse(self._client.providers)
|
676
621
|
|
677
|
-
@cached_property
|
678
|
-
def auth(self) -> auth.AuthResourceWithStreamingResponse:
|
679
|
-
from .resources.auth import AuthResourceWithStreamingResponse
|
680
|
-
|
681
|
-
return AuthResourceWithStreamingResponse(self._client.auth)
|
682
|
-
|
683
622
|
@cached_property
|
684
623
|
def regions(self) -> regions.RegionsResourceWithStreamingResponse:
|
685
624
|
from .resources.regions import RegionsResourceWithStreamingResponse
|
@@ -698,12 +637,6 @@ class DigitaloceanGenaiSDKWithStreamedResponse:
|
|
698
637
|
|
699
638
|
return KnowledgeBasesResourceWithStreamingResponse(self._client.knowledge_bases)
|
700
639
|
|
701
|
-
@cached_property
|
702
|
-
def api_keys(self) -> api_keys.APIKeysResourceWithStreamingResponse:
|
703
|
-
from .resources.api_keys import APIKeysResourceWithStreamingResponse
|
704
|
-
|
705
|
-
return APIKeysResourceWithStreamingResponse(self._client.api_keys)
|
706
|
-
|
707
640
|
@cached_property
|
708
641
|
def chat(self) -> chat.ChatResourceWithStreamingResponse:
|
709
642
|
from .resources.chat import ChatResourceWithStreamingResponse
|
@@ -711,10 +644,10 @@ class DigitaloceanGenaiSDKWithStreamedResponse:
|
|
711
644
|
return ChatResourceWithStreamingResponse(self._client.chat)
|
712
645
|
|
713
646
|
@cached_property
|
714
|
-
def
|
715
|
-
from .resources.
|
647
|
+
def inference(self) -> inference.InferenceResourceWithStreamingResponse:
|
648
|
+
from .resources.inference import InferenceResourceWithStreamingResponse
|
716
649
|
|
717
|
-
return
|
650
|
+
return InferenceResourceWithStreamingResponse(self._client.inference)
|
718
651
|
|
719
652
|
@cached_property
|
720
653
|
def models(self) -> models.ModelsResourceWithStreamingResponse:
|
@@ -723,10 +656,10 @@ class DigitaloceanGenaiSDKWithStreamedResponse:
|
|
723
656
|
return ModelsResourceWithStreamingResponse(self._client.models)
|
724
657
|
|
725
658
|
|
726
|
-
class
|
727
|
-
_client:
|
659
|
+
class AsyncGradientAIWithStreamedResponse:
|
660
|
+
_client: AsyncGradientAI
|
728
661
|
|
729
|
-
def __init__(self, client:
|
662
|
+
def __init__(self, client: AsyncGradientAI) -> None:
|
730
663
|
self._client = client
|
731
664
|
|
732
665
|
@cached_property
|
@@ -741,12 +674,6 @@ class AsyncDigitaloceanGenaiSDKWithStreamedResponse:
|
|
741
674
|
|
742
675
|
return AsyncProvidersResourceWithStreamingResponse(self._client.providers)
|
743
676
|
|
744
|
-
@cached_property
|
745
|
-
def auth(self) -> auth.AsyncAuthResourceWithStreamingResponse:
|
746
|
-
from .resources.auth import AsyncAuthResourceWithStreamingResponse
|
747
|
-
|
748
|
-
return AsyncAuthResourceWithStreamingResponse(self._client.auth)
|
749
|
-
|
750
677
|
@cached_property
|
751
678
|
def regions(self) -> regions.AsyncRegionsResourceWithStreamingResponse:
|
752
679
|
from .resources.regions import AsyncRegionsResourceWithStreamingResponse
|
@@ -765,12 +692,6 @@ class AsyncDigitaloceanGenaiSDKWithStreamedResponse:
|
|
765
692
|
|
766
693
|
return AsyncKnowledgeBasesResourceWithStreamingResponse(self._client.knowledge_bases)
|
767
694
|
|
768
|
-
@cached_property
|
769
|
-
def api_keys(self) -> api_keys.AsyncAPIKeysResourceWithStreamingResponse:
|
770
|
-
from .resources.api_keys import AsyncAPIKeysResourceWithStreamingResponse
|
771
|
-
|
772
|
-
return AsyncAPIKeysResourceWithStreamingResponse(self._client.api_keys)
|
773
|
-
|
774
695
|
@cached_property
|
775
696
|
def chat(self) -> chat.AsyncChatResourceWithStreamingResponse:
|
776
697
|
from .resources.chat import AsyncChatResourceWithStreamingResponse
|
@@ -778,10 +699,10 @@ class AsyncDigitaloceanGenaiSDKWithStreamedResponse:
|
|
778
699
|
return AsyncChatResourceWithStreamingResponse(self._client.chat)
|
779
700
|
|
780
701
|
@cached_property
|
781
|
-
def
|
782
|
-
from .resources.
|
702
|
+
def inference(self) -> inference.AsyncInferenceResourceWithStreamingResponse:
|
703
|
+
from .resources.inference import AsyncInferenceResourceWithStreamingResponse
|
783
704
|
|
784
|
-
return
|
705
|
+
return AsyncInferenceResourceWithStreamingResponse(self._client.inference)
|
785
706
|
|
786
707
|
@cached_property
|
787
708
|
def models(self) -> models.AsyncModelsResourceWithStreamingResponse:
|
@@ -790,6 +711,6 @@ class AsyncDigitaloceanGenaiSDKWithStreamedResponse:
|
|
790
711
|
return AsyncModelsResourceWithStreamingResponse(self._client.models)
|
791
712
|
|
792
713
|
|
793
|
-
Client =
|
714
|
+
Client = GradientAI
|
794
715
|
|
795
|
-
AsyncClient =
|
716
|
+
AsyncClient = AsyncGradientAI
|
@@ -18,11 +18,11 @@ __all__ = [
|
|
18
18
|
]
|
19
19
|
|
20
20
|
|
21
|
-
class
|
21
|
+
class GradientAIError(Exception):
|
22
22
|
pass
|
23
23
|
|
24
24
|
|
25
|
-
class APIError(
|
25
|
+
class APIError(GradientAIError):
|
26
26
|
message: str
|
27
27
|
request: httpx.Request
|
28
28
|
|
@@ -8,13 +8,13 @@ from typing import TYPE_CHECKING
|
|
8
8
|
import anyio
|
9
9
|
|
10
10
|
if TYPE_CHECKING:
|
11
|
-
from ._client import
|
11
|
+
from ._client import GradientAI, AsyncGradientAI
|
12
12
|
|
13
13
|
|
14
14
|
class SyncAPIResource:
|
15
|
-
_client:
|
15
|
+
_client: GradientAI
|
16
16
|
|
17
|
-
def __init__(self, client:
|
17
|
+
def __init__(self, client: GradientAI) -> None:
|
18
18
|
self._client = client
|
19
19
|
self._get = client.get
|
20
20
|
self._post = client.post
|
@@ -28,9 +28,9 @@ class SyncAPIResource:
|
|
28
28
|
|
29
29
|
|
30
30
|
class AsyncAPIResource:
|
31
|
-
_client:
|
31
|
+
_client: AsyncGradientAI
|
32
32
|
|
33
|
-
def __init__(self, client:
|
33
|
+
def __init__(self, client: AsyncGradientAI) -> None:
|
34
34
|
self._client = client
|
35
35
|
self._get = client.get
|
36
36
|
self._post = client.post
|
@@ -29,7 +29,7 @@ from ._utils import is_given, extract_type_arg, is_annotated_type, is_type_alias
|
|
29
29
|
from ._models import BaseModel, is_basemodel
|
30
30
|
from ._constants import RAW_RESPONSE_HEADER, OVERRIDE_CAST_TO_HEADER
|
31
31
|
from ._streaming import Stream, AsyncStream, is_stream_class_type, extract_stream_chunk_type
|
32
|
-
from ._exceptions import
|
32
|
+
from ._exceptions import GradientAIError, APIResponseValidationError
|
33
33
|
|
34
34
|
if TYPE_CHECKING:
|
35
35
|
from ._models import FinalRequestOptions
|
@@ -218,7 +218,7 @@ class BaseAPIResponse(Generic[R]):
|
|
218
218
|
and issubclass(origin, pydantic.BaseModel)
|
219
219
|
):
|
220
220
|
raise TypeError(
|
221
|
-
"Pydantic models must subclass our base model type, e.g. `from
|
221
|
+
"Pydantic models must subclass our base model type, e.g. `from gradientai import BaseModel`"
|
222
222
|
)
|
223
223
|
|
224
224
|
if (
|
@@ -285,7 +285,7 @@ class APIResponse(BaseAPIResponse[R]):
|
|
285
285
|
the `to` argument, e.g.
|
286
286
|
|
287
287
|
```py
|
288
|
-
from
|
288
|
+
from gradientai import BaseModel
|
289
289
|
|
290
290
|
|
291
291
|
class MyModel(BaseModel):
|
@@ -387,7 +387,7 @@ class AsyncAPIResponse(BaseAPIResponse[R]):
|
|
387
387
|
the `to` argument, e.g.
|
388
388
|
|
389
389
|
```py
|
390
|
-
from
|
390
|
+
from gradientai import BaseModel
|
391
391
|
|
392
392
|
|
393
393
|
class MyModel(BaseModel):
|
@@ -558,11 +558,11 @@ class AsyncStreamedBinaryAPIResponse(AsyncAPIResponse[bytes]):
|
|
558
558
|
class MissingStreamClassError(TypeError):
|
559
559
|
def __init__(self) -> None:
|
560
560
|
super().__init__(
|
561
|
-
"The `stream` argument was set to `True` but the `stream_cls` argument was not given. See `
|
561
|
+
"The `stream` argument was set to `True` but the `stream_cls` argument was not given. See `gradientai._streaming` for reference",
|
562
562
|
)
|
563
563
|
|
564
564
|
|
565
|
-
class StreamAlreadyConsumed(
|
565
|
+
class StreamAlreadyConsumed(GradientAIError):
|
566
566
|
"""
|
567
567
|
Attempted to read or stream content, but the content has already
|
568
568
|
been streamed.
|