Skip to content
Merged
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
12 changes: 8 additions & 4 deletions src/everyrow/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from everyrow.generated.client import AuthenticatedClient
from everyrow.generated.models.error_response import ErrorResponse
from everyrow.generated.models.http_validation_error import HTTPValidationError
from everyrow.generated.models.insufficient_balance_error import (
InsufficientBalanceError,
from everyrow.generated.models.insufficient_balance_response import (
InsufficientBalanceResponse,
)


Expand Down Expand Up @@ -35,13 +35,17 @@ def create_client() -> AuthenticatedClient:


def handle_response[T](
response: T | ErrorResponse | HTTPValidationError | InsufficientBalanceError | None,
response: T
| ErrorResponse
| HTTPValidationError
| InsufficientBalanceResponse
| None,
) -> T:
if isinstance(response, ErrorResponse):
raise EveryrowError(response.message)
if isinstance(response, HTTPValidationError):
raise EveryrowError(response.detail)
if isinstance(response, InsufficientBalanceError):
if isinstance(response, InsufficientBalanceResponse):
raise EveryrowError(response.message)
if response is None:
raise EveryrowError("Unknown error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ...client import AuthenticatedClient, Client
from ...models.agent_map_operation import AgentMapOperation
from ...models.error_response import ErrorResponse
from ...models.insufficient_balance_error import InsufficientBalanceError
from ...models.insufficient_balance_response import InsufficientBalanceResponse
from ...models.operation_response import OperationResponse
from ...types import UNSET, Response, Unset

Expand Down Expand Up @@ -36,14 +36,14 @@ def _get_kwargs(

def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> ErrorResponse | InsufficientBalanceError | OperationResponse | None:
) -> ErrorResponse | InsufficientBalanceResponse | OperationResponse | None:
if response.status_code == 200:
response_200 = OperationResponse.from_dict(response.json())

return response_200

if response.status_code == 402:
response_402 = InsufficientBalanceError.from_dict(response.json())
response_402 = InsufficientBalanceResponse.from_dict(response.json())

return response_402

Expand All @@ -60,7 +60,7 @@ def _parse_response(

def _build_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[ErrorResponse | InsufficientBalanceError | OperationResponse]:
) -> Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -74,7 +74,7 @@ def sync_detailed(
client: AuthenticatedClient,
body: AgentMapOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> Response[ErrorResponse | InsufficientBalanceError | OperationResponse]:
) -> Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]:
"""Parallel AI research agents

Run an AI agent on each row in parallel to perform research and generate responses.
Expand All @@ -94,7 +94,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[ErrorResponse | InsufficientBalanceError | OperationResponse]
Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]
"""

kwargs = _get_kwargs(
Expand All @@ -114,7 +114,7 @@ def sync(
client: AuthenticatedClient,
body: AgentMapOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> ErrorResponse | InsufficientBalanceError | OperationResponse | None:
) -> ErrorResponse | InsufficientBalanceResponse | OperationResponse | None:
"""Parallel AI research agents

Run an AI agent on each row in parallel to perform research and generate responses.
Expand All @@ -134,7 +134,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
ErrorResponse | InsufficientBalanceError | OperationResponse
ErrorResponse | InsufficientBalanceResponse | OperationResponse
"""

return sync_detailed(
Expand All @@ -149,7 +149,7 @@ async def asyncio_detailed(
client: AuthenticatedClient,
body: AgentMapOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> Response[ErrorResponse | InsufficientBalanceError | OperationResponse]:
) -> Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]:
"""Parallel AI research agents

Run an AI agent on each row in parallel to perform research and generate responses.
Expand All @@ -169,7 +169,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[ErrorResponse | InsufficientBalanceError | OperationResponse]
Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]
"""

kwargs = _get_kwargs(
Expand All @@ -187,7 +187,7 @@ async def asyncio(
client: AuthenticatedClient,
body: AgentMapOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> ErrorResponse | InsufficientBalanceError | OperationResponse | None:
) -> ErrorResponse | InsufficientBalanceResponse | OperationResponse | None:
"""Parallel AI research agents

Run an AI agent on each row in parallel to perform research and generate responses.
Expand All @@ -207,7 +207,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
ErrorResponse | InsufficientBalanceError | OperationResponse
ErrorResponse | InsufficientBalanceResponse | OperationResponse
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ...client import AuthenticatedClient, Client
from ...models.classify_operation import ClassifyOperation
from ...models.error_response import ErrorResponse
from ...models.insufficient_balance_error import InsufficientBalanceError
from ...models.insufficient_balance_response import InsufficientBalanceResponse
from ...models.operation_response import OperationResponse
from ...types import UNSET, Response, Unset

Expand Down Expand Up @@ -36,14 +36,14 @@ def _get_kwargs(

def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> ErrorResponse | InsufficientBalanceError | OperationResponse | None:
) -> ErrorResponse | InsufficientBalanceResponse | OperationResponse | None:
if response.status_code == 200:
response_200 = OperationResponse.from_dict(response.json())

return response_200

if response.status_code == 402:
response_402 = InsufficientBalanceError.from_dict(response.json())
response_402 = InsufficientBalanceResponse.from_dict(response.json())

return response_402

Expand All @@ -60,7 +60,7 @@ def _parse_response(

def _build_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[ErrorResponse | InsufficientBalanceError | OperationResponse]:
) -> Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -74,7 +74,7 @@ def sync_detailed(
client: AuthenticatedClient,
body: ClassifyOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> Response[ErrorResponse | InsufficientBalanceError | OperationResponse]:
) -> Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]:
"""Classify rows into categories

Use AI to classify each row into one of the provided categories.
Expand All @@ -88,7 +88,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[ErrorResponse | InsufficientBalanceError | OperationResponse]
Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]
"""

kwargs = _get_kwargs(
Expand All @@ -108,7 +108,7 @@ def sync(
client: AuthenticatedClient,
body: ClassifyOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> ErrorResponse | InsufficientBalanceError | OperationResponse | None:
) -> ErrorResponse | InsufficientBalanceResponse | OperationResponse | None:
"""Classify rows into categories

Use AI to classify each row into one of the provided categories.
Expand All @@ -122,7 +122,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
ErrorResponse | InsufficientBalanceError | OperationResponse
ErrorResponse | InsufficientBalanceResponse | OperationResponse
"""

return sync_detailed(
Expand All @@ -137,7 +137,7 @@ async def asyncio_detailed(
client: AuthenticatedClient,
body: ClassifyOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> Response[ErrorResponse | InsufficientBalanceError | OperationResponse]:
) -> Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]:
"""Classify rows into categories

Use AI to classify each row into one of the provided categories.
Expand All @@ -151,7 +151,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[ErrorResponse | InsufficientBalanceError | OperationResponse]
Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]
"""

kwargs = _get_kwargs(
Expand All @@ -169,7 +169,7 @@ async def asyncio(
client: AuthenticatedClient,
body: ClassifyOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> ErrorResponse | InsufficientBalanceError | OperationResponse | None:
) -> ErrorResponse | InsufficientBalanceResponse | OperationResponse | None:
"""Classify rows into categories

Use AI to classify each row into one of the provided categories.
Expand All @@ -183,7 +183,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
ErrorResponse | InsufficientBalanceError | OperationResponse
ErrorResponse | InsufficientBalanceResponse | OperationResponse
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ...client import AuthenticatedClient, Client
from ...models.dedupe_operation import DedupeOperation
from ...models.error_response import ErrorResponse
from ...models.insufficient_balance_error import InsufficientBalanceError
from ...models.insufficient_balance_response import InsufficientBalanceResponse
from ...models.operation_response import OperationResponse
from ...types import UNSET, Response, Unset

Expand Down Expand Up @@ -36,14 +36,14 @@ def _get_kwargs(

def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> ErrorResponse | InsufficientBalanceError | OperationResponse | None:
) -> ErrorResponse | InsufficientBalanceResponse | OperationResponse | None:
if response.status_code == 200:
response_200 = OperationResponse.from_dict(response.json())

return response_200

if response.status_code == 402:
response_402 = InsufficientBalanceError.from_dict(response.json())
response_402 = InsufficientBalanceResponse.from_dict(response.json())

return response_402

Expand All @@ -60,7 +60,7 @@ def _parse_response(

def _build_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[ErrorResponse | InsufficientBalanceError | OperationResponse]:
) -> Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -74,7 +74,7 @@ def sync_detailed(
client: AuthenticatedClient,
body: DedupeOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> Response[ErrorResponse | InsufficientBalanceError | OperationResponse]:
) -> Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]:
"""AI-powered deduplication

Use AI to identify and remove duplicate rows based on the equivalence relation.
Expand All @@ -88,7 +88,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[ErrorResponse | InsufficientBalanceError | OperationResponse]
Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]
"""

kwargs = _get_kwargs(
Expand All @@ -108,7 +108,7 @@ def sync(
client: AuthenticatedClient,
body: DedupeOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> ErrorResponse | InsufficientBalanceError | OperationResponse | None:
) -> ErrorResponse | InsufficientBalanceResponse | OperationResponse | None:
"""AI-powered deduplication

Use AI to identify and remove duplicate rows based on the equivalence relation.
Expand All @@ -122,7 +122,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
ErrorResponse | InsufficientBalanceError | OperationResponse
ErrorResponse | InsufficientBalanceResponse | OperationResponse
"""

return sync_detailed(
Expand All @@ -137,7 +137,7 @@ async def asyncio_detailed(
client: AuthenticatedClient,
body: DedupeOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> Response[ErrorResponse | InsufficientBalanceError | OperationResponse]:
) -> Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]:
"""AI-powered deduplication

Use AI to identify and remove duplicate rows based on the equivalence relation.
Expand All @@ -151,7 +151,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[ErrorResponse | InsufficientBalanceError | OperationResponse]
Response[ErrorResponse | InsufficientBalanceResponse | OperationResponse]
"""

kwargs = _get_kwargs(
Expand All @@ -169,7 +169,7 @@ async def asyncio(
client: AuthenticatedClient,
body: DedupeOperation,
x_cohort_source: None | str | Unset = UNSET,
) -> ErrorResponse | InsufficientBalanceError | OperationResponse | None:
) -> ErrorResponse | InsufficientBalanceResponse | OperationResponse | None:
"""AI-powered deduplication

Use AI to identify and remove duplicate rows based on the equivalence relation.
Expand All @@ -183,7 +183,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
ErrorResponse | InsufficientBalanceError | OperationResponse
ErrorResponse | InsufficientBalanceResponse | OperationResponse
"""

return (
Expand Down
Loading