Skip to content

Commit 5608d64

Browse files
fix(api): add missing file rank enum + more metadata (#2164)
1 parent d6bb8c1 commit 5608d64

File tree

7 files changed

+71
-4
lines changed

7 files changed

+71
-4
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 74
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-5d30684c3118d049682ea30cdb4dbef39b97d51667da484689193dc40162af32.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b524aed1c2c5c928aa4e2c546f5dbb364e7b4d5027daf05e42e210b05a97c3c6.yml

src/openai/resources/fine_tuning/jobs/jobs.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Union, Iterable, Optional
5+
from typing import Dict, Union, Iterable, Optional
66
from typing_extensions import Literal
77

88
import httpx
@@ -30,6 +30,7 @@
3030
make_request_options,
3131
)
3232
from ....types.fine_tuning import job_list_params, job_create_params, job_list_events_params
33+
from ....types.shared_params.metadata import Metadata
3334
from ....types.fine_tuning.fine_tuning_job import FineTuningJob
3435
from ....types.fine_tuning.fine_tuning_job_event import FineTuningJobEvent
3536

@@ -67,6 +68,7 @@ def create(
6768
training_file: str,
6869
hyperparameters: job_create_params.Hyperparameters | NotGiven = NOT_GIVEN,
6970
integrations: Optional[Iterable[job_create_params.Integration]] | NotGiven = NOT_GIVEN,
71+
metadata: Optional[Metadata] | NotGiven = NOT_GIVEN,
7072
method: job_create_params.Method | NotGiven = NOT_GIVEN,
7173
seed: Optional[int] | NotGiven = NOT_GIVEN,
7274
suffix: Optional[str] | NotGiven = NOT_GIVEN,
@@ -114,6 +116,13 @@ def create(
114116
115117
integrations: A list of integrations to enable for your fine-tuning job.
116118
119+
metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
120+
for storing additional information about the object in a structured format, and
121+
querying for objects via API or the dashboard.
122+
123+
Keys are strings with a maximum length of 64 characters. Values are strings with
124+
a maximum length of 512 characters.
125+
117126
method: The method used for fine-tuning.
118127
119128
seed: The seed controls the reproducibility of the job. Passing in the same seed and
@@ -155,6 +164,7 @@ def create(
155164
"training_file": training_file,
156165
"hyperparameters": hyperparameters,
157166
"integrations": integrations,
167+
"metadata": metadata,
158168
"method": method,
159169
"seed": seed,
160170
"suffix": suffix,
@@ -208,6 +218,7 @@ def list(
208218
*,
209219
after: str | NotGiven = NOT_GIVEN,
210220
limit: int | NotGiven = NOT_GIVEN,
221+
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
211222
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
212223
# The extra values given here take precedence over values defined on the client or passed to this method.
213224
extra_headers: Headers | None = None,
@@ -223,6 +234,9 @@ def list(
223234
224235
limit: Number of fine-tuning jobs to retrieve.
225236
237+
metadata: Optional metadata filter. To filter, use the syntax `metadata[k]=v`.
238+
Alternatively, set `metadata=null` to indicate no metadata.
239+
226240
extra_headers: Send extra headers
227241
228242
extra_query: Add additional query parameters to the request
@@ -243,6 +257,7 @@ def list(
243257
{
244258
"after": after,
245259
"limit": limit,
260+
"metadata": metadata,
246261
},
247262
job_list_params.JobListParams,
248263
),
@@ -365,6 +380,7 @@ async def create(
365380
training_file: str,
366381
hyperparameters: job_create_params.Hyperparameters | NotGiven = NOT_GIVEN,
367382
integrations: Optional[Iterable[job_create_params.Integration]] | NotGiven = NOT_GIVEN,
383+
metadata: Optional[Metadata] | NotGiven = NOT_GIVEN,
368384
method: job_create_params.Method | NotGiven = NOT_GIVEN,
369385
seed: Optional[int] | NotGiven = NOT_GIVEN,
370386
suffix: Optional[str] | NotGiven = NOT_GIVEN,
@@ -412,6 +428,13 @@ async def create(
412428
413429
integrations: A list of integrations to enable for your fine-tuning job.
414430
431+
metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
432+
for storing additional information about the object in a structured format, and
433+
querying for objects via API or the dashboard.
434+
435+
Keys are strings with a maximum length of 64 characters. Values are strings with
436+
a maximum length of 512 characters.
437+
415438
method: The method used for fine-tuning.
416439
417440
seed: The seed controls the reproducibility of the job. Passing in the same seed and
@@ -453,6 +476,7 @@ async def create(
453476
"training_file": training_file,
454477
"hyperparameters": hyperparameters,
455478
"integrations": integrations,
479+
"metadata": metadata,
456480
"method": method,
457481
"seed": seed,
458482
"suffix": suffix,
@@ -506,6 +530,7 @@ def list(
506530
*,
507531
after: str | NotGiven = NOT_GIVEN,
508532
limit: int | NotGiven = NOT_GIVEN,
533+
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
509534
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
510535
# The extra values given here take precedence over values defined on the client or passed to this method.
511536
extra_headers: Headers | None = None,
@@ -521,6 +546,9 @@ def list(
521546
522547
limit: Number of fine-tuning jobs to retrieve.
523548
549+
metadata: Optional metadata filter. To filter, use the syntax `metadata[k]=v`.
550+
Alternatively, set `metadata=null` to indicate no metadata.
551+
524552
extra_headers: Send extra headers
525553
526554
extra_query: Add additional query parameters to the request
@@ -541,6 +569,7 @@ def list(
541569
{
542570
"after": after,
543571
"limit": limit,
572+
"metadata": metadata,
544573
},
545574
job_list_params.JobListParams,
546575
),

src/openai/types/beta/threads/runs/file_search_tool_call.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616

1717
class FileSearchRankingOptions(BaseModel):
18-
ranker: Literal["default_2024_08_21"]
19-
"""The ranker used for the file search."""
18+
ranker: Literal["auto", "default_2024_08_21"]
19+
"""The ranker to use for the file search.
20+
21+
If not specified will use the `auto` ranker.
22+
"""
2023

2124
score_threshold: float
2225
"""The score threshold for the file search.

src/openai/types/fine_tuning/fine_tuning_job.py

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing_extensions import Literal
55

66
from ..._models import BaseModel
7+
from ..shared.metadata import Metadata
78
from .fine_tuning_job_wandb_integration_object import FineTuningJobWandbIntegrationObject
89

910
__all__ = [
@@ -208,5 +209,15 @@ class FineTuningJob(BaseModel):
208209
integrations: Optional[List[FineTuningJobWandbIntegrationObject]] = None
209210
"""A list of integrations to enable for this fine-tuning job."""
210211

212+
metadata: Optional[Metadata] = None
213+
"""Set of 16 key-value pairs that can be attached to an object.
214+
215+
This can be useful for storing additional information about the object in a
216+
structured format, and querying for objects via API or the dashboard.
217+
218+
Keys are strings with a maximum length of 64 characters. Values are strings with
219+
a maximum length of 512 characters.
220+
"""
221+
211222
method: Optional[Method] = None
212223
"""The method used for fine-tuning."""

src/openai/types/fine_tuning/job_create_params.py

+12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from typing import List, Union, Iterable, Optional
66
from typing_extensions import Literal, Required, TypedDict
77

8+
from ..shared_params.metadata import Metadata
9+
810
__all__ = [
911
"JobCreateParams",
1012
"Hyperparameters",
@@ -55,6 +57,16 @@ class JobCreateParams(TypedDict, total=False):
5557
integrations: Optional[Iterable[Integration]]
5658
"""A list of integrations to enable for your fine-tuning job."""
5759

60+
metadata: Optional[Metadata]
61+
"""Set of 16 key-value pairs that can be attached to an object.
62+
63+
This can be useful for storing additional information about the object in a
64+
structured format, and querying for objects via API or the dashboard.
65+
66+
Keys are strings with a maximum length of 64 characters. Values are strings with
67+
a maximum length of 512 characters.
68+
"""
69+
5870
method: Method
5971
"""The method used for fine-tuning."""
6072

src/openai/types/fine_tuning/job_list_params.py

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from typing import Dict, Optional
56
from typing_extensions import TypedDict
67

78
__all__ = ["JobListParams"]
@@ -13,3 +14,10 @@ class JobListParams(TypedDict, total=False):
1314

1415
limit: int
1516
"""Number of fine-tuning jobs to retrieve."""
17+
18+
metadata: Optional[Dict[str, str]]
19+
"""Optional metadata filter.
20+
21+
To filter, use the syntax `metadata[k]=v`. Alternatively, set `metadata=null` to
22+
indicate no metadata.
23+
"""

tests/api_resources/fine_tuning/test_jobs.py

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def test_method_create_with_all_params(self, client: OpenAI) -> None:
5050
},
5151
}
5252
],
53+
metadata={"foo": "string"},
5354
method={
5455
"dpo": {
5556
"hyperparameters": {
@@ -148,6 +149,7 @@ def test_method_list_with_all_params(self, client: OpenAI) -> None:
148149
job = client.fine_tuning.jobs.list(
149150
after="string",
150151
limit=0,
152+
metadata={"foo": "string"},
151153
)
152154
assert_matches_type(SyncCursorPage[FineTuningJob], job, path=["response"])
153155

@@ -289,6 +291,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) ->
289291
},
290292
}
291293
],
294+
metadata={"foo": "string"},
292295
method={
293296
"dpo": {
294297
"hyperparameters": {
@@ -387,6 +390,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> N
387390
job = await async_client.fine_tuning.jobs.list(
388391
after="string",
389392
limit=0,
393+
metadata={"foo": "string"},
390394
)
391395
assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"])
392396

0 commit comments

Comments
 (0)