Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion google/genai/_gaos/_hooks/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
BeforeRequestHook,
)
import asyncio
import httpx
import httpx2 as httpx
from typing import Optional, Tuple, Union

# ============================================================================
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/_hooks/asyncregistration.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def init_async_hooks(hooks: AsyncHooks):

Example:
from .asynctypes import AsyncBeforeRequestHook, BeforeRequestContext
import httpx
import httpx2 as httpx

class MyAsyncHook(AsyncBeforeRequestHook):
async def before_request(self, hook_ctx: BeforeRequestContext, request: httpx.Request):
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/_hooks/asyncsdkhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

import httpx
import httpx2 as httpx
from .asynctypes import (
AsyncBeforeRequestHook,
AsyncAfterSuccessHook,
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/_hooks/asynctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
BeforeRequestContext,
)
from abc import ABC, abstractmethod
import httpx
import httpx2 as httpx
from typing import Optional, Tuple, Union


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/_hooks/google_genai_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from typing import Any, Callable, Mapping, Optional, Union, cast

import httpx
import httpx2 as httpx

from .. import types, utils
from .types import BeforeRequestContext, BeforeRequestHook
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/_hooks/sdkhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

import httpx
import httpx2 as httpx
from .types import (
SDKInitHook,
BeforeRequestContext,
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/_hooks/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from ..sdkconfiguration import SDKConfiguration
from abc import ABC, abstractmethod
import httpx
import httpx2 as httpx
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .basesdk import AsyncBaseSDK, BaseSDK
from .types import OptionalNullable, UNSET
from .utils import get_security_from_env, response_helpers
import httpx
import httpx2 as httpx
from typing import Any, Mapping, Optional, Union, cast


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .types.agents import agent as agents_agent, agenttool as agents_agenttool
from .utils import get_security_from_env, response_helpers
from .utils.unmarshal_json_response import unmarshal_json_response
import httpx
import httpx2 as httpx
from typing import Any, Iterable, List, Mapping, Optional, Union, cast


Expand Down
20 changes: 13 additions & 7 deletions google/genai/_gaos/basesdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,24 @@
)
from .sdkconfiguration import SDKConfiguration
from .utils import RetryConfig, SerializedRequestBody, get_body_content
import httpx
import httpx2 as httpx

try:
import httpx2
import httpx as httpx1
except ImportError:
httpx2 = None
httpx1 = None

_HTTPX_TIMEOUT_TYPES = (
(httpx.Timeout,)
if httpx2 is None
else (httpx.Timeout, httpx2.Timeout)
if httpx1 is None
else (httpx.Timeout, httpx1.Timeout)
)


def _default_timeout(client):
if httpx1 is not None and isinstance(client, (httpx1.Client, httpx1.AsyncClient)):
return httpx1.USE_CLIENT_DEFAULT
return httpx.USE_CLIENT_DEFAULT
from typing import Any, Callable, List, Mapping, Optional, Tuple
from urllib.parse import parse_qs, urlparse

Expand Down Expand Up @@ -234,7 +240,7 @@ def _build_request_with_client(
data=serialized_request_body.data,
files=serialized_request_body.files,
headers=headers,
timeout=timeout if timeout is not None else httpx.USE_CLIENT_DEFAULT,
timeout=timeout if timeout is not None else _default_timeout(client),
)

def do_request(
Expand Down Expand Up @@ -501,7 +507,7 @@ def _build_request_with_client(
data=serialized_request_body.data,
files=serialized_request_body.files,
headers=headers,
timeout=timeout if timeout is not None else httpx.USE_CLIENT_DEFAULT,
timeout=timeout if timeout is not None else _default_timeout(client),
)

async def do_request_async(
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from .types import BaseModel, OptionalNullable, UNSET, credentials, interactions
from .utils import get_security_from_env, response_helpers
from .utils.unmarshal_json_response import unmarshal_json_response
import httpx
import httpx2 as httpx
from typing import Any, List, Literal, Mapping, Optional, Union, cast, overload


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from .types.interactions import source as interactions_source
from .utils import get_security_from_env, response_helpers
from .utils.unmarshal_json_response import unmarshal_json_response
import httpx
import httpx2 as httpx
from typing import Any, Iterable, List, Mapping, Optional, Union, cast


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/errors/cancelinteractionbyid.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from ..types import BaseModel
from ..types.interactions import error as interactions_error
from dataclasses import dataclass, field
import httpx
import httpx2 as httpx
from typing import Optional


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/errors/createinteraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from ..types import BaseModel
from ..types.interactions import error as interactions_error
from dataclasses import dataclass, field
import httpx
import httpx2 as httpx
from typing import Optional


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/errors/deleteinteraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from ..types import BaseModel
from ..types.interactions import error as interactions_error
from dataclasses import dataclass, field
import httpx
import httpx2 as httpx
from typing import Optional


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/errors/genaidefaulterror.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

import httpx
import httpx2 as httpx
from typing import Optional
from dataclasses import dataclass

Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/errors/genaierror.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

import httpx
import httpx2 as httpx
from typing import Optional
from dataclasses import dataclass, field

Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/errors/getinteractionbyid.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from ..types import BaseModel
from ..types.interactions import error as interactions_error
from dataclasses import dataclass, field
import httpx
import httpx2 as httpx
from typing import Optional


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/errors/responsevalidationerror.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

import httpx
import httpx2 as httpx
from typing import Optional
from dataclasses import dataclass

Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from .types import OptionalNullable, UNSET, environments
from .utils import get_security_from_env, response_helpers
from .utils.unmarshal_json_response import unmarshal_json_response
import httpx
import httpx2 as httpx
from typing import Any, Mapping, Optional, Union, cast


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/google_genai.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import mimetypes
import os

import httpx
import httpx2 as httpx

from ._hooks.google_genai_auth import (
GOOGLE_GENAI_API_REVISION as _GOOGLE_GENAI_API_REVISION,
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# pyright: reportReturnType = false
import asyncio
from typing_extensions import Protocol, runtime_checkable
import httpx
import httpx2 as httpx
from typing import Any, Optional, Union


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .utils import get_security_from_env, response_helpers
from .utils.eventstreaming import AsyncStream, Stream
from .utils.unmarshal_json_response import unmarshal_json_response
import httpx
import httpx2 as httpx
from typing import Any, Dict, List, Literal, Mapping, Optional, Union, cast, overload


Expand Down
20 changes: 10 additions & 10 deletions google/genai/_gaos/lib/compat_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@
import json
from typing import Any, Awaitable, Callable, Optional, TypeVar, cast

import httpx2 as httpx

try:
import httpx2
import httpx as httpx1
except ImportError:
httpx2 = None

import httpx
httpx1 = None

_HTTPX_TIMEOUT_ERRORS = (
(httpx.TimeoutException,)
if httpx2 is None
else (httpx.TimeoutException, httpx2.TimeoutException)
if httpx1 is None
else (httpx.TimeoutException, httpx1.TimeoutException)
)
_HTTPX_HTTP_ERRORS = (
(httpx.HTTPError,)
if httpx2 is None
else (httpx.HTTPError, httpx2.HTTPError)
if httpx1 is None
else (httpx.HTTPError, httpx1.HTTPError)
)

from ..errors.genaierror import GenAiError
Expand Down Expand Up @@ -336,8 +336,8 @@ def wrap_sdk_error(error: BaseException) -> BaseException:

_WRAP_EXCEPTIONS = (
(GenAiError, NoResponseError, httpx.HTTPError)
if httpx2 is None
else (GenAiError, NoResponseError, httpx.HTTPError, httpx2.HTTPError)
if httpx1 is None
else (GenAiError, NoResponseError, httpx.HTTPError, httpx1.HTTPError)
)


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .types import OptionalNullable, UNSET
from .utils.logger import Logger, get_default_logger
from .utils.retries import RetryConfig
import httpx
import httpx2 as httpx
import importlib
import importlib.util
import sys
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from .types.triggers import triggerupdate as triggers_triggerupdate
from .utils import get_security_from_env, response_helpers
from .utils.unmarshal_json_response import unmarshal_json_response
import httpx
import httpx2 as httpx
from typing import Any, Mapping, Optional, Union, cast


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/utils/eventstreaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
AsyncGenerator,
Tuple,
)
import httpx
import httpx2 as httpx

T = TypeVar("T")

Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/utils/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
List,
Optional,
)
from httpx import Headers
from httpx2 import Headers
from pydantic import BaseModel
from pydantic.fields import FieldInfo

Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

import httpx
import httpx2 as httpx
import logging
import os
from typing import Any, Protocol
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/utils/response_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
overload,
)

import httpx
import httpx2 as httpx
from pydantic import BaseModel
from typing_extensions import TypeAliasType

Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/utils/retries.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from email.utils import parsedate_to_datetime
from typing import List, Optional

import httpx
import httpx2 as httpx


class BackoffStrategy:
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/utils/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import typing_extensions
from typing_extensions import get_origin

import httpx
import httpx2 as httpx
from pydantic import ConfigDict, create_model
from pydantic_core import from_json

Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/utils/unmarshal_json_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from typing import Any, Optional, Type, TypeVar, overload

import httpx
import httpx2 as httpx

from .serializers import unmarshal_json, construct_unvalidated
from .. import errors
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/utils/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import os
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union, cast

from httpx import Response
from httpx2 import Response
from pydantic import BaseModel
from pydantic.fields import FieldInfo

Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/voices.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .types.voices import voice_input as voices_voice_input
from .utils import get_security_from_env, response_helpers
from .utils.unmarshal_json_response import unmarshal_json_response
import httpx
import httpx2 as httpx
from typing import Any, Iterable, List, Mapping, Optional, Union, cast


Expand Down
2 changes: 1 addition & 1 deletion google/genai/_gaos/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
)
from .utils import get_security_from_env, response_helpers
from .utils.unmarshal_json_response import unmarshal_json_response
import httpx
import httpx2 as httpx
from typing import Any, Iterable, List, Mapping, Optional, Union, cast


Expand Down
Loading
Loading