Skip to content

Commit 71fdd98

Browse files
feat(api): add file search result details to run steps (#1681)
1 parent c21c7a3 commit 71fdd98

File tree

14 files changed

+322
-16
lines changed

14 files changed

+322
-16
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: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-8e569a23f15a599dd4aee8a53431962bcba4985ab6cfb66c53c1434b99026b37.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-1dbac0e95bdb5a89a0dd3d93265475a378214551b7d8c22862928e0d87ace94b.yml

api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ from openai.types.beta.threads.runs import (
349349
RunStepDelta,
350350
RunStepDeltaEvent,
351351
RunStepDeltaMessageDelta,
352+
RunStepInclude,
352353
ToolCall,
353354
ToolCallDelta,
354355
ToolCallDeltaObject,
@@ -358,7 +359,7 @@ from openai.types.beta.threads.runs import (
358359

359360
Methods:
360361

361-
- <code title="get /threads/{thread_id}/runs/{run_id}/steps/{step_id}">client.beta.threads.runs.steps.<a href="./src/openai/resources/beta/threads/runs/steps.py">retrieve</a>(step_id, \*, thread_id, run_id) -> <a href="./src/openai/types/beta/threads/runs/run_step.py">RunStep</a></code>
362+
- <code title="get /threads/{thread_id}/runs/{run_id}/steps/{step_id}">client.beta.threads.runs.steps.<a href="./src/openai/resources/beta/threads/runs/steps.py">retrieve</a>(step_id, \*, thread_id, run_id, \*\*<a href="src/openai/types/beta/threads/runs/step_retrieve_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/runs/run_step.py">RunStep</a></code>
362363
- <code title="get /threads/{thread_id}/runs/{run_id}/steps">client.beta.threads.runs.steps.<a href="./src/openai/resources/beta/threads/runs/steps.py">list</a>(run_id, \*, thread_id, \*\*<a href="src/openai/types/beta/threads/runs/step_list_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/runs/run_step.py">SyncCursorPage[RunStep]</a></code>
363364

364365
### Messages

src/openai/resources/beta/threads/runs/runs.py

Lines changed: 68 additions & 3 deletions
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, overload
5+
from typing import List, Union, Iterable, Optional, overload
66
from typing_extensions import Literal
77

88
import httpx
@@ -38,6 +38,7 @@
3838
from .....types.beta.threads.run import Run
3939
from .....types.beta.assistant_tool_param import AssistantToolParam
4040
from .....types.beta.assistant_stream_event import AssistantStreamEvent
41+
from .....types.beta.threads.runs.run_step_include import RunStepInclude
4142
from .....types.beta.assistant_tool_choice_option_param import AssistantToolChoiceOptionParam
4243
from .....types.beta.assistant_response_format_option_param import AssistantResponseFormatOptionParam
4344

@@ -63,6 +64,7 @@ def create(
6364
thread_id: str,
6465
*,
6566
assistant_id: str,
67+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
6668
additional_instructions: Optional[str] | NotGiven = NOT_GIVEN,
6769
additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | NotGiven = NOT_GIVEN,
6870
instructions: Optional[str] | NotGiven = NOT_GIVEN,
@@ -93,6 +95,14 @@ def create(
9395
[assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
9496
execute this run.
9597
98+
include: A list of additional fields to include in the response. Currently the only
99+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
100+
to fetch the file search result content.
101+
102+
See the
103+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
104+
for more information.
105+
96106
additional_instructions: Appends additional instructions at the end of the instructions for the run. This
97107
is useful for modifying the behavior on a per-run basis without overriding other
98108
instructions.
@@ -195,6 +205,7 @@ def create(
195205
*,
196206
assistant_id: str,
197207
stream: Literal[True],
208+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
198209
additional_instructions: Optional[str] | NotGiven = NOT_GIVEN,
199210
additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | NotGiven = NOT_GIVEN,
200211
instructions: Optional[str] | NotGiven = NOT_GIVEN,
@@ -228,6 +239,14 @@ def create(
228239
events, terminating when the Run enters a terminal state with a `data: [DONE]`
229240
message.
230241
242+
include: A list of additional fields to include in the response. Currently the only
243+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
244+
to fetch the file search result content.
245+
246+
See the
247+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
248+
for more information.
249+
231250
additional_instructions: Appends additional instructions at the end of the instructions for the run. This
232251
is useful for modifying the behavior on a per-run basis without overriding other
233252
instructions.
@@ -326,6 +345,7 @@ def create(
326345
*,
327346
assistant_id: str,
328347
stream: bool,
348+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
329349
additional_instructions: Optional[str] | NotGiven = NOT_GIVEN,
330350
additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | NotGiven = NOT_GIVEN,
331351
instructions: Optional[str] | NotGiven = NOT_GIVEN,
@@ -359,6 +379,14 @@ def create(
359379
events, terminating when the Run enters a terminal state with a `data: [DONE]`
360380
message.
361381
382+
include: A list of additional fields to include in the response. Currently the only
383+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
384+
to fetch the file search result content.
385+
386+
See the
387+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
388+
for more information.
389+
362390
additional_instructions: Appends additional instructions at the end of the instructions for the run. This
363391
is useful for modifying the behavior on a per-run basis without overriding other
364392
instructions.
@@ -456,6 +484,7 @@ def create(
456484
thread_id: str,
457485
*,
458486
assistant_id: str,
487+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
459488
additional_instructions: Optional[str] | NotGiven = NOT_GIVEN,
460489
additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | NotGiven = NOT_GIVEN,
461490
instructions: Optional[str] | NotGiven = NOT_GIVEN,
@@ -505,7 +534,11 @@ def create(
505534
run_create_params.RunCreateParams,
506535
),
507536
options=make_request_options(
508-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
537+
extra_headers=extra_headers,
538+
extra_query=extra_query,
539+
extra_body=extra_body,
540+
timeout=timeout,
541+
query=maybe_transform({"include": include}, run_create_params.RunCreateParams),
509542
),
510543
cast_to=Run,
511544
stream=stream or False,
@@ -868,6 +901,7 @@ async def create(
868901
thread_id: str,
869902
*,
870903
assistant_id: str,
904+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
871905
additional_instructions: Optional[str] | NotGiven = NOT_GIVEN,
872906
additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | NotGiven = NOT_GIVEN,
873907
instructions: Optional[str] | NotGiven = NOT_GIVEN,
@@ -898,6 +932,14 @@ async def create(
898932
[assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
899933
execute this run.
900934
935+
include: A list of additional fields to include in the response. Currently the only
936+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
937+
to fetch the file search result content.
938+
939+
See the
940+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
941+
for more information.
942+
901943
additional_instructions: Appends additional instructions at the end of the instructions for the run. This
902944
is useful for modifying the behavior on a per-run basis without overriding other
903945
instructions.
@@ -1000,6 +1042,7 @@ async def create(
10001042
*,
10011043
assistant_id: str,
10021044
stream: Literal[True],
1045+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
10031046
additional_instructions: Optional[str] | NotGiven = NOT_GIVEN,
10041047
additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | NotGiven = NOT_GIVEN,
10051048
instructions: Optional[str] | NotGiven = NOT_GIVEN,
@@ -1033,6 +1076,14 @@ async def create(
10331076
events, terminating when the Run enters a terminal state with a `data: [DONE]`
10341077
message.
10351078
1079+
include: A list of additional fields to include in the response. Currently the only
1080+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
1081+
to fetch the file search result content.
1082+
1083+
See the
1084+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
1085+
for more information.
1086+
10361087
additional_instructions: Appends additional instructions at the end of the instructions for the run. This
10371088
is useful for modifying the behavior on a per-run basis without overriding other
10381089
instructions.
@@ -1131,6 +1182,7 @@ async def create(
11311182
*,
11321183
assistant_id: str,
11331184
stream: bool,
1185+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
11341186
additional_instructions: Optional[str] | NotGiven = NOT_GIVEN,
11351187
additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | NotGiven = NOT_GIVEN,
11361188
instructions: Optional[str] | NotGiven = NOT_GIVEN,
@@ -1164,6 +1216,14 @@ async def create(
11641216
events, terminating when the Run enters a terminal state with a `data: [DONE]`
11651217
message.
11661218
1219+
include: A list of additional fields to include in the response. Currently the only
1220+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
1221+
to fetch the file search result content.
1222+
1223+
See the
1224+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
1225+
for more information.
1226+
11671227
additional_instructions: Appends additional instructions at the end of the instructions for the run. This
11681228
is useful for modifying the behavior on a per-run basis without overriding other
11691229
instructions.
@@ -1261,6 +1321,7 @@ async def create(
12611321
thread_id: str,
12621322
*,
12631323
assistant_id: str,
1324+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
12641325
additional_instructions: Optional[str] | NotGiven = NOT_GIVEN,
12651326
additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | NotGiven = NOT_GIVEN,
12661327
instructions: Optional[str] | NotGiven = NOT_GIVEN,
@@ -1310,7 +1371,11 @@ async def create(
13101371
run_create_params.RunCreateParams,
13111372
),
13121373
options=make_request_options(
1313-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1374+
extra_headers=extra_headers,
1375+
extra_query=extra_query,
1376+
extra_body=extra_body,
1377+
timeout=timeout,
1378+
query=await async_maybe_transform({"include": include}, run_create_params.RunCreateParams),
13141379
),
13151380
cast_to=Run,
13161381
stream=stream or False,

src/openai/resources/beta/threads/runs/steps.py

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22

33
from __future__ import annotations
44

5+
from typing import List
56
from typing_extensions import Literal
67

78
import httpx
89

910
from ..... import _legacy_response
1011
from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11-
from ....._utils import maybe_transform
12+
from ....._utils import (
13+
maybe_transform,
14+
async_maybe_transform,
15+
)
1216
from ....._compat import cached_property
1317
from ....._resource import SyncAPIResource, AsyncAPIResource
1418
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
1519
from .....pagination import SyncCursorPage, AsyncCursorPage
1620
from ....._base_client import AsyncPaginator, make_request_options
17-
from .....types.beta.threads.runs import step_list_params
21+
from .....types.beta.threads.runs import step_list_params, step_retrieve_params
1822
from .....types.beta.threads.runs.run_step import RunStep
23+
from .....types.beta.threads.runs.run_step_include import RunStepInclude
1924

2025
__all__ = ["Steps", "AsyncSteps"]
2126

@@ -35,6 +40,7 @@ def retrieve(
3540
*,
3641
thread_id: str,
3742
run_id: str,
43+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
3844
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
3945
# The extra values given here take precedence over values defined on the client or passed to this method.
4046
extra_headers: Headers | None = None,
@@ -46,6 +52,14 @@ def retrieve(
4652
Retrieves a run step.
4753
4854
Args:
55+
include: A list of additional fields to include in the response. Currently the only
56+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
57+
to fetch the file search result content.
58+
59+
See the
60+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
61+
for more information.
62+
4963
extra_headers: Send extra headers
5064
5165
extra_query: Add additional query parameters to the request
@@ -64,7 +78,11 @@ def retrieve(
6478
return self._get(
6579
f"/threads/{thread_id}/runs/{run_id}/steps/{step_id}",
6680
options=make_request_options(
67-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
81+
extra_headers=extra_headers,
82+
extra_query=extra_query,
83+
extra_body=extra_body,
84+
timeout=timeout,
85+
query=maybe_transform({"include": include}, step_retrieve_params.StepRetrieveParams),
6886
),
6987
cast_to=RunStep,
7088
)
@@ -76,6 +94,7 @@ def list(
7694
thread_id: str,
7795
after: str | NotGiven = NOT_GIVEN,
7896
before: str | NotGiven = NOT_GIVEN,
97+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
7998
limit: int | NotGiven = NOT_GIVEN,
8099
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
81100
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -99,6 +118,14 @@ def list(
99118
ending with obj_foo, your subsequent call can include before=obj_foo in order to
100119
fetch the previous page of the list.
101120
121+
include: A list of additional fields to include in the response. Currently the only
122+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
123+
to fetch the file search result content.
124+
125+
See the
126+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
127+
for more information.
128+
102129
limit: A limit on the number of objects to be returned. Limit can range between 1 and
103130
100, and the default is 20.
104131
@@ -130,6 +157,7 @@ def list(
130157
{
131158
"after": after,
132159
"before": before,
160+
"include": include,
133161
"limit": limit,
134162
"order": order,
135163
},
@@ -155,6 +183,7 @@ async def retrieve(
155183
*,
156184
thread_id: str,
157185
run_id: str,
186+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
158187
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
159188
# The extra values given here take precedence over values defined on the client or passed to this method.
160189
extra_headers: Headers | None = None,
@@ -166,6 +195,14 @@ async def retrieve(
166195
Retrieves a run step.
167196
168197
Args:
198+
include: A list of additional fields to include in the response. Currently the only
199+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
200+
to fetch the file search result content.
201+
202+
See the
203+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
204+
for more information.
205+
169206
extra_headers: Send extra headers
170207
171208
extra_query: Add additional query parameters to the request
@@ -184,7 +221,11 @@ async def retrieve(
184221
return await self._get(
185222
f"/threads/{thread_id}/runs/{run_id}/steps/{step_id}",
186223
options=make_request_options(
187-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
224+
extra_headers=extra_headers,
225+
extra_query=extra_query,
226+
extra_body=extra_body,
227+
timeout=timeout,
228+
query=await async_maybe_transform({"include": include}, step_retrieve_params.StepRetrieveParams),
188229
),
189230
cast_to=RunStep,
190231
)
@@ -196,6 +237,7 @@ def list(
196237
thread_id: str,
197238
after: str | NotGiven = NOT_GIVEN,
198239
before: str | NotGiven = NOT_GIVEN,
240+
include: List[RunStepInclude] | NotGiven = NOT_GIVEN,
199241
limit: int | NotGiven = NOT_GIVEN,
200242
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
201243
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -219,6 +261,14 @@ def list(
219261
ending with obj_foo, your subsequent call can include before=obj_foo in order to
220262
fetch the previous page of the list.
221263
264+
include: A list of additional fields to include in the response. Currently the only
265+
supported value is `step_details.tool_calls[*].file_search.results[*].content`
266+
to fetch the file search result content.
267+
268+
See the
269+
[file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
270+
for more information.
271+
222272
limit: A limit on the number of objects to be returned. Limit can range between 1 and
223273
100, and the default is 20.
224274
@@ -250,6 +300,7 @@ def list(
250300
{
251301
"after": after,
252302
"before": before,
303+
"include": include,
253304
"limit": limit,
254305
"order": order,
255306
},

0 commit comments

Comments
 (0)