mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-29 11:23:49 +08:00
chore: 🐝 Update SDK - Generate (spec change merged) 0.11.17 (#422)
Co-authored-by: speakeasybot <bot@speakeasyapi.dev> Co-authored-by: speakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
speakeasybot
speakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
parent
e62415b7ce
commit
4a9b45c2a0
@@ -3,10 +3,10 @@
|
||||
import importlib.metadata
|
||||
|
||||
__title__: str = "openrouter"
|
||||
__version__: str = "0.11.16"
|
||||
__version__: str = "0.11.17"
|
||||
__openapi_doc_version__: str = "1.0.0"
|
||||
__gen_version__: str = "2.914.0"
|
||||
__user_agent__: str = "speakeasy-sdk/python 0.11.16 2.914.0 1.0.0 openrouter"
|
||||
__user_agent__: str = "speakeasy-sdk/python 0.11.17 2.914.0 1.0.0 openrouter"
|
||||
|
||||
try:
|
||||
if __package__ is not None:
|
||||
|
||||
@@ -2488,6 +2488,17 @@ if TYPE_CHECKING:
|
||||
SubagentServerToolConfig,
|
||||
SubagentServerToolConfigTypedDict,
|
||||
)
|
||||
from .submitgenerationfeedbackrequest import (
|
||||
Category,
|
||||
SubmitGenerationFeedbackRequest,
|
||||
SubmitGenerationFeedbackRequestTypedDict,
|
||||
)
|
||||
from .submitgenerationfeedbackresponse import (
|
||||
SubmitGenerationFeedbackResponse,
|
||||
SubmitGenerationFeedbackResponseData,
|
||||
SubmitGenerationFeedbackResponseDataTypedDict,
|
||||
SubmitGenerationFeedbackResponseTypedDict,
|
||||
)
|
||||
from .taskclassificationitem import (
|
||||
TaskClassificationItem,
|
||||
TaskClassificationItemTypedDict,
|
||||
@@ -2995,6 +3006,7 @@ __all__ = [
|
||||
"CachingTypedDict",
|
||||
"CapabilityDescriptor",
|
||||
"CapabilityDescriptorTypedDict",
|
||||
"Category",
|
||||
"ChatAssistantImages",
|
||||
"ChatAssistantImagesImageURL",
|
||||
"ChatAssistantImagesImageURLTypedDict",
|
||||
@@ -4486,6 +4498,12 @@ __all__ = [
|
||||
"SubagentServerToolOpenRouter",
|
||||
"SubagentServerToolOpenRouterType",
|
||||
"SubagentServerToolOpenRouterTypedDict",
|
||||
"SubmitGenerationFeedbackRequest",
|
||||
"SubmitGenerationFeedbackRequestTypedDict",
|
||||
"SubmitGenerationFeedbackResponse",
|
||||
"SubmitGenerationFeedbackResponseData",
|
||||
"SubmitGenerationFeedbackResponseDataTypedDict",
|
||||
"SubmitGenerationFeedbackResponseTypedDict",
|
||||
"SupportedAspectRatio",
|
||||
"SupportedFrameImage",
|
||||
"SupportedResolution",
|
||||
@@ -6605,6 +6623,13 @@ _dynamic_imports: dict[str, str] = {
|
||||
"SubagentServerToolOpenRouterTypedDict": ".subagentservertool_openrouter",
|
||||
"SubagentServerToolConfig": ".subagentservertoolconfig",
|
||||
"SubagentServerToolConfigTypedDict": ".subagentservertoolconfig",
|
||||
"Category": ".submitgenerationfeedbackrequest",
|
||||
"SubmitGenerationFeedbackRequest": ".submitgenerationfeedbackrequest",
|
||||
"SubmitGenerationFeedbackRequestTypedDict": ".submitgenerationfeedbackrequest",
|
||||
"SubmitGenerationFeedbackResponse": ".submitgenerationfeedbackresponse",
|
||||
"SubmitGenerationFeedbackResponseData": ".submitgenerationfeedbackresponse",
|
||||
"SubmitGenerationFeedbackResponseDataTypedDict": ".submitgenerationfeedbackresponse",
|
||||
"SubmitGenerationFeedbackResponseTypedDict": ".submitgenerationfeedbackresponse",
|
||||
"TaskClassificationItem": ".taskclassificationitem",
|
||||
"TaskClassificationItemTypedDict": ".taskclassificationitem",
|
||||
"TaskClassificationMacroCategory": ".taskclassificationmacrocategory",
|
||||
|
||||
@@ -78,7 +78,7 @@ BYOKProviderSlug = Union[
|
||||
"recraft",
|
||||
"reka",
|
||||
"relace",
|
||||
"sakana-ai",
|
||||
"sakana",
|
||||
"sambanova",
|
||||
"seed",
|
||||
"siliconflow",
|
||||
|
||||
@@ -162,7 +162,7 @@ class ImageGenerationRequestOptionsTypedDict(TypedDict):
|
||||
reka: NotRequired[Dict[str, Nullable[Any]]]
|
||||
relace: NotRequired[Dict[str, Nullable[Any]]]
|
||||
replicate: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sakana_ai: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sakana: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sambanova: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sambanova_cloaked: NotRequired[Dict[str, Nullable[Any]]]
|
||||
seed: NotRequired[Dict[str, Nullable[Any]]]
|
||||
@@ -422,9 +422,7 @@ class ImageGenerationRequestOptions(BaseModel):
|
||||
|
||||
replicate: Optional[Dict[str, Nullable[Any]]] = None
|
||||
|
||||
sakana_ai: Annotated[
|
||||
Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="sakana-ai")
|
||||
] = None
|
||||
sakana: Optional[Dict[str, Nullable[Any]]] = None
|
||||
|
||||
sambanova: Optional[Dict[str, Nullable[Any]]] = None
|
||||
|
||||
@@ -579,7 +577,7 @@ class ImageGenerationRequestOptions(BaseModel):
|
||||
"reka",
|
||||
"relace",
|
||||
"replicate",
|
||||
"sakana-ai",
|
||||
"sakana",
|
||||
"sambanova",
|
||||
"sambanova-cloaked",
|
||||
"seed",
|
||||
|
||||
@@ -108,7 +108,7 @@ class ProviderOptionsTypedDict(TypedDict):
|
||||
reka: NotRequired[Dict[str, Nullable[Any]]]
|
||||
relace: NotRequired[Dict[str, Nullable[Any]]]
|
||||
replicate: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sakana_ai: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sakana: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sambanova: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sambanova_cloaked: NotRequired[Dict[str, Nullable[Any]]]
|
||||
seed: NotRequired[Dict[str, Nullable[Any]]]
|
||||
@@ -368,9 +368,7 @@ class ProviderOptions(BaseModel):
|
||||
|
||||
replicate: Optional[Dict[str, Nullable[Any]]] = None
|
||||
|
||||
sakana_ai: Annotated[
|
||||
Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="sakana-ai")
|
||||
] = None
|
||||
sakana: Optional[Dict[str, Nullable[Any]]] = None
|
||||
|
||||
sambanova: Optional[Dict[str, Nullable[Any]]] = None
|
||||
|
||||
@@ -525,7 +523,7 @@ class ProviderOptions(BaseModel):
|
||||
"reka",
|
||||
"relace",
|
||||
"replicate",
|
||||
"sakana-ai",
|
||||
"sakana",
|
||||
"sambanova",
|
||||
"sambanova-cloaked",
|
||||
"seed",
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UNSET_SENTINEL, UnrecognizedStr
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
Category = Union[
|
||||
Literal[
|
||||
"latency",
|
||||
"incoherence",
|
||||
"incorrect_response",
|
||||
"formatting",
|
||||
"billing",
|
||||
"api_error",
|
||||
"other",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The category of feedback being reported"""
|
||||
|
||||
|
||||
class SubmitGenerationFeedbackRequestTypedDict(TypedDict):
|
||||
r"""Structured feedback about a specific generation"""
|
||||
|
||||
category: Category
|
||||
r"""The category of feedback being reported"""
|
||||
generation_id: str
|
||||
r"""The generation to submit feedback on"""
|
||||
comment: NotRequired[str]
|
||||
r"""An optional free-text comment describing the feedback"""
|
||||
|
||||
|
||||
class SubmitGenerationFeedbackRequest(BaseModel):
|
||||
r"""Structured feedback about a specific generation"""
|
||||
|
||||
category: Category
|
||||
r"""The category of feedback being reported"""
|
||||
|
||||
generation_id: str
|
||||
r"""The generation to submit feedback on"""
|
||||
|
||||
comment: Optional[str] = None
|
||||
r"""An optional free-text comment describing the feedback"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = set(["comment"])
|
||||
serialized = handler(self)
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k, serialized.get(n))
|
||||
|
||||
if val != UNSET_SENTINEL:
|
||||
if val is not None or k not in optional_fields:
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,40 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class SubmitGenerationFeedbackResponseDataTypedDict(TypedDict):
|
||||
success: Literal[True]
|
||||
r"""Whether the feedback was recorded"""
|
||||
|
||||
|
||||
class SubmitGenerationFeedbackResponseData(BaseModel):
|
||||
SUCCESS: Annotated[
|
||||
Annotated[Literal[True], AfterValidator(validate_const(True))],
|
||||
pydantic.Field(alias="success"),
|
||||
] = True
|
||||
r"""Whether the feedback was recorded"""
|
||||
|
||||
|
||||
class SubmitGenerationFeedbackResponseTypedDict(TypedDict):
|
||||
r"""Confirmation that the feedback was recorded"""
|
||||
|
||||
data: SubmitGenerationFeedbackResponseDataTypedDict
|
||||
|
||||
|
||||
class SubmitGenerationFeedbackResponse(BaseModel):
|
||||
r"""Confirmation that the feedback was recorded"""
|
||||
|
||||
data: SubmitGenerationFeedbackResponseData
|
||||
|
||||
|
||||
try:
|
||||
SubmitGenerationFeedbackResponseData.model_rebuild()
|
||||
except NameError:
|
||||
pass
|
||||
@@ -127,7 +127,7 @@ class VideoGenerationRequestOptionsTypedDict(TypedDict):
|
||||
reka: NotRequired[Dict[str, Nullable[Any]]]
|
||||
relace: NotRequired[Dict[str, Nullable[Any]]]
|
||||
replicate: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sakana_ai: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sakana: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sambanova: NotRequired[Dict[str, Nullable[Any]]]
|
||||
sambanova_cloaked: NotRequired[Dict[str, Nullable[Any]]]
|
||||
seed: NotRequired[Dict[str, Nullable[Any]]]
|
||||
@@ -387,9 +387,7 @@ class VideoGenerationRequestOptions(BaseModel):
|
||||
|
||||
replicate: Optional[Dict[str, Nullable[Any]]] = None
|
||||
|
||||
sakana_ai: Annotated[
|
||||
Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="sakana-ai")
|
||||
] = None
|
||||
sakana: Optional[Dict[str, Nullable[Any]]] = None
|
||||
|
||||
sambanova: Optional[Dict[str, Nullable[Any]]] = None
|
||||
|
||||
@@ -544,7 +542,7 @@ class VideoGenerationRequestOptions(BaseModel):
|
||||
"reka",
|
||||
"relace",
|
||||
"replicate",
|
||||
"sakana-ai",
|
||||
"sakana",
|
||||
"sambanova",
|
||||
"sambanova-cloaked",
|
||||
"seed",
|
||||
|
||||
@@ -619,3 +619,313 @@ class Generations(BaseSDK):
|
||||
)
|
||||
|
||||
raise errors.OpenRouterDefaultError("Unexpected response received", http_res)
|
||||
|
||||
def submit_feedback(
|
||||
self,
|
||||
*,
|
||||
category: components.Category,
|
||||
generation_id: str,
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
comment: Optional[str] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> components.SubmitGenerationFeedbackResponse:
|
||||
r"""Submit feedback for a generation
|
||||
|
||||
Submit structured feedback on a generation the authenticated user made. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
||||
|
||||
:param category: The category of feedback being reported
|
||||
:param generation_id: The generation to submit feedback on
|
||||
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
This is used to track API usage per application.
|
||||
|
||||
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param comment: An optional free-text comment describing the feedback
|
||||
: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 http_headers: Additional headers to set or replace on requests.
|
||||
"""
|
||||
base_url = None
|
||||
url_variables = None
|
||||
if timeout_ms is None:
|
||||
timeout_ms = self.sdk_configuration.timeout_ms
|
||||
|
||||
if server_url is not None:
|
||||
base_url = server_url
|
||||
else:
|
||||
base_url = self._get_url(base_url, url_variables)
|
||||
|
||||
request = operations.SubmitGenerationFeedbackRequest(
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
submit_generation_feedback_request=components.SubmitGenerationFeedbackRequest(
|
||||
category=category,
|
||||
comment=comment,
|
||||
generation_id=generation_id,
|
||||
),
|
||||
)
|
||||
|
||||
req = self._build_request(
|
||||
method="POST",
|
||||
path="/generation/feedback",
|
||||
base_url=base_url,
|
||||
url_variables=url_variables,
|
||||
request=request,
|
||||
request_body_required=True,
|
||||
request_has_path_params=False,
|
||||
request_has_query_params=True,
|
||||
user_agent_header="user-agent",
|
||||
accept_header_value="application/json",
|
||||
http_headers=http_headers,
|
||||
_globals=operations.SubmitGenerationFeedbackGlobals(
|
||||
http_referer=self.sdk_configuration.globals.http_referer,
|
||||
x_open_router_title=self.sdk_configuration.globals.x_open_router_title,
|
||||
x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories,
|
||||
),
|
||||
security=self.sdk_configuration.security,
|
||||
get_serialized_body=lambda: utils.serialize_request_body(
|
||||
request.submit_generation_feedback_request,
|
||||
False,
|
||||
False,
|
||||
"json",
|
||||
components.SubmitGenerationFeedbackRequest,
|
||||
),
|
||||
allow_empty_value=None,
|
||||
timeout_ms=timeout_ms,
|
||||
)
|
||||
|
||||
if retries == UNSET:
|
||||
if self.sdk_configuration.retry_config is not UNSET:
|
||||
retries = self.sdk_configuration.retry_config
|
||||
else:
|
||||
retries = utils.RetryConfig(
|
||||
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
||||
)
|
||||
|
||||
retry_config = None
|
||||
if isinstance(retries, utils.RetryConfig):
|
||||
retry_config = (retries, ["5XX"])
|
||||
|
||||
http_res = self.do_request(
|
||||
hook_ctx=HookContext(
|
||||
config=self.sdk_configuration,
|
||||
base_url=base_url or "",
|
||||
operation_id="submitGenerationFeedback",
|
||||
oauth2_scopes=None,
|
||||
security_source=get_security_from_env(
|
||||
self.sdk_configuration.security, components.Security
|
||||
),
|
||||
tags=["Generations"],
|
||||
extensions=None,
|
||||
),
|
||||
request=req,
|
||||
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(
|
||||
components.SubmitGenerationFeedbackResponse, http_res
|
||||
)
|
||||
if utils.match_response(http_res, "400", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.BadRequestResponseErrorData, http_res
|
||||
)
|
||||
raise errors.BadRequestResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.UnauthorizedResponseErrorData, http_res
|
||||
)
|
||||
raise errors.UnauthorizedResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "404", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.NotFoundResponseErrorData, http_res
|
||||
)
|
||||
raise errors.NotFoundResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "429", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.TooManyRequestsResponseErrorData, http_res
|
||||
)
|
||||
raise errors.TooManyRequestsResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "500", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.InternalServerResponseErrorData, http_res
|
||||
)
|
||||
raise errors.InternalServerResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "4XX", "*"):
|
||||
http_res_text = utils.stream_to_text(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
if utils.match_response(http_res, "5XX", "*"):
|
||||
http_res_text = utils.stream_to_text(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
|
||||
raise errors.OpenRouterDefaultError("Unexpected response received", http_res)
|
||||
|
||||
async def submit_feedback_async(
|
||||
self,
|
||||
*,
|
||||
category: components.Category,
|
||||
generation_id: str,
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
comment: Optional[str] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> components.SubmitGenerationFeedbackResponse:
|
||||
r"""Submit feedback for a generation
|
||||
|
||||
Submit structured feedback on a generation the authenticated user made. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
||||
|
||||
:param category: The category of feedback being reported
|
||||
:param generation_id: The generation to submit feedback on
|
||||
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
This is used to track API usage per application.
|
||||
|
||||
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param comment: An optional free-text comment describing the feedback
|
||||
: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 http_headers: Additional headers to set or replace on requests.
|
||||
"""
|
||||
base_url = None
|
||||
url_variables = None
|
||||
if timeout_ms is None:
|
||||
timeout_ms = self.sdk_configuration.timeout_ms
|
||||
|
||||
if server_url is not None:
|
||||
base_url = server_url
|
||||
else:
|
||||
base_url = self._get_url(base_url, url_variables)
|
||||
|
||||
request = operations.SubmitGenerationFeedbackRequest(
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
submit_generation_feedback_request=components.SubmitGenerationFeedbackRequest(
|
||||
category=category,
|
||||
comment=comment,
|
||||
generation_id=generation_id,
|
||||
),
|
||||
)
|
||||
|
||||
req = self._build_request_async(
|
||||
method="POST",
|
||||
path="/generation/feedback",
|
||||
base_url=base_url,
|
||||
url_variables=url_variables,
|
||||
request=request,
|
||||
request_body_required=True,
|
||||
request_has_path_params=False,
|
||||
request_has_query_params=True,
|
||||
user_agent_header="user-agent",
|
||||
accept_header_value="application/json",
|
||||
http_headers=http_headers,
|
||||
_globals=operations.SubmitGenerationFeedbackGlobals(
|
||||
http_referer=self.sdk_configuration.globals.http_referer,
|
||||
x_open_router_title=self.sdk_configuration.globals.x_open_router_title,
|
||||
x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories,
|
||||
),
|
||||
security=self.sdk_configuration.security,
|
||||
get_serialized_body=lambda: utils.serialize_request_body(
|
||||
request.submit_generation_feedback_request,
|
||||
False,
|
||||
False,
|
||||
"json",
|
||||
components.SubmitGenerationFeedbackRequest,
|
||||
),
|
||||
allow_empty_value=None,
|
||||
timeout_ms=timeout_ms,
|
||||
)
|
||||
|
||||
if retries == UNSET:
|
||||
if self.sdk_configuration.retry_config is not UNSET:
|
||||
retries = self.sdk_configuration.retry_config
|
||||
else:
|
||||
retries = utils.RetryConfig(
|
||||
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
||||
)
|
||||
|
||||
retry_config = None
|
||||
if isinstance(retries, utils.RetryConfig):
|
||||
retry_config = (retries, ["5XX"])
|
||||
|
||||
http_res = await self.do_request_async(
|
||||
hook_ctx=HookContext(
|
||||
config=self.sdk_configuration,
|
||||
base_url=base_url or "",
|
||||
operation_id="submitGenerationFeedback",
|
||||
oauth2_scopes=None,
|
||||
security_source=get_security_from_env(
|
||||
self.sdk_configuration.security, components.Security
|
||||
),
|
||||
tags=["Generations"],
|
||||
extensions=None,
|
||||
),
|
||||
request=req,
|
||||
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(
|
||||
components.SubmitGenerationFeedbackResponse, http_res
|
||||
)
|
||||
if utils.match_response(http_res, "400", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.BadRequestResponseErrorData, http_res
|
||||
)
|
||||
raise errors.BadRequestResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.UnauthorizedResponseErrorData, http_res
|
||||
)
|
||||
raise errors.UnauthorizedResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "404", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.NotFoundResponseErrorData, http_res
|
||||
)
|
||||
raise errors.NotFoundResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "429", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.TooManyRequestsResponseErrorData, http_res
|
||||
)
|
||||
raise errors.TooManyRequestsResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "500", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.InternalServerResponseErrorData, http_res
|
||||
)
|
||||
raise errors.InternalServerResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "4XX", "*"):
|
||||
http_res_text = await utils.stream_to_text_async(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
if utils.match_response(http_res, "5XX", "*"):
|
||||
http_res_text = await utils.stream_to_text_async(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
|
||||
raise errors.OpenRouterDefaultError("Unexpected response received", http_res)
|
||||
|
||||
@@ -686,6 +686,12 @@ if TYPE_CHECKING:
|
||||
SendChatCompletionRequestResponse,
|
||||
SendChatCompletionRequestResponseTypedDict,
|
||||
)
|
||||
from .submitgenerationfeedback import (
|
||||
SubmitGenerationFeedbackGlobals,
|
||||
SubmitGenerationFeedbackGlobalsTypedDict,
|
||||
SubmitGenerationFeedbackRequest,
|
||||
SubmitGenerationFeedbackRequestTypedDict,
|
||||
)
|
||||
from .updatebyokkey import (
|
||||
UpdateBYOKKeyGlobals,
|
||||
UpdateBYOKKeyGlobalsTypedDict,
|
||||
@@ -1248,6 +1254,10 @@ __all__ = [
|
||||
"SendChatCompletionRequestResponseTypedDict",
|
||||
"Source",
|
||||
"Subcategory",
|
||||
"SubmitGenerationFeedbackGlobals",
|
||||
"SubmitGenerationFeedbackGlobalsTypedDict",
|
||||
"SubmitGenerationFeedbackRequest",
|
||||
"SubmitGenerationFeedbackRequestTypedDict",
|
||||
"TaskType",
|
||||
"TimeRange",
|
||||
"TimeRangeTypedDict",
|
||||
@@ -1825,6 +1835,10 @@ _dynamic_imports: dict[str, str] = {
|
||||
"SendChatCompletionRequestRequestTypedDict": ".sendchatcompletionrequest",
|
||||
"SendChatCompletionRequestResponse": ".sendchatcompletionrequest",
|
||||
"SendChatCompletionRequestResponseTypedDict": ".sendchatcompletionrequest",
|
||||
"SubmitGenerationFeedbackGlobals": ".submitgenerationfeedback",
|
||||
"SubmitGenerationFeedbackGlobalsTypedDict": ".submitgenerationfeedback",
|
||||
"SubmitGenerationFeedbackRequest": ".submitgenerationfeedback",
|
||||
"SubmitGenerationFeedbackRequestTypedDict": ".submitgenerationfeedback",
|
||||
"UpdateBYOKKeyGlobals": ".updatebyokkey",
|
||||
"UpdateBYOKKeyGlobalsTypedDict": ".updatebyokkey",
|
||||
"UpdateBYOKKeyRequest": ".updatebyokkey",
|
||||
|
||||
@@ -149,7 +149,7 @@ Provider = Union[
|
||||
"recraft",
|
||||
"reka",
|
||||
"relace",
|
||||
"sakana-ai",
|
||||
"sakana",
|
||||
"sambanova",
|
||||
"seed",
|
||||
"siliconflow",
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.components import (
|
||||
submitgenerationfeedbackrequest as components_submitgenerationfeedbackrequest,
|
||||
)
|
||||
from openrouter.types import BaseModel, UNSET_SENTINEL
|
||||
from openrouter.utils import FieldMetadata, HeaderMetadata, RequestMetadata
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing import Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class SubmitGenerationFeedbackGlobalsTypedDict(TypedDict):
|
||||
http_referer: NotRequired[str]
|
||||
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
This is used to track API usage per application.
|
||||
|
||||
"""
|
||||
x_open_router_title: NotRequired[str]
|
||||
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||
|
||||
"""
|
||||
x_open_router_categories: NotRequired[str]
|
||||
r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
class SubmitGenerationFeedbackGlobals(BaseModel):
|
||||
http_referer: Annotated[
|
||||
Optional[str],
|
||||
pydantic.Field(alias="HTTP-Referer"),
|
||||
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
||||
] = None
|
||||
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
This is used to track API usage per application.
|
||||
|
||||
"""
|
||||
|
||||
x_open_router_title: Annotated[
|
||||
Optional[str],
|
||||
pydantic.Field(alias="X-OpenRouter-Title"),
|
||||
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
||||
] = None
|
||||
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||
|
||||
"""
|
||||
|
||||
x_open_router_categories: Annotated[
|
||||
Optional[str],
|
||||
pydantic.Field(alias="X-OpenRouter-Categories"),
|
||||
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
||||
] = None
|
||||
r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = set(
|
||||
["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"]
|
||||
)
|
||||
serialized = handler(self)
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k, serialized.get(n))
|
||||
|
||||
if val != UNSET_SENTINEL:
|
||||
if val is not None or k not in optional_fields:
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class SubmitGenerationFeedbackRequestTypedDict(TypedDict):
|
||||
submit_generation_feedback_request: components_submitgenerationfeedbackrequest.SubmitGenerationFeedbackRequestTypedDict
|
||||
http_referer: NotRequired[str]
|
||||
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
This is used to track API usage per application.
|
||||
|
||||
"""
|
||||
x_open_router_title: NotRequired[str]
|
||||
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||
|
||||
"""
|
||||
x_open_router_categories: NotRequired[str]
|
||||
r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
class SubmitGenerationFeedbackRequest(BaseModel):
|
||||
submit_generation_feedback_request: Annotated[
|
||||
components_submitgenerationfeedbackrequest.SubmitGenerationFeedbackRequest,
|
||||
FieldMetadata(request=RequestMetadata(media_type="application/json")),
|
||||
]
|
||||
|
||||
http_referer: Annotated[
|
||||
Optional[str],
|
||||
pydantic.Field(alias="HTTP-Referer"),
|
||||
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
||||
] = None
|
||||
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
This is used to track API usage per application.
|
||||
|
||||
"""
|
||||
|
||||
x_open_router_title: Annotated[
|
||||
Optional[str],
|
||||
pydantic.Field(alias="X-OpenRouter-Title"),
|
||||
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
||||
] = None
|
||||
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||
|
||||
"""
|
||||
|
||||
x_open_router_categories: Annotated[
|
||||
Optional[str],
|
||||
pydantic.Field(alias="X-OpenRouter-Categories"),
|
||||
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
||||
] = None
|
||||
r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = set(
|
||||
["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"]
|
||||
)
|
||||
serialized = handler(self)
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k, serialized.get(n))
|
||||
|
||||
if val != UNSET_SENTINEL:
|
||||
if val is not None or k not in optional_fields:
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
Reference in New Issue
Block a user