Skip to content

Commit 7632c50

Browse files
committed
Sync updates from stainless branch: dineshyv/dev
1 parent c94bf4a commit 7632c50

39 files changed

+1074
-568
lines changed

src/llama_stack_client/_client.py

Lines changed: 101 additions & 222 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Generic, TypeVar
4+
5+
from ._models import GenericModel
6+
7+
__all__ = ["DataWrapper"]
8+
9+
_T = TypeVar("_T")
10+
11+
12+
class DataWrapper(GenericModel, Generic[_T]):
13+
data: _T
14+
15+
@staticmethod
16+
def _unwrapper(obj: "DataWrapper[_T]") -> _T:
17+
return obj.data

src/llama_stack_client/resources/datasets.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, Union, Iterable, Optional
5+
from typing import Dict, Type, Union, Iterable, Optional, cast
66

77
import httpx
88

@@ -21,6 +21,7 @@
2121
async_to_raw_response_wrapper,
2222
async_to_streamed_response_wrapper,
2323
)
24+
from .._wrappers import DataWrapper
2425
from .._base_client import make_request_options
2526
from ..types.shared_params.url import URL
2627
from ..types.dataset_list_response import DatasetListResponse
@@ -126,9 +127,13 @@ def list(
126127
return self._get(
127128
"/v1/datasets",
128129
options=make_request_options(
129-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
130+
extra_headers=extra_headers,
131+
extra_query=extra_query,
132+
extra_body=extra_body,
133+
timeout=timeout,
134+
post_parser=DataWrapper[DatasetListResponse]._unwrapper,
130135
),
131-
cast_to=DatasetListResponse,
136+
cast_to=cast(Type[DatasetListResponse], DataWrapper[DatasetListResponse]),
132137
)
133138

134139
def register(
@@ -328,9 +333,13 @@ async def list(
328333
return await self._get(
329334
"/v1/datasets",
330335
options=make_request_options(
331-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
336+
extra_headers=extra_headers,
337+
extra_query=extra_query,
338+
extra_body=extra_body,
339+
timeout=timeout,
340+
post_parser=DataWrapper[DatasetListResponse]._unwrapper,
332341
),
333-
cast_to=DatasetListResponse,
342+
cast_to=cast(Type[DatasetListResponse], DataWrapper[DatasetListResponse]),
334343
)
335344

336345
async def register(

src/llama_stack_client/resources/eval/eval.py

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ def with_streaming_response(self) -> EvalResourceWithStreamingResponse:
6262

6363
def evaluate_rows(
6464
self,
65+
task_id: str,
6566
*,
6667
input_rows: Iterable[Dict[str, Union[bool, float, str, Iterable[object], object, None]]],
6768
scoring_functions: List[str],
6869
task_config: eval_evaluate_rows_params.TaskConfig,
69-
task_id: str,
7070
x_llama_stack_client_version: str | NotGiven = NOT_GIVEN,
7171
x_llama_stack_provider_data: str | NotGiven = NOT_GIVEN,
7272
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -86,6 +86,8 @@ def evaluate_rows(
8686
8787
timeout: Override the client-level default timeout for this request, in seconds
8888
"""
89+
if not task_id:
90+
raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
8991
extra_headers = {
9092
**strip_not_given(
9193
{
@@ -96,13 +98,12 @@ def evaluate_rows(
9698
**(extra_headers or {}),
9799
}
98100
return self._post(
99-
"/v1/eval/evaluate-rows",
101+
f"/v1/eval/tasks/{task_id}/evaluations",
100102
body=maybe_transform(
101103
{
102104
"input_rows": input_rows,
103105
"scoring_functions": scoring_functions,
104106
"task_config": task_config,
105-
"task_id": task_id,
106107
},
107108
eval_evaluate_rows_params.EvalEvaluateRowsParams,
108109
),
@@ -114,9 +115,9 @@ def evaluate_rows(
114115

115116
def run_eval(
116117
self,
118+
task_id: str,
117119
*,
118120
task_config: eval_run_eval_params.TaskConfig,
119-
task_id: str,
120121
x_llama_stack_client_version: str | NotGiven = NOT_GIVEN,
121122
x_llama_stack_provider_data: str | NotGiven = NOT_GIVEN,
122123
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -136,6 +137,8 @@ def run_eval(
136137
137138
timeout: Override the client-level default timeout for this request, in seconds
138139
"""
140+
if not task_id:
141+
raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
139142
extra_headers = {
140143
**strip_not_given(
141144
{
@@ -146,14 +149,8 @@ def run_eval(
146149
**(extra_headers or {}),
147150
}
148151
return self._post(
149-
"/v1/eval/run",
150-
body=maybe_transform(
151-
{
152-
"task_config": task_config,
153-
"task_id": task_id,
154-
},
155-
eval_run_eval_params.EvalRunEvalParams,
156-
),
152+
f"/v1/eval/tasks/{task_id}/jobs",
153+
body=maybe_transform({"task_config": task_config}, eval_run_eval_params.EvalRunEvalParams),
157154
options=make_request_options(
158155
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
159156
),
@@ -187,11 +184,11 @@ def with_streaming_response(self) -> AsyncEvalResourceWithStreamingResponse:
187184

188185
async def evaluate_rows(
189186
self,
187+
task_id: str,
190188
*,
191189
input_rows: Iterable[Dict[str, Union[bool, float, str, Iterable[object], object, None]]],
192190
scoring_functions: List[str],
193191
task_config: eval_evaluate_rows_params.TaskConfig,
194-
task_id: str,
195192
x_llama_stack_client_version: str | NotGiven = NOT_GIVEN,
196193
x_llama_stack_provider_data: str | NotGiven = NOT_GIVEN,
197194
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -211,6 +208,8 @@ async def evaluate_rows(
211208
212209
timeout: Override the client-level default timeout for this request, in seconds
213210
"""
211+
if not task_id:
212+
raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
214213
extra_headers = {
215214
**strip_not_given(
216215
{
@@ -221,13 +220,12 @@ async def evaluate_rows(
221220
**(extra_headers or {}),
222221
}
223222
return await self._post(
224-
"/v1/eval/evaluate-rows",
223+
f"/v1/eval/tasks/{task_id}/evaluations",
225224
body=await async_maybe_transform(
226225
{
227226
"input_rows": input_rows,
228227
"scoring_functions": scoring_functions,
229228
"task_config": task_config,
230-
"task_id": task_id,
231229
},
232230
eval_evaluate_rows_params.EvalEvaluateRowsParams,
233231
),
@@ -239,9 +237,9 @@ async def evaluate_rows(
239237

240238
async def run_eval(
241239
self,
240+
task_id: str,
242241
*,
243242
task_config: eval_run_eval_params.TaskConfig,
244-
task_id: str,
245243
x_llama_stack_client_version: str | NotGiven = NOT_GIVEN,
246244
x_llama_stack_provider_data: str | NotGiven = NOT_GIVEN,
247245
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -261,6 +259,8 @@ async def run_eval(
261259
262260
timeout: Override the client-level default timeout for this request, in seconds
263261
"""
262+
if not task_id:
263+
raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
264264
extra_headers = {
265265
**strip_not_given(
266266
{
@@ -271,14 +271,8 @@ async def run_eval(
271271
**(extra_headers or {}),
272272
}
273273
return await self._post(
274-
"/v1/eval/run",
275-
body=await async_maybe_transform(
276-
{
277-
"task_config": task_config,
278-
"task_id": task_id,
279-
},
280-
eval_run_eval_params.EvalRunEvalParams,
281-
),
274+
f"/v1/eval/tasks/{task_id}/jobs",
275+
body=await async_maybe_transform({"task_config": task_config}, eval_run_eval_params.EvalRunEvalParams),
282276
options=make_request_options(
283277
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
284278
),

0 commit comments

Comments
 (0)