Skip to content

Commit

Permalink
feat(api): add file search result details to run steps (#1023)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Aug 29, 2024
1 parent c179c56 commit 523399c
Show file tree
Hide file tree
Showing 12 changed files with 398 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 68
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-8e569a23f15a599dd4aee8a53431962bcba4985ab6cfb66c53c1434b99026b37.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-1dbac0e95bdb5a89a0dd3d93265475a378214551b7d8c22862928e0d87ace94b.yml
3 changes: 2 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,15 @@ Types:
- <code><a href="./src/resources/beta/threads/runs/steps.ts">RunStepDelta</a></code>
- <code><a href="./src/resources/beta/threads/runs/steps.ts">RunStepDeltaEvent</a></code>
- <code><a href="./src/resources/beta/threads/runs/steps.ts">RunStepDeltaMessageDelta</a></code>
- <code><a href="./src/resources/beta/threads/runs/steps.ts">RunStepInclude</a></code>
- <code><a href="./src/resources/beta/threads/runs/steps.ts">ToolCall</a></code>
- <code><a href="./src/resources/beta/threads/runs/steps.ts">ToolCallDelta</a></code>
- <code><a href="./src/resources/beta/threads/runs/steps.ts">ToolCallDeltaObject</a></code>
- <code><a href="./src/resources/beta/threads/runs/steps.ts">ToolCallsStepDetails</a></code>

Methods:

- <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>
- <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>
- <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>

### Messages
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
"dependencies": {
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.4",
"@types/qs": "^6.9.7",
"abort-controller": "^3.0.0",
"agentkeepalive": "^4.2.1",
"form-data-encoder": "1.7.2",
"formdata-node": "^4.3.2",
"node-fetch": "^2.6.7"
"node-fetch": "^2.6.7",
"qs": "^6.10.3"
},
"devDependencies": {
"@swc/core": "^1.3.102",
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as Errors from './error';
import * as Uploads from './uploads';
import { type Agent } from './_shims/index';
import * as qs from 'qs';
import * as Core from './core';
import * as Pagination from './pagination';
import * as API from './resources/index';
Expand Down Expand Up @@ -183,6 +184,10 @@ export class OpenAI extends Core.APIClient {
return { Authorization: `Bearer ${this.apiKey}` };
}

protected override stringifyQuery(query: Record<string, unknown>): string {
return qs.stringify(query, { arrayFormat: 'brackets' });
}

static OpenAI = this;
static DEFAULT_TIMEOUT = 600000; // 10 minutes

Expand Down
82 changes: 57 additions & 25 deletions src/resources/beta/assistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ export namespace AssistantStreamEvent {

/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
* created.
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is created.
*/
export interface ThreadRunStepCreated {
/**
Expand All @@ -455,7 +455,7 @@ export namespace AssistantStreamEvent {

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

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

/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
* completed.
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is completed.
*/
export interface ThreadRunStepCompleted {
/**
Expand All @@ -498,7 +498,7 @@ export namespace AssistantStreamEvent {

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

/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
* cancelled.
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is cancelled.
*/
export interface ThreadRunStepCancelled {
/**
Expand All @@ -526,7 +526,7 @@ export namespace AssistantStreamEvent {

/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object)
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* expires.
*/
export interface ThreadRunStepExpired {
Expand Down Expand Up @@ -658,10 +658,42 @@ export namespace FileSearchTool {
*
* Note that the file search tool may output fewer than `max_num_results` results.
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/number-of-chunks-returned)
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
* for more information.
*/
max_num_results?: number;

/**
* The ranking options for the file search.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
* for more information.
*/
ranking_options?: FileSearch.RankingOptions;
}

export namespace FileSearch {
/**
* The ranking options for the file search.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings)
* for more information.
*/
export interface RankingOptions {
/**
* The ranker to use for the file search. If not specified will use the `auto`
* ranker.
*/
ranker?: 'auto' | 'default_2024_08_21';

/**
* The score threshold for the file search. All values must be a floating point
* number between 0 and 1.
*/
score_threshold?: number;
}
}
}

Expand Down Expand Up @@ -765,8 +797,8 @@ export namespace MessageStreamEvent {

/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
* created.
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is created.
*/
export type RunStepStreamEvent =
| RunStepStreamEvent.ThreadRunStepCreated
Expand All @@ -780,8 +812,8 @@ export type RunStepStreamEvent =
export namespace RunStepStreamEvent {
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
* created.
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is created.
*/
export interface ThreadRunStepCreated {
/**
Expand All @@ -794,7 +826,7 @@ export namespace RunStepStreamEvent {

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

/**
* Occurs when parts of a
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) are
* being streamed.
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* are being streamed.
*/
export interface ThreadRunStepDelta {
/**
Expand All @@ -823,8 +855,8 @@ export namespace RunStepStreamEvent {

/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
* completed.
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is completed.
*/
export interface ThreadRunStepCompleted {
/**
Expand All @@ -837,7 +869,7 @@ export namespace RunStepStreamEvent {

/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object)
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* fails.
*/
export interface ThreadRunStepFailed {
Expand All @@ -851,8 +883,8 @@ export namespace RunStepStreamEvent {

/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
* cancelled.
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is cancelled.
*/
export interface ThreadRunStepCancelled {
/**
Expand All @@ -865,7 +897,7 @@ export namespace RunStepStreamEvent {

/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/runs/step-object)
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* expires.
*/
export interface ThreadRunStepExpired {
Expand Down
2 changes: 2 additions & 0 deletions src/resources/beta/threads/runs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ export {
RunStepDelta,
RunStepDeltaEvent,
RunStepDeltaMessageDelta,
RunStepInclude,
ToolCall,
ToolCallDelta,
ToolCallDeltaObject,
ToolCallsStepDetails,
StepRetrieveParams,
StepListParams,
RunStepsPage,
Steps,
Expand Down
Loading

0 comments on commit 523399c

Please sign in to comment.