Skip to content

Commit 1985b7d

Browse files
fix(api): add missing file rank enum + more metadata (openai#2164)
1 parent 346561f commit 1985b7d

File tree

7 files changed

+71
-4
lines changed

7 files changed

+71
-4
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 30 additions & 1 deletion
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
@@ -27,6 +27,7 @@
2727
from ....pagination import SyncCursorPage, AsyncCursorPage
2828
from ...._base_client import AsyncPaginator, make_request_options
2929
from ....types.fine_tuning import job_list_params, job_create_params, job_list_events_params
30+
from ....types.shared_params.metadata import Metadata
3031
from ....types.fine_tuning.fine_tuning_job import FineTuningJob
3132
from ....types.fine_tuning.fine_tuning_job_event import FineTuningJobEvent
3233

@@ -64,6 +65,7 @@ def create(
6465
training_file: str,
6566
hyperparameters: job_create_params.Hyperparameters | NotGiven = NOT_GIVEN,
6667
integrations: Optional[Iterable[job_create_params.Integration]] | NotGiven = NOT_GIVEN,
68+
metadata: Optional[Metadata] | NotGiven = NOT_GIVEN,
6769
method: job_create_params.Method | NotGiven = NOT_GIVEN,
6870
seed: Optional[int] | NotGiven = NOT_GIVEN,
6971
suffix: Optional[str] | NotGiven = NOT_GIVEN,
@@ -111,6 +113,13 @@ def create(
111113
112114
integrations: A list of integrations to enable for your fine-tuning job.
113115
116+
metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
117+
for storing additional information about the object in a structured format, and
118+
querying for objects via API or the dashboard.
119+
120+
Keys are strings with a maximum length of 64 characters. Values are strings with
121+
a maximum length of 512 characters.
122+
114123
method: The method used for fine-tuning.
115124
116125
seed: The seed controls the reproducibility of the job. Passing in the same seed and
@@ -152,6 +161,7 @@ def create(
152161
"training_file": training_file,
153162
"hyperparameters": hyperparameters,
154163
"integrations": integrations,
164+
"metadata": metadata,
155165
"method": method,
156166
"seed": seed,
157167
"suffix": suffix,
@@ -205,6 +215,7 @@ def list(
205215
*,
206216
after: str | NotGiven = NOT_GIVEN,
207217
limit: int | NotGiven = NOT_GIVEN,
218+
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
208219
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
209220
# The extra values given here take precedence over values defined on the client or passed to this method.
210221
extra_headers: Headers | None = None,
@@ -220,6 +231,9 @@ def list(
220231
221232
limit: Number of fine-tuning jobs to retrieve.
222233
234+
metadata: Optional metadata filter. To filter, use the syntax `metadata[k]=v`.
235+
Alternatively, set `metadata=null` to indicate no metadata.
236+
223237
extra_headers: Send extra headers
224238
225239
extra_query: Add additional query parameters to the request
@@ -240,6 +254,7 @@ def list(
240254
{
241255
"after": after,
242256
"limit": limit,
257+
"metadata": metadata,
243258
},
244259
job_list_params.JobListParams,
245260
),
@@ -362,6 +377,7 @@ async def create(
362377
training_file: str,
363378
hyperparameters: job_create_params.Hyperparameters | NotGiven = NOT_GIVEN,
364379
integrations: Optional[Iterable[job_create_params.Integration]] | NotGiven = NOT_GIVEN,
380+
metadata: Optional[Metadata] | NotGiven = NOT_GIVEN,
365381
method: job_create_params.Method | NotGiven = NOT_GIVEN,
366382
seed: Optional[int] | NotGiven = NOT_GIVEN,
367383
suffix: Optional[str] | NotGiven = NOT_GIVEN,
@@ -409,6 +425,13 @@ async def create(
409425
410426
integrations: A list of integrations to enable for your fine-tuning job.
411427
428+
metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
429+
for storing additional information about the object in a structured format, and
430+
querying for objects via API or the dashboard.
431+
432+
Keys are strings with a maximum length of 64 characters. Values are strings with
433+
a maximum length of 512 characters.
434+
412435
method: The method used for fine-tuning.
413436
414437
seed: The seed controls the reproducibility of the job. Passing in the same seed and
@@ -450,6 +473,7 @@ async def create(
450473
"training_file": training_file,
451474
"hyperparameters": hyperparameters,
452475
"integrations": integrations,
476+
"metadata": metadata,
453477
"method": method,
454478
"seed": seed,
455479
"suffix": suffix,
@@ -503,6 +527,7 @@ def list(
503527
*,
504528
after: str | NotGiven = NOT_GIVEN,
505529
limit: int | NotGiven = NOT_GIVEN,
530+
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
506531
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
507532
# The extra values given here take precedence over values defined on the client or passed to this method.
508533
extra_headers: Headers | None = None,
@@ -518,6 +543,9 @@ def list(
518543
519544
limit: Number of fine-tuning jobs to retrieve.
520545
546+
metadata: Optional metadata filter. To filter, use the syntax `metadata[k]=v`.
547+
Alternatively, set `metadata=null` to indicate no metadata.
548+
521549
extra_headers: Send extra headers
522550
523551
extra_query: Add additional query parameters to the request
@@ -538,6 +566,7 @@ def list(
538566
{
539567
"after": after,
540568
"limit": limit,
569+
"metadata": metadata,
541570
},
542571
job_list_params.JobListParams,
543572
),

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

Lines changed: 5 additions & 2 deletions
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

Lines changed: 11 additions & 0 deletions
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

Lines changed: 12 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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="after",
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="after",
389392
limit=0,
393+
metadata={"foo": "string"},
390394
)
391395
assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"])
392396

0 commit comments

Comments
 (0)