Skip to content

Commit cdd99bd

Browse files
committed
chore: update sdk
1 parent cedbd3a commit cdd99bd

8 files changed

Lines changed: 765 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Contains endpoint functions for accessing the API"""
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
4+
import httpx
5+
6+
from ... import errors
7+
from ...client import AuthenticatedClient, Client
8+
from ...models.chat_request import ChatRequest
9+
from ...models.http_validation_error import HTTPValidationError
10+
from ...types import Response
11+
12+
13+
def _get_kwargs(
14+
*,
15+
body: ChatRequest,
16+
) -> dict[str, Any]:
17+
headers: dict[str, Any] = {}
18+
19+
_kwargs: dict[str, Any] = {
20+
"method": "post",
21+
"url": "/v1/chat/",
22+
}
23+
24+
_kwargs["json"] = body.to_dict()
25+
26+
headers["Content-Type"] = "application/json"
27+
28+
_kwargs["headers"] = headers
29+
return _kwargs
30+
31+
32+
def _parse_response(
33+
*, client: AuthenticatedClient | Client, response: httpx.Response
34+
) -> Any | HTTPValidationError | None:
35+
if response.status_code == 200:
36+
response_200 = response.json()
37+
return response_200
38+
39+
if response.status_code == 422:
40+
response_422 = HTTPValidationError.from_dict(response.json())
41+
42+
return response_422
43+
44+
if client.raise_on_unexpected_status:
45+
raise errors.UnexpectedStatus(response.status_code, response.content)
46+
else:
47+
return None
48+
49+
50+
def _build_response(
51+
*, client: AuthenticatedClient | Client, response: httpx.Response
52+
) -> Response[Any | HTTPValidationError]:
53+
return Response(
54+
status_code=HTTPStatus(response.status_code),
55+
content=response.content,
56+
headers=response.headers,
57+
parsed=_parse_response(client=client, response=response),
58+
)
59+
60+
61+
def sync_detailed(
62+
*,
63+
client: AuthenticatedClient,
64+
body: ChatRequest,
65+
) -> Response[Any | HTTPValidationError]:
66+
"""Handle Chat
67+
68+
Args:
69+
body (ChatRequest):
70+
71+
Raises:
72+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
73+
httpx.TimeoutException: If the request takes longer than Client.timeout.
74+
75+
Returns:
76+
Response[Any | HTTPValidationError]
77+
"""
78+
79+
kwargs = _get_kwargs(
80+
body=body,
81+
)
82+
83+
response = client.get_httpx_client().request(
84+
**kwargs,
85+
)
86+
87+
return _build_response(client=client, response=response)
88+
89+
90+
def sync(
91+
*,
92+
client: AuthenticatedClient,
93+
body: ChatRequest,
94+
) -> Any | HTTPValidationError | None:
95+
"""Handle Chat
96+
97+
Args:
98+
body (ChatRequest):
99+
100+
Raises:
101+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
102+
httpx.TimeoutException: If the request takes longer than Client.timeout.
103+
104+
Returns:
105+
Any | HTTPValidationError
106+
"""
107+
108+
return sync_detailed(
109+
client=client,
110+
body=body,
111+
).parsed
112+
113+
114+
async def asyncio_detailed(
115+
*,
116+
client: AuthenticatedClient,
117+
body: ChatRequest,
118+
) -> Response[Any | HTTPValidationError]:
119+
"""Handle Chat
120+
121+
Args:
122+
body (ChatRequest):
123+
124+
Raises:
125+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
126+
httpx.TimeoutException: If the request takes longer than Client.timeout.
127+
128+
Returns:
129+
Response[Any | HTTPValidationError]
130+
"""
131+
132+
kwargs = _get_kwargs(
133+
body=body,
134+
)
135+
136+
response = await client.get_async_httpx_client().request(**kwargs)
137+
138+
return _build_response(client=client, response=response)
139+
140+
141+
async def asyncio(
142+
*,
143+
client: AuthenticatedClient,
144+
body: ChatRequest,
145+
) -> Any | HTTPValidationError | None:
146+
"""Handle Chat
147+
148+
Args:
149+
body (ChatRequest):
150+
151+
Raises:
152+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
153+
httpx.TimeoutException: If the request takes longer than Client.timeout.
154+
155+
Returns:
156+
Any | HTTPValidationError
157+
"""
158+
159+
return (
160+
await asyncio_detailed(
161+
client=client,
162+
body=body,
163+
)
164+
).parsed

app/desktop/studio_server/api_client/kiln_ai_server_client/models/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
BodyStartPromptOptimizationJobV1JobsPromptOptimizationJobStartPost,
88
)
99
from .body_start_sample_job_v1_jobs_sample_job_start_post import BodyStartSampleJobV1JobsSampleJobStartPost
10+
from .chat_request import ChatRequest
1011
from .check_entitlements_v1_check_entitlements_get_response_check_entitlements_v1_check_entitlements_get import (
1112
CheckEntitlementsV1CheckEntitlementsGetResponseCheckEntitlementsV1CheckEntitlementsGet,
1213
)
1314
from .check_model_supported_response import CheckModelSupportedResponse
1415
from .clarify_spec_input import ClarifySpecInput
1516
from .clarify_spec_output import ClarifySpecOutput
17+
from .client_message import ClientMessage
18+
from .client_message_part import ClientMessagePart
1619
from .examples_for_feedback_item import ExamplesForFeedbackItem
1720
from .examples_with_feedback_item import ExamplesWithFeedbackItem
1821
from .generate_batch_input import GenerateBatchInput
@@ -51,6 +54,8 @@
5154
from .synthetic_data_generation_step_config_input import SyntheticDataGenerationStepConfigInput
5255
from .task_info import TaskInfo
5356
from .task_metadata import TaskMetadata
57+
from .tool_invocation import ToolInvocation
58+
from .tool_invocation_state import ToolInvocationState
5459
from .validation_error import ValidationError
5560

5661
__all__ = (
@@ -59,10 +64,13 @@
5964
"ApiKeyVerificationResult",
6065
"BodyStartPromptOptimizationJobV1JobsPromptOptimizationJobStartPost",
6166
"BodyStartSampleJobV1JobsSampleJobStartPost",
67+
"ChatRequest",
6268
"CheckEntitlementsV1CheckEntitlementsGetResponseCheckEntitlementsV1CheckEntitlementsGet",
6369
"CheckModelSupportedResponse",
6470
"ClarifySpecInput",
6571
"ClarifySpecOutput",
72+
"ClientMessage",
73+
"ClientMessagePart",
6674
"ExamplesForFeedbackItem",
6775
"ExamplesWithFeedbackItem",
6876
"GenerateBatchInput",
@@ -101,5 +109,7 @@
101109
"SyntheticDataGenerationStepConfigInput",
102110
"TaskInfo",
103111
"TaskMetadata",
112+
"ToolInvocation",
113+
"ToolInvocationState",
104114
"ValidationError",
105115
)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
from __future__ import annotations
2+
3+
from collections.abc import Mapping
4+
from typing import TYPE_CHECKING, Any, TypeVar, cast
5+
6+
from attrs import define as _attrs_define
7+
from attrs import field as _attrs_field
8+
9+
from ..types import UNSET, Unset
10+
11+
if TYPE_CHECKING:
12+
from ..models.client_message import ClientMessage
13+
14+
15+
T = TypeVar("T", bound="ChatRequest")
16+
17+
18+
@_attrs_define
19+
class ChatRequest:
20+
"""
21+
Attributes:
22+
messages (list[ClientMessage]):
23+
task_id (None | str | Unset):
24+
"""
25+
26+
messages: list[ClientMessage]
27+
task_id: None | str | Unset = UNSET
28+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
29+
30+
def to_dict(self) -> dict[str, Any]:
31+
messages = []
32+
for messages_item_data in self.messages:
33+
messages_item = messages_item_data.to_dict()
34+
messages.append(messages_item)
35+
36+
task_id: None | str | Unset
37+
if isinstance(self.task_id, Unset):
38+
task_id = UNSET
39+
else:
40+
task_id = self.task_id
41+
42+
field_dict: dict[str, Any] = {}
43+
field_dict.update(self.additional_properties)
44+
field_dict.update(
45+
{
46+
"messages": messages,
47+
}
48+
)
49+
if task_id is not UNSET:
50+
field_dict["task_id"] = task_id
51+
52+
return field_dict
53+
54+
@classmethod
55+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
56+
from ..models.client_message import ClientMessage
57+
58+
d = dict(src_dict)
59+
messages = []
60+
_messages = d.pop("messages")
61+
for messages_item_data in _messages:
62+
messages_item = ClientMessage.from_dict(messages_item_data)
63+
64+
messages.append(messages_item)
65+
66+
def _parse_task_id(data: object) -> None | str | Unset:
67+
if data is None:
68+
return data
69+
if isinstance(data, Unset):
70+
return data
71+
return cast(None | str | Unset, data)
72+
73+
task_id = _parse_task_id(d.pop("task_id", UNSET))
74+
75+
chat_request = cls(
76+
messages=messages,
77+
task_id=task_id,
78+
)
79+
80+
chat_request.additional_properties = d
81+
return chat_request
82+
83+
@property
84+
def additional_keys(self) -> list[str]:
85+
return list(self.additional_properties.keys())
86+
87+
def __getitem__(self, key: str) -> Any:
88+
return self.additional_properties[key]
89+
90+
def __setitem__(self, key: str, value: Any) -> None:
91+
self.additional_properties[key] = value
92+
93+
def __delitem__(self, key: str) -> None:
94+
del self.additional_properties[key]
95+
96+
def __contains__(self, key: str) -> bool:
97+
return key in self.additional_properties

0 commit comments

Comments
 (0)