Skip to content

Commit 619903c

Browse files
Stainless Botstainless-app[bot]
Stainless Bot
authored andcommitted
feat(api): add file search result details to run steps (#1023)
1 parent 081e21a commit 619903c

File tree

12 files changed

+400
-91
lines changed

12 files changed

+400
-91
lines changed

.stats.yml

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

api.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,15 @@ Types:
339339
- <code><a href="./src/resources/beta/threads/runs/steps.ts">RunStepDelta</a></code>
340340
- <code><a href="./src/resources/beta/threads/runs/steps.ts">RunStepDeltaEvent</a></code>
341341
- <code><a href="./src/resources/beta/threads/runs/steps.ts">RunStepDeltaMessageDelta</a></code>
342+
- <code><a href="./src/resources/beta/threads/runs/steps.ts">RunStepInclude</a></code>
342343
- <code><a href="./src/resources/beta/threads/runs/steps.ts">ToolCall</a></code>
343344
- <code><a href="./src/resources/beta/threads/runs/steps.ts">ToolCallDelta</a></code>
344345
- <code><a href="./src/resources/beta/threads/runs/steps.ts">ToolCallDeltaObject</a></code>
345346
- <code><a href="./src/resources/beta/threads/runs/steps.ts">ToolCallsStepDetails</a></code>
346347

347348
Methods:
348349

349-
- <code title="get /threads/{thread_id}/runs/{run_id}/steps/{step_id}">client.beta.threads.runs.steps.<a href="./src/resources/beta/threads/runs/steps.ts">retrieve</a>(threadId, runId, stepId) -> RunStep</code>
350+
- <code title="get /threads/{thread_id}/runs/{run_id}/steps/{step_id}">client.beta.threads.runs.steps.<a href="./src/resources/beta/threads/runs/steps.ts">retrieve</a>(threadId, runId, stepId, { ...params }) -> RunStep</code>
350351
- <code title="get /threads/{thread_id}/runs/{run_id}/steps">client.beta.threads.runs.steps.<a href="./src/resources/beta/threads/runs/steps.ts">list</a>(threadId, runId, { ...params }) -> RunStepsPage</code>
351352

352353
### Messages

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
"dependencies": {
2727
"@types/node": "^18.11.18",
2828
"@types/node-fetch": "^2.6.4",
29+
"@types/qs": "^6.9.7",
2930
"abort-controller": "^3.0.0",
3031
"agentkeepalive": "^4.2.1",
3132
"form-data-encoder": "1.7.2",
3233
"formdata-node": "^4.3.2",
33-
"node-fetch": "^2.6.7"
34+
"node-fetch": "^2.6.7",
35+
"qs": "^6.10.3"
3436
},
3537
"devDependencies": {
3638
"@swc/core": "^1.3.102",

src/index.ts

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

33
import * as Errors from './error';
44
import * as Uploads from './uploads';
5+
56
import { type Agent, type RequestInit } from './_shims/index';
7+
import * as qs from 'qs';
8+
69
import * as Core from './core';
710
import * as Pagination from './pagination';
811
import * as API from './resources/index';
@@ -183,6 +186,10 @@ export class OpenAI extends Core.APIClient {
183186
return { Authorization: `Bearer ${this.apiKey}` };
184187
}
185188

189+
protected override stringifyQuery(query: Record<string, unknown>): string {
190+
return qs.stringify(query, { arrayFormat: 'brackets' });
191+
}
192+
186193
static OpenAI = this;
187194
static DEFAULT_TIMEOUT = 600000; // 10 minutes
188195

src/resources/beta/assistants.ts

+57-25
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ export namespace AssistantStreamEvent {
441441

442442
/**
443443
* Occurs when a
444-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
445-
* created.
444+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
445+
* is created.
446446
*/
447447
export interface ThreadRunStepCreated {
448448
/**
@@ -455,7 +455,7 @@ export namespace AssistantStreamEvent {
455455

456456
/**
457457
* Occurs when a
458-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object)
458+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
459459
* moves to an `in_progress` state.
460460
*/
461461
export interface ThreadRunStepInProgress {
@@ -469,8 +469,8 @@ export namespace AssistantStreamEvent {
469469

470470
/**
471471
* Occurs when parts of a
472-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) are
473-
* being streamed.
472+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
473+
* are being streamed.
474474
*/
475475
export interface ThreadRunStepDelta {
476476
/**
@@ -484,8 +484,8 @@ export namespace AssistantStreamEvent {
484484

485485
/**
486486
* Occurs when a
487-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
488-
* completed.
487+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
488+
* is completed.
489489
*/
490490
export interface ThreadRunStepCompleted {
491491
/**
@@ -498,7 +498,7 @@ export namespace AssistantStreamEvent {
498498

499499
/**
500500
* Occurs when a
501-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object)
501+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
502502
* fails.
503503
*/
504504
export interface ThreadRunStepFailed {
@@ -512,8 +512,8 @@ export namespace AssistantStreamEvent {
512512

513513
/**
514514
* Occurs when a
515-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
516-
* cancelled.
515+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
516+
* is cancelled.
517517
*/
518518
export interface ThreadRunStepCancelled {
519519
/**
@@ -526,7 +526,7 @@ export namespace AssistantStreamEvent {
526526

527527
/**
528528
* Occurs when a
529-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object)
529+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
530530
* expires.
531531
*/
532532
export interface ThreadRunStepExpired {
@@ -658,10 +658,42 @@ export namespace FileSearchTool {
658658
*
659659
* Note that the file search tool may output fewer than `max_num_results` results.
660660
* See the
661-
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/number-of-chunks-returned)
661+
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
662662
* for more information.
663663
*/
664664
max_num_results?: number;
665+
666+
/**
667+
* The ranking options for the file search.
668+
*
669+
* See the
670+
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
671+
* for more information.
672+
*/
673+
ranking_options?: FileSearch.RankingOptions;
674+
}
675+
676+
export namespace FileSearch {
677+
/**
678+
* The ranking options for the file search.
679+
*
680+
* See the
681+
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
682+
* for more information.
683+
*/
684+
export interface RankingOptions {
685+
/**
686+
* The ranker to use for the file search. If not specified will use the `auto`
687+
* ranker.
688+
*/
689+
ranker?: 'auto' | 'default_2024_08_21';
690+
691+
/**
692+
* The score threshold for the file search. All values must be a floating point
693+
* number between 0 and 1.
694+
*/
695+
score_threshold?: number;
696+
}
665697
}
666698
}
667699

@@ -765,8 +797,8 @@ export namespace MessageStreamEvent {
765797

766798
/**
767799
* Occurs when a
768-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
769-
* created.
800+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
801+
* is created.
770802
*/
771803
export type RunStepStreamEvent =
772804
| RunStepStreamEvent.ThreadRunStepCreated
@@ -780,8 +812,8 @@ export type RunStepStreamEvent =
780812
export namespace RunStepStreamEvent {
781813
/**
782814
* Occurs when a
783-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
784-
* created.
815+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
816+
* is created.
785817
*/
786818
export interface ThreadRunStepCreated {
787819
/**
@@ -794,7 +826,7 @@ export namespace RunStepStreamEvent {
794826

795827
/**
796828
* Occurs when a
797-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object)
829+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
798830
* moves to an `in_progress` state.
799831
*/
800832
export interface ThreadRunStepInProgress {
@@ -808,8 +840,8 @@ export namespace RunStepStreamEvent {
808840

809841
/**
810842
* Occurs when parts of a
811-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) are
812-
* being streamed.
843+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
844+
* are being streamed.
813845
*/
814846
export interface ThreadRunStepDelta {
815847
/**
@@ -823,8 +855,8 @@ export namespace RunStepStreamEvent {
823855

824856
/**
825857
* Occurs when a
826-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
827-
* completed.
858+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
859+
* is completed.
828860
*/
829861
export interface ThreadRunStepCompleted {
830862
/**
@@ -837,7 +869,7 @@ export namespace RunStepStreamEvent {
837869

838870
/**
839871
* Occurs when a
840-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object)
872+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
841873
* fails.
842874
*/
843875
export interface ThreadRunStepFailed {
@@ -851,8 +883,8 @@ export namespace RunStepStreamEvent {
851883

852884
/**
853885
* Occurs when a
854-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
855-
* cancelled.
886+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
887+
* is cancelled.
856888
*/
857889
export interface ThreadRunStepCancelled {
858890
/**
@@ -865,7 +897,7 @@ export namespace RunStepStreamEvent {
865897

866898
/**
867899
* Occurs when a
868-
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object)
900+
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
869901
* expires.
870902
*/
871903
export interface ThreadRunStepExpired {

src/resources/beta/threads/runs/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ export {
1414
RunStepDelta,
1515
RunStepDeltaEvent,
1616
RunStepDeltaMessageDelta,
17+
RunStepInclude,
1718
ToolCall,
1819
ToolCallDelta,
1920
ToolCallDeltaObject,
2021
ToolCallsStepDetails,
22+
StepRetrieveParams,
2123
StepListParams,
2224
RunStepsPage,
2325
Steps,

0 commit comments

Comments
 (0)