11from http import HTTPStatus
2- from typing import Any
2+ from typing import Any , Optional , Union
33
44import httpx
55
6- from src . attribution . infini_gram_api_client import errors
7- from src . attribution . infini_gram_api_client .client import AuthenticatedClient , Client
8- from src . attribution . infini_gram_api_client .models .available_infini_gram_index_id import AvailableInfiniGramIndexId
9- from src . attribution . infini_gram_api_client .models .http_validation_error import HTTPValidationError
10- from src . attribution . infini_gram_api_client .models .infini_gram_count_response import InfiniGramCountResponse
11- from src . attribution . infini_gram_api_client .types import UNSET , Response
6+ from ... import errors
7+ from .. .client import AuthenticatedClient , Client
8+ from .. .models .available_infini_gram_index_id import AvailableInfiniGramIndexId
9+ from .. .models .infini_gram_count_response import InfiniGramCountResponse
10+ from .. .models .request_validation_error import RequestValidationError
11+ from .. .types import UNSET , Response
1212
1313
1414def _get_kwargs (
@@ -32,22 +32,25 @@ def _get_kwargs(
3232
3333
3434def _parse_response (
35- * , client : AuthenticatedClient | Client , response : httpx .Response
36- ) -> HTTPValidationError | InfiniGramCountResponse | None :
35+ * , client : Union [ AuthenticatedClient , Client ] , response : httpx .Response
36+ ) -> Optional [ Union [ InfiniGramCountResponse , RequestValidationError ]] :
3737 if response .status_code == 200 :
38- return InfiniGramCountResponse .from_dict (response .json ())
38+ response_200 = InfiniGramCountResponse .from_dict (response .json ())
3939
40+ return response_200
4041 if response .status_code == 422 :
41- return HTTPValidationError .from_dict (response .json ())
42+ response_422 = RequestValidationError .from_dict (response .json ())
4243
44+ return response_422
4345 if client .raise_on_unexpected_status :
4446 raise errors .UnexpectedStatus (response .status_code , response .content )
45- return None
47+ else :
48+ return None
4649
4750
4851def _build_response (
49- * , client : AuthenticatedClient | Client , response : httpx .Response
50- ) -> Response [HTTPValidationError | InfiniGramCountResponse ]:
52+ * , client : Union [ AuthenticatedClient , Client ] , response : httpx .Response
53+ ) -> Response [Union [ InfiniGramCountResponse , RequestValidationError ] ]:
5154 return Response (
5255 status_code = HTTPStatus (response .status_code ),
5356 content = response .content ,
@@ -59,9 +62,9 @@ def _build_response(
5962def sync_detailed (
6063 index : AvailableInfiniGramIndexId ,
6164 * ,
62- client : AuthenticatedClient | Client ,
65+ client : Union [ AuthenticatedClient , Client ] ,
6366 query : str ,
64- ) -> Response [HTTPValidationError | InfiniGramCountResponse ]:
67+ ) -> Response [Union [ InfiniGramCountResponse , RequestValidationError ] ]:
6568 """Count
6669
6770 Args:
@@ -73,7 +76,7 @@ def sync_detailed(
7376 httpx.TimeoutException: If the request takes longer than Client.timeout.
7477
7578 Returns:
76- Response[Union[HTTPValidationError, InfiniGramCountResponse ]]
79+ Response[Union[InfiniGramCountResponse, RequestValidationError ]]
7780 """
7881
7982 kwargs = _get_kwargs (
@@ -91,9 +94,9 @@ def sync_detailed(
9194def sync (
9295 index : AvailableInfiniGramIndexId ,
9396 * ,
94- client : AuthenticatedClient | Client ,
97+ client : Union [ AuthenticatedClient , Client ] ,
9598 query : str ,
96- ) -> HTTPValidationError | InfiniGramCountResponse | None :
99+ ) -> Optional [ Union [ InfiniGramCountResponse , RequestValidationError ]] :
97100 """Count
98101
99102 Args:
@@ -105,7 +108,7 @@ def sync(
105108 httpx.TimeoutException: If the request takes longer than Client.timeout.
106109
107110 Returns:
108- Union[HTTPValidationError, InfiniGramCountResponse ]
111+ Union[InfiniGramCountResponse, RequestValidationError ]
109112 """
110113
111114 return sync_detailed (
@@ -118,9 +121,9 @@ def sync(
118121async def asyncio_detailed (
119122 index : AvailableInfiniGramIndexId ,
120123 * ,
121- client : AuthenticatedClient | Client ,
124+ client : Union [ AuthenticatedClient , Client ] ,
122125 query : str ,
123- ) -> Response [HTTPValidationError | InfiniGramCountResponse ]:
126+ ) -> Response [Union [ InfiniGramCountResponse , RequestValidationError ] ]:
124127 """Count
125128
126129 Args:
@@ -132,7 +135,7 @@ async def asyncio_detailed(
132135 httpx.TimeoutException: If the request takes longer than Client.timeout.
133136
134137 Returns:
135- Response[Union[HTTPValidationError, InfiniGramCountResponse ]]
138+ Response[Union[InfiniGramCountResponse, RequestValidationError ]]
136139 """
137140
138141 kwargs = _get_kwargs (
@@ -148,9 +151,9 @@ async def asyncio_detailed(
148151async def asyncio (
149152 index : AvailableInfiniGramIndexId ,
150153 * ,
151- client : AuthenticatedClient | Client ,
154+ client : Union [ AuthenticatedClient , Client ] ,
152155 query : str ,
153- ) -> HTTPValidationError | InfiniGramCountResponse | None :
156+ ) -> Optional [ Union [ InfiniGramCountResponse , RequestValidationError ]] :
154157 """Count
155158
156159 Args:
@@ -162,7 +165,7 @@ async def asyncio(
162165 httpx.TimeoutException: If the request takes longer than Client.timeout.
163166
164167 Returns:
165- Union[HTTPValidationError, InfiniGramCountResponse ]
168+ Union[InfiniGramCountResponse, RequestValidationError ]
166169 """
167170
168171 return (
0 commit comments