mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-29 11:23:49 +08:00
updates
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from .basesdk import BaseSDK
|
||||
from enum import Enum
|
||||
from openrouter import components, errors, operations, utils
|
||||
from openrouter._hooks import HookContext
|
||||
from openrouter.types import OptionalNullable, UNSET
|
||||
@@ -9,6 +10,11 @@ from openrouter.utils.unmarshal_json_response import unmarshal_json_response
|
||||
from typing import Any, Mapping, Optional, Union
|
||||
|
||||
|
||||
class GenerateAcceptEnum(str, Enum):
|
||||
APPLICATION_JSON = "application/json"
|
||||
TEXT_EVENT_STREAM = "text/event-stream"
|
||||
|
||||
|
||||
class Embeddings(BaseSDK):
|
||||
r"""Text embedding endpoints"""
|
||||
|
||||
@@ -30,6 +36,7 @@ class Embeddings(BaseSDK):
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
accept_header_override: Optional[GenerateAcceptEnum] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> operations.CreateEmbeddingsResponse:
|
||||
r"""Submit an embedding request
|
||||
@@ -46,6 +53,7 @@ class Embeddings(BaseSDK):
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
:param accept_header_override: Override the default accept header for this method
|
||||
:param http_headers: Additional headers to set or replace on requests.
|
||||
"""
|
||||
base_url = None
|
||||
@@ -80,7 +88,9 @@ class Embeddings(BaseSDK):
|
||||
request_has_path_params=False,
|
||||
request_has_query_params=True,
|
||||
user_agent_header="user-agent",
|
||||
accept_header_value="application/json",
|
||||
accept_header_value=accept_header_override.value
|
||||
if accept_header_override is not None
|
||||
else "application/json;q=1, text/event-stream;q=0",
|
||||
http_headers=http_headers,
|
||||
security=self.sdk_configuration.security,
|
||||
get_serialized_body=lambda: utils.serialize_request_body(
|
||||
@@ -129,8 +139,10 @@ class Embeddings(BaseSDK):
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(
|
||||
operations.CreateEmbeddingsResponse, http_res
|
||||
operations.CreateEmbeddingsResponseBody, http_res
|
||||
)
|
||||
if utils.match_response(http_res, "200", "text/event-stream"):
|
||||
return http_res.text
|
||||
if utils.match_response(http_res, "400", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.BadRequestResponseErrorData, http_res
|
||||
@@ -212,6 +224,7 @@ class Embeddings(BaseSDK):
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
accept_header_override: Optional[GenerateAcceptEnum] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> operations.CreateEmbeddingsResponse:
|
||||
r"""Submit an embedding request
|
||||
@@ -228,6 +241,7 @@ class Embeddings(BaseSDK):
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
:param accept_header_override: Override the default accept header for this method
|
||||
:param http_headers: Additional headers to set or replace on requests.
|
||||
"""
|
||||
base_url = None
|
||||
@@ -262,7 +276,9 @@ class Embeddings(BaseSDK):
|
||||
request_has_path_params=False,
|
||||
request_has_query_params=True,
|
||||
user_agent_header="user-agent",
|
||||
accept_header_value="application/json",
|
||||
accept_header_value=accept_header_override.value
|
||||
if accept_header_override is not None
|
||||
else "application/json;q=1, text/event-stream;q=0",
|
||||
http_headers=http_headers,
|
||||
security=self.sdk_configuration.security,
|
||||
get_serialized_body=lambda: utils.serialize_request_body(
|
||||
@@ -311,8 +327,10 @@ class Embeddings(BaseSDK):
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(
|
||||
operations.CreateEmbeddingsResponse, http_res
|
||||
operations.CreateEmbeddingsResponseBody, http_res
|
||||
)
|
||||
if utils.match_response(http_res, "200", "text/event-stream"):
|
||||
return http_res.text
|
||||
if utils.match_response(http_res, "400", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.BadRequestResponseErrorData, http_res
|
||||
|
||||
Reference in New Issue
Block a user