|
| 1 | +from http import HTTPStatus |
| 2 | +from typing import Any, Optional, Union, cast |
| 3 | + |
| 4 | +import httpx |
| 5 | + |
| 6 | +from ... import errors |
| 7 | +from ...client import AuthenticatedClient, Client |
| 8 | +from ...models.agent_request import AgentRequest |
| 9 | +from ...models.agent_response import AgentResponse |
| 10 | +from ...models.error_response import ErrorResponse |
| 11 | +from ...models.http_validation_error import HTTPValidationError |
| 12 | +from ...types import UNSET, Response, Unset |
| 13 | + |
| 14 | + |
| 15 | +def _get_kwargs( |
| 16 | + graph_id: str, |
| 17 | + *, |
| 18 | + body: AgentRequest, |
| 19 | + authorization: Union[None, Unset, str] = UNSET, |
| 20 | + auth_token: Union[None, Unset, str] = UNSET, |
| 21 | +) -> dict[str, Any]: |
| 22 | + headers: dict[str, Any] = {} |
| 23 | + if not isinstance(authorization, Unset): |
| 24 | + headers["authorization"] = authorization |
| 25 | + |
| 26 | + cookies = {} |
| 27 | + if auth_token is not UNSET: |
| 28 | + cookies["auth-token"] = auth_token |
| 29 | + |
| 30 | + _kwargs: dict[str, Any] = { |
| 31 | + "method": "post", |
| 32 | + "url": f"/v1/{graph_id}/agent", |
| 33 | + "cookies": cookies, |
| 34 | + } |
| 35 | + |
| 36 | + _kwargs["json"] = body.to_dict() |
| 37 | + |
| 38 | + headers["Content-Type"] = "application/json" |
| 39 | + |
| 40 | + _kwargs["headers"] = headers |
| 41 | + return _kwargs |
| 42 | + |
| 43 | + |
| 44 | +def _parse_response( |
| 45 | + *, client: Union[AuthenticatedClient, Client], response: httpx.Response |
| 46 | +) -> Optional[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]: |
| 47 | + if response.status_code == 200: |
| 48 | + response_200 = AgentResponse.from_dict(response.json()) |
| 49 | + |
| 50 | + return response_200 |
| 51 | + if response.status_code == 400: |
| 52 | + response_400 = cast(Any, None) |
| 53 | + return response_400 |
| 54 | + if response.status_code == 402: |
| 55 | + response_402 = cast(Any, None) |
| 56 | + return response_402 |
| 57 | + if response.status_code == 429: |
| 58 | + response_429 = cast(Any, None) |
| 59 | + return response_429 |
| 60 | + if response.status_code == 500: |
| 61 | + response_500 = ErrorResponse.from_dict(response.json()) |
| 62 | + |
| 63 | + return response_500 |
| 64 | + if response.status_code == 422: |
| 65 | + response_422 = HTTPValidationError.from_dict(response.json()) |
| 66 | + |
| 67 | + return response_422 |
| 68 | + if client.raise_on_unexpected_status: |
| 69 | + raise errors.UnexpectedStatus(response.status_code, response.content) |
| 70 | + else: |
| 71 | + return None |
| 72 | + |
| 73 | + |
| 74 | +def _build_response( |
| 75 | + *, client: Union[AuthenticatedClient, Client], response: httpx.Response |
| 76 | +) -> Response[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]: |
| 77 | + return Response( |
| 78 | + status_code=HTTPStatus(response.status_code), |
| 79 | + content=response.content, |
| 80 | + headers=response.headers, |
| 81 | + parsed=_parse_response(client=client, response=response), |
| 82 | + ) |
| 83 | + |
| 84 | + |
| 85 | +def sync_detailed( |
| 86 | + graph_id: str, |
| 87 | + *, |
| 88 | + client: AuthenticatedClient, |
| 89 | + body: AgentRequest, |
| 90 | + authorization: Union[None, Unset, str] = UNSET, |
| 91 | + auth_token: Union[None, Unset, str] = UNSET, |
| 92 | +) -> Response[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]: |
| 93 | + """Auto-select agent for query |
| 94 | +
|
| 95 | + Automatically select the best agent for your query. |
| 96 | +
|
| 97 | + The orchestrator will: |
| 98 | + 1. Enrich context with RAG if enabled |
| 99 | + 2. Evaluate all available agents |
| 100 | + 3. Select the best match based on confidence scores |
| 101 | + 4. Execute the query with the selected agent |
| 102 | +
|
| 103 | + Use this endpoint when you want the system to intelligently route your query. |
| 104 | +
|
| 105 | + Args: |
| 106 | + graph_id (str): |
| 107 | + authorization (Union[None, Unset, str]): |
| 108 | + auth_token (Union[None, Unset, str]): |
| 109 | + body (AgentRequest): Request model for agent interactions. |
| 110 | +
|
| 111 | + Raises: |
| 112 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 113 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 114 | +
|
| 115 | + Returns: |
| 116 | + Response[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]] |
| 117 | + """ |
| 118 | + |
| 119 | + kwargs = _get_kwargs( |
| 120 | + graph_id=graph_id, |
| 121 | + body=body, |
| 122 | + authorization=authorization, |
| 123 | + auth_token=auth_token, |
| 124 | + ) |
| 125 | + |
| 126 | + response = client.get_httpx_client().request( |
| 127 | + **kwargs, |
| 128 | + ) |
| 129 | + |
| 130 | + return _build_response(client=client, response=response) |
| 131 | + |
| 132 | + |
| 133 | +def sync( |
| 134 | + graph_id: str, |
| 135 | + *, |
| 136 | + client: AuthenticatedClient, |
| 137 | + body: AgentRequest, |
| 138 | + authorization: Union[None, Unset, str] = UNSET, |
| 139 | + auth_token: Union[None, Unset, str] = UNSET, |
| 140 | +) -> Optional[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]: |
| 141 | + """Auto-select agent for query |
| 142 | +
|
| 143 | + Automatically select the best agent for your query. |
| 144 | +
|
| 145 | + The orchestrator will: |
| 146 | + 1. Enrich context with RAG if enabled |
| 147 | + 2. Evaluate all available agents |
| 148 | + 3. Select the best match based on confidence scores |
| 149 | + 4. Execute the query with the selected agent |
| 150 | +
|
| 151 | + Use this endpoint when you want the system to intelligently route your query. |
| 152 | +
|
| 153 | + Args: |
| 154 | + graph_id (str): |
| 155 | + authorization (Union[None, Unset, str]): |
| 156 | + auth_token (Union[None, Unset, str]): |
| 157 | + body (AgentRequest): Request model for agent interactions. |
| 158 | +
|
| 159 | + Raises: |
| 160 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 161 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 162 | +
|
| 163 | + Returns: |
| 164 | + Union[AgentResponse, Any, ErrorResponse, HTTPValidationError] |
| 165 | + """ |
| 166 | + |
| 167 | + return sync_detailed( |
| 168 | + graph_id=graph_id, |
| 169 | + client=client, |
| 170 | + body=body, |
| 171 | + authorization=authorization, |
| 172 | + auth_token=auth_token, |
| 173 | + ).parsed |
| 174 | + |
| 175 | + |
| 176 | +async def asyncio_detailed( |
| 177 | + graph_id: str, |
| 178 | + *, |
| 179 | + client: AuthenticatedClient, |
| 180 | + body: AgentRequest, |
| 181 | + authorization: Union[None, Unset, str] = UNSET, |
| 182 | + auth_token: Union[None, Unset, str] = UNSET, |
| 183 | +) -> Response[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]: |
| 184 | + """Auto-select agent for query |
| 185 | +
|
| 186 | + Automatically select the best agent for your query. |
| 187 | +
|
| 188 | + The orchestrator will: |
| 189 | + 1. Enrich context with RAG if enabled |
| 190 | + 2. Evaluate all available agents |
| 191 | + 3. Select the best match based on confidence scores |
| 192 | + 4. Execute the query with the selected agent |
| 193 | +
|
| 194 | + Use this endpoint when you want the system to intelligently route your query. |
| 195 | +
|
| 196 | + Args: |
| 197 | + graph_id (str): |
| 198 | + authorization (Union[None, Unset, str]): |
| 199 | + auth_token (Union[None, Unset, str]): |
| 200 | + body (AgentRequest): Request model for agent interactions. |
| 201 | +
|
| 202 | + Raises: |
| 203 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 204 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 205 | +
|
| 206 | + Returns: |
| 207 | + Response[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]] |
| 208 | + """ |
| 209 | + |
| 210 | + kwargs = _get_kwargs( |
| 211 | + graph_id=graph_id, |
| 212 | + body=body, |
| 213 | + authorization=authorization, |
| 214 | + auth_token=auth_token, |
| 215 | + ) |
| 216 | + |
| 217 | + response = await client.get_async_httpx_client().request(**kwargs) |
| 218 | + |
| 219 | + return _build_response(client=client, response=response) |
| 220 | + |
| 221 | + |
| 222 | +async def asyncio( |
| 223 | + graph_id: str, |
| 224 | + *, |
| 225 | + client: AuthenticatedClient, |
| 226 | + body: AgentRequest, |
| 227 | + authorization: Union[None, Unset, str] = UNSET, |
| 228 | + auth_token: Union[None, Unset, str] = UNSET, |
| 229 | +) -> Optional[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]: |
| 230 | + """Auto-select agent for query |
| 231 | +
|
| 232 | + Automatically select the best agent for your query. |
| 233 | +
|
| 234 | + The orchestrator will: |
| 235 | + 1. Enrich context with RAG if enabled |
| 236 | + 2. Evaluate all available agents |
| 237 | + 3. Select the best match based on confidence scores |
| 238 | + 4. Execute the query with the selected agent |
| 239 | +
|
| 240 | + Use this endpoint when you want the system to intelligently route your query. |
| 241 | +
|
| 242 | + Args: |
| 243 | + graph_id (str): |
| 244 | + authorization (Union[None, Unset, str]): |
| 245 | + auth_token (Union[None, Unset, str]): |
| 246 | + body (AgentRequest): Request model for agent interactions. |
| 247 | +
|
| 248 | + Raises: |
| 249 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 250 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 251 | +
|
| 252 | + Returns: |
| 253 | + Union[AgentResponse, Any, ErrorResponse, HTTPValidationError] |
| 254 | + """ |
| 255 | + |
| 256 | + return ( |
| 257 | + await asyncio_detailed( |
| 258 | + graph_id=graph_id, |
| 259 | + client=client, |
| 260 | + body=body, |
| 261 | + authorization=authorization, |
| 262 | + auth_token=auth_token, |
| 263 | + ) |
| 264 | + ).parsed |
0 commit comments