diff --git a/.stats.yml b/.stats.yml index 185585b67..fd4f27136 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 68 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-8ff62fa1091460d68fbd36d72c17d91b709917bebf2983c9c4de5784bc384a2e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-1dbac0e95bdb5a89a0dd3d93265475a378214551b7d8c22862928e0d87ace94b.yml diff --git a/api.md b/api.md index 9594a101c..936f64196 100644 --- a/api.md +++ b/api.md @@ -339,6 +339,7 @@ Types: - RunStepDelta - RunStepDeltaEvent - RunStepDeltaMessageDelta +- RunStepInclude - ToolCall - ToolCallDelta - ToolCallDeltaObject @@ -346,7 +347,7 @@ Types: Methods: -- client.beta.threads.runs.steps.retrieve(threadId, runId, stepId) -> RunStep +- client.beta.threads.runs.steps.retrieve(threadId, runId, stepId, { ...params }) -> RunStep - client.beta.threads.runs.steps.list(threadId, runId, { ...params }) -> RunStepsPage ### Messages diff --git a/package.json b/package.json index 1fa8e59d4..e4d595eae 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.ts b/src/index.ts index 0c6c7badb..c0e527d25 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,10 @@ import * as Errors from './error'; import * as Uploads from './uploads'; + import { type Agent, type RequestInit } from './_shims/index'; +import * as qs from 'qs'; + import * as Core from './core'; import * as Pagination from './pagination'; import * as API from './resources/index'; @@ -183,6 +186,10 @@ export class OpenAI extends Core.APIClient { return { Authorization: `Bearer ${this.apiKey}` }; } + protected override stringifyQuery(query: Record): string { + return qs.stringify(query, { arrayFormat: 'brackets' }); + } + static OpenAI = this; static DEFAULT_TIMEOUT = 600000; // 10 minutes diff --git a/src/resources/beta/assistants.ts b/src/resources/beta/assistants.ts index 8d07e45b0..924d63d5c 100644 --- a/src/resources/beta/assistants.ts +++ b/src/resources/beta/assistants.ts @@ -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 { /** @@ -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 { @@ -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 { /** @@ -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 { /** @@ -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 { @@ -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 { /** @@ -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 { @@ -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; + } } } @@ -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 @@ -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 { /** @@ -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 { @@ -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 { /** @@ -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 { /** @@ -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 { @@ -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 { /** @@ -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 { diff --git a/src/resources/beta/threads/runs/index.ts b/src/resources/beta/threads/runs/index.ts index d216195cb..9496f59e1 100644 --- a/src/resources/beta/threads/runs/index.ts +++ b/src/resources/beta/threads/runs/index.ts @@ -14,10 +14,12 @@ export { RunStepDelta, RunStepDeltaEvent, RunStepDeltaMessageDelta, + RunStepInclude, ToolCall, ToolCallDelta, ToolCallDeltaObject, ToolCallsStepDetails, + StepRetrieveParams, StepListParams, RunStepsPage, Steps, diff --git a/src/resources/beta/threads/runs/runs.ts b/src/resources/beta/threads/runs/runs.ts index 9383e70cc..fe3a278e9 100644 --- a/src/resources/beta/threads/runs/runs.ts +++ b/src/resources/beta/threads/runs/runs.ts @@ -22,27 +22,33 @@ export class Runs extends APIResource { /** * Create a run. */ - create(threadId: string, body: RunCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise; create( threadId: string, - body: RunCreateParamsStreaming, + params: RunCreateParamsNonStreaming, + options?: Core.RequestOptions, + ): APIPromise; + create( + threadId: string, + params: RunCreateParamsStreaming, options?: Core.RequestOptions, ): APIPromise>; create( threadId: string, - body: RunCreateParamsBase, + params: RunCreateParamsBase, options?: Core.RequestOptions, ): APIPromise | Run>; create( threadId: string, - body: RunCreateParams, + params: RunCreateParams, options?: Core.RequestOptions, ): APIPromise | APIPromise> { + const { include, ...body } = params; return this._client.post(`/threads/${threadId}/runs`, { + query: { include }, body, ...options, headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers }, - stream: body.stream ?? false, + stream: params.stream ?? false, }) as APIPromise | APIPromise>; } @@ -617,74 +623,87 @@ export type RunCreateParams = RunCreateParamsNonStreaming | RunCreateParamsStrea export interface RunCreateParamsBase { /** - * The ID of the + * Body param: The ID of the * [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to * execute this run. */ assistant_id: string; /** - * Appends additional instructions at the end of the instructions for the run. This - * is useful for modifying the behavior on a per-run basis without overriding other - * instructions. + * Query param: A list of additional fields to include in the response. Currently + * the only supported value is + * `step_details.tool_calls[*].file_search.results[*].content` to fetch the file + * search result content. + * + * See the + * [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) + * for more information. + */ + include?: Array; + + /** + * Body param: Appends additional instructions at the end of the instructions for + * the run. This is useful for modifying the behavior on a per-run basis without + * overriding other instructions. */ additional_instructions?: string | null; /** - * Adds additional messages to the thread before creating the run. + * Body param: Adds additional messages to the thread before creating the run. */ additional_messages?: Array | null; /** - * Overrides the + * Body param: Overrides the * [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant) * of the assistant. This is useful for modifying the behavior on a per-run basis. */ instructions?: string | null; /** - * The maximum number of completion tokens that may be used over the course of the - * run. The run will make a best effort to use only the number of completion tokens - * specified, across multiple turns of the run. If the run exceeds the number of - * completion tokens specified, the run will end with status `incomplete`. See - * `incomplete_details` for more info. + * Body param: The maximum number of completion tokens that may be used over the + * course of the run. The run will make a best effort to use only the number of + * completion tokens specified, across multiple turns of the run. If the run + * exceeds the number of completion tokens specified, the run will end with status + * `incomplete`. See `incomplete_details` for more info. */ max_completion_tokens?: number | null; /** - * The maximum number of prompt tokens that may be used over the course of the run. - * The run will make a best effort to use only the number of prompt tokens - * specified, across multiple turns of the run. If the run exceeds the number of - * prompt tokens specified, the run will end with status `incomplete`. See - * `incomplete_details` for more info. + * Body param: The maximum number of prompt tokens that may be used over the course + * of the run. The run will make a best effort to use only the number of prompt + * tokens specified, across multiple turns of the run. If the run exceeds the + * number of prompt tokens specified, the run will end with status `incomplete`. + * See `incomplete_details` for more info. */ max_prompt_tokens?: number | null; /** - * Set of 16 key-value pairs that can be attached to an object. This can be useful - * for storing additional information about the object in a structured format. Keys - * can be a maximum of 64 characters long and values can be a maxium of 512 - * characters long. + * Body param: Set of 16 key-value pairs that can be attached to an object. This + * can be useful for storing additional information about the object in a + * structured format. Keys can be a maximum of 64 characters long and values can be + * a maxium of 512 characters long. */ metadata?: unknown | null; /** - * The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to - * be used to execute this run. If a value is provided here, it will override the - * model associated with the assistant. If not, the model associated with the - * assistant will be used. + * Body param: The ID of the + * [Model](https://platform.openai.com/docs/api-reference/models) to be used to + * execute this run. If a value is provided here, it will override the model + * associated with the assistant. If not, the model associated with the assistant + * will be used. */ model?: (string & {}) | ChatAPI.ChatModel | null; /** - * Whether to enable + * Body param: Whether to enable * [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) * during tool use. */ parallel_tool_calls?: boolean; /** - * Specifies the format that the model must output. Compatible with + * Body param: Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models/gpt-4o), * [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4), * and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. @@ -708,48 +727,50 @@ export interface RunCreateParamsBase { response_format?: ThreadsAPI.AssistantResponseFormatOption | null; /** - * If `true`, returns a stream of events that happen during the Run as server-sent - * events, terminating when the Run enters a terminal state with a `data: [DONE]` - * message. + * Body param: If `true`, returns a stream of events that happen during the Run as + * server-sent events, terminating when the Run enters a terminal state with a + * `data: [DONE]` message. */ stream?: boolean | null; /** - * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will - * make the output more random, while lower values like 0.2 will make it more - * focused and deterministic. + * Body param: What sampling temperature to use, between 0 and 2. Higher values + * like 0.8 will make the output more random, while lower values like 0.2 will make + * it more focused and deterministic. */ temperature?: number | null; /** - * Controls which (if any) tool is called by the model. `none` means the model will - * not call any tools and instead generates a message. `auto` is the default value - * and means the model can pick between generating a message or calling one or more - * tools. `required` means the model must call one or more tools before responding - * to the user. Specifying a particular tool like `{"type": "file_search"}` or + * Body param: Controls which (if any) tool is called by the model. `none` means + * the model will not call any tools and instead generates a message. `auto` is the + * default value and means the model can pick between generating a message or + * calling one or more tools. `required` means the model must call one or more + * tools before responding to the user. Specifying a particular tool like + * `{"type": "file_search"}` or * `{"type": "function", "function": {"name": "my_function"}}` forces the model to * call that tool. */ tool_choice?: ThreadsAPI.AssistantToolChoiceOption | null; /** - * Override the tools the assistant can use for this run. This is useful for - * modifying the behavior on a per-run basis. + * Body param: Override the tools the assistant can use for this run. This is + * useful for modifying the behavior on a per-run basis. */ tools?: Array | null; /** - * An alternative to sampling with temperature, called nucleus sampling, where the - * model considers the results of the tokens with top_p probability mass. So 0.1 - * means only the tokens comprising the top 10% probability mass are considered. + * Body param: An alternative to sampling with temperature, called nucleus + * sampling, where the model considers the results of the tokens with top_p + * probability mass. So 0.1 means only the tokens comprising the top 10% + * probability mass are considered. * * We generally recommend altering this or temperature but not both. */ top_p?: number | null; /** - * Controls for how a thread will be truncated prior to the run. Use this to - * control the intial context window of the run. + * Body param: Controls for how a thread will be truncated prior to the run. Use + * this to control the intial context window of the run. */ truncation_strategy?: RunCreateParams.TruncationStrategy | null; } @@ -834,18 +855,18 @@ export namespace RunCreateParams { export interface RunCreateParamsNonStreaming extends RunCreateParamsBase { /** - * If `true`, returns a stream of events that happen during the Run as server-sent - * events, terminating when the Run enters a terminal state with a `data: [DONE]` - * message. + * Body param: If `true`, returns a stream of events that happen during the Run as + * server-sent events, terminating when the Run enters a terminal state with a + * `data: [DONE]` message. */ stream?: false | null; } export interface RunCreateParamsStreaming extends RunCreateParamsBase { /** - * If `true`, returns a stream of events that happen during the Run as server-sent - * events, terminating when the Run enters a terminal state with a `data: [DONE]` - * message. + * Body param: If `true`, returns a stream of events that happen during the Run as + * server-sent events, terminating when the Run enters a terminal state with a + * `data: [DONE]` message. */ stream: true; } @@ -1630,10 +1651,12 @@ export namespace Runs { export import RunStepDelta = StepsAPI.RunStepDelta; export import RunStepDeltaEvent = StepsAPI.RunStepDeltaEvent; export import RunStepDeltaMessageDelta = StepsAPI.RunStepDeltaMessageDelta; + export import RunStepInclude = StepsAPI.RunStepInclude; export import ToolCall = StepsAPI.ToolCall; export import ToolCallDelta = StepsAPI.ToolCallDelta; export import ToolCallDeltaObject = StepsAPI.ToolCallDeltaObject; export import ToolCallsStepDetails = StepsAPI.ToolCallsStepDetails; export import RunStepsPage = StepsAPI.RunStepsPage; + export import StepRetrieveParams = StepsAPI.StepRetrieveParams; export import StepListParams = StepsAPI.StepListParams; } diff --git a/src/resources/beta/threads/runs/steps.ts b/src/resources/beta/threads/runs/steps.ts index 09605d458..c076191a3 100644 --- a/src/resources/beta/threads/runs/steps.ts +++ b/src/resources/beta/threads/runs/steps.ts @@ -14,9 +14,27 @@ export class Steps extends APIResource { threadId: string, runId: string, stepId: string, + query?: StepRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve( + threadId: string, + runId: string, + stepId: string, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve( + threadId: string, + runId: string, + stepId: string, + query: StepRetrieveParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { + if (isRequestOptions(query)) { + return this.retrieve(threadId, runId, stepId, {}, query); + } return this._client.get(`/threads/${threadId}/runs/${runId}/steps/${stepId}`, { + query, ...options, headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers }, }); @@ -229,7 +247,7 @@ export interface FileSearchToolCall { /** * For now, this is always going to be an empty object. */ - file_search: unknown; + file_search: FileSearchToolCall.FileSearch; /** * The type of tool call. This is always going to be `file_search` for this type of @@ -238,6 +256,82 @@ export interface FileSearchToolCall { type: 'file_search'; } +export namespace FileSearchToolCall { + /** + * For now, this is always going to be an empty object. + */ + export interface FileSearch { + /** + * The ranking options for the file search. + */ + ranking_options?: FileSearch.RankingOptions; + + /** + * The results of the file search. + */ + results?: Array; + } + + export namespace FileSearch { + /** + * The ranking options for the file search. + */ + export interface RankingOptions { + /** + * The ranker used for the file search. + */ + ranker: '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; + } + + /** + * A result instance of the file search. + */ + export interface Result { + /** + * The ID of the file that result was found in. + */ + file_id: string; + + /** + * The name of the file that result was found in. + */ + file_name: string; + + /** + * The score of the result. All values must be a floating point number between 0 + * and 1. + */ + score: number; + + /** + * The content of the result that was found. The content is only included if + * requested via the include query parameter. + */ + content?: Array; + } + + export namespace Result { + export interface Content { + /** + * The text content of the file. + */ + text?: string; + + /** + * The type of the content. + */ + type?: 'text'; + } + } + } +} + export interface FileSearchToolCallDelta { /** * For now, this is always going to be an empty object. @@ -558,6 +652,8 @@ export namespace RunStepDeltaMessageDelta { } } +export type RunStepInclude = 'step_details.tool_calls[*].file_search.results[*].content'; + /** * Details of the Code Interpreter tool call the run step was involved in. */ @@ -602,6 +698,19 @@ export interface ToolCallsStepDetails { type: 'tool_calls'; } +export interface StepRetrieveParams { + /** + * A list of additional fields to include in the response. Currently the only + * supported value is `step_details.tool_calls[*].file_search.results[*].content` + * to fetch the file search result content. + * + * See the + * [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) + * for more information. + */ + include?: Array; +} + export interface StepListParams extends CursorPageParams { /** * A cursor for use in pagination. `before` is an object ID that defines your place @@ -611,6 +720,17 @@ export interface StepListParams extends CursorPageParams { */ before?: string; + /** + * A list of additional fields to include in the response. Currently the only + * supported value is `step_details.tool_calls[*].file_search.results[*].content` + * to fetch the file search result content. + * + * See the + * [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) + * for more information. + */ + include?: Array; + /** * Sort order by the `created_at` timestamp of the objects. `asc` for ascending * order and `desc` for descending order. @@ -632,10 +752,12 @@ export namespace Steps { export import RunStepDelta = StepsAPI.RunStepDelta; export import RunStepDeltaEvent = StepsAPI.RunStepDeltaEvent; export import RunStepDeltaMessageDelta = StepsAPI.RunStepDeltaMessageDelta; + export import RunStepInclude = StepsAPI.RunStepInclude; export import ToolCall = StepsAPI.ToolCall; export import ToolCallDelta = StepsAPI.ToolCallDelta; export import ToolCallDeltaObject = StepsAPI.ToolCallDeltaObject; export import ToolCallsStepDetails = StepsAPI.ToolCallsStepDetails; export import RunStepsPage = StepsAPI.RunStepsPage; + export import StepRetrieveParams = StepsAPI.StepRetrieveParams; export import StepListParams = StepsAPI.StepListParams; } diff --git a/tests/api-resources/beta/threads/runs/runs.test.ts b/tests/api-resources/beta/threads/runs/runs.test.ts index a2fda7757..352d775c0 100644 --- a/tests/api-resources/beta/threads/runs/runs.test.ts +++ b/tests/api-resources/beta/threads/runs/runs.test.ts @@ -23,6 +23,7 @@ describe('resource runs', () => { test('create: required and optional params', async () => { const response = await client.beta.threads.runs.create('thread_id', { assistant_id: 'assistant_id', + include: ['step_details.tool_calls[*].file_search.results[*].content'], additional_instructions: 'additional_instructions', additional_messages: [ { diff --git a/tests/api-resources/beta/threads/runs/steps.test.ts b/tests/api-resources/beta/threads/runs/steps.test.ts index 21487c17b..64cd228ae 100644 --- a/tests/api-resources/beta/threads/runs/steps.test.ts +++ b/tests/api-resources/beta/threads/runs/steps.test.ts @@ -29,6 +29,19 @@ describe('resource steps', () => { ).rejects.toThrow(OpenAI.NotFoundError); }); + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.beta.threads.runs.steps.retrieve( + 'thread_id', + 'run_id', + 'step_id', + { include: ['step_details.tool_calls[*].file_search.results[*].content'] }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(OpenAI.NotFoundError); + }); + test('list', async () => { const responsePromise = client.beta.threads.runs.steps.list('thread_id', 'run_id'); const rawResponse = await responsePromise.asResponse(); @@ -53,7 +66,13 @@ describe('resource steps', () => { client.beta.threads.runs.steps.list( 'thread_id', 'run_id', - { after: 'after', before: 'before', limit: 0, order: 'asc' }, + { + after: 'after', + before: 'before', + include: ['step_details.tool_calls[*].file_search.results[*].content'], + limit: 0, + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/stringifyQuery.test.ts b/tests/stringifyQuery.test.ts index 724743f30..e5f3e560a 100644 --- a/tests/stringifyQuery.test.ts +++ b/tests/stringifyQuery.test.ts @@ -20,10 +20,4 @@ describe(stringifyQuery, () => { expect(stringifyQuery(input)).toEqual(expected); }); } - - for (const value of [[], {}, new Date()]) { - it(`${JSON.stringify(value)} -> `, () => { - expect(() => stringifyQuery({ value })).toThrow(`Cannot stringify type ${typeof value}`); - }); - } }); diff --git a/yarn.lock b/yarn.lock index 1b0863df1..c916c0a6a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -881,6 +881,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f" integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA== +"@types/qs@^6.9.7": + version "6.9.15" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.15.tgz#adde8a060ec9c305a82de1babc1056e73bd64dce" + integrity sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg== + "@types/semver@^7.5.0": version "7.5.3" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.3.tgz#9a726e116beb26c24f1ccd6850201e1246122e04" @@ -1243,6 +1248,17 @@ bundle-name@^3.0.0: dependencies: run-applescript "^5.0.0" +call-bind@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.7.tgz#06016599c40c56498c18769d2730be242b6fa3b9" + integrity sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + set-function-length "^1.2.1" + callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -1432,6 +1448,15 @@ default-browser@^4.0.0: execa "^7.1.1" titleize "^3.0.0" +define-data-property@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" + integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + gopd "^1.0.1" + define-lazy-prop@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz#dbb19adfb746d7fc6d734a06b72f4a00d021255f" @@ -1498,6 +1523,18 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" +es-define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845" + integrity sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ== + dependencies: + get-intrinsic "^1.2.4" + +es-errors@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" + integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== + escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" @@ -1845,6 +1882,17 @@ get-caller-file@^2.0.5: resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== +get-intrinsic@^1.1.3, get-intrinsic@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.4.tgz#e385f5a4b5227d449c3eabbad05494ef0abbeadd" + integrity sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ== + dependencies: + es-errors "^1.3.0" + function-bind "^1.1.2" + has-proto "^1.0.1" + has-symbols "^1.0.3" + hasown "^2.0.0" + get-package-type@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" @@ -1910,6 +1958,13 @@ globby@^11.1.0: merge2 "^1.4.1" slash "^3.0.0" +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" + graceful-fs@^4.2.9: version "4.2.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" @@ -1930,6 +1985,23 @@ has-flag@^4.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== +has-property-descriptors@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" + integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== + dependencies: + es-define-property "^1.0.0" + +has-proto@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.3.tgz#b31ddfe9b0e6e9914536a6ab286426d0214f77fd" + integrity sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q== + +has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + hasown@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.0.tgz#f4c513d454a57b7c7e1650778de226b11700546c" @@ -2747,6 +2819,11 @@ npm-run-path@^5.1.0: dependencies: path-key "^4.0.0" +object-inspect@^1.13.1: + version "1.13.2" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.2.tgz#dea0088467fb991e67af4058147a24824a3043ff" + integrity sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g== + once@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" @@ -2960,6 +3037,13 @@ pure-rand@^6.0.0: resolved "https://registry.yarnpkg.com/pure-rand/-/pure-rand-6.0.4.tgz#50b737f6a925468679bff00ad20eade53f37d5c7" integrity sha512-LA0Y9kxMYv47GIPJy6MI84fqTd2HmYZI83W/kM/SkKfDlajnZYfmXFTxkbY+xSBPkLJxltMa9hIkmdc29eguMA== +qs@^6.10.3: + version "6.13.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.13.0.tgz#6ca3bd58439f7e245655798997787b0d88a51906" + integrity sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg== + dependencies: + side-channel "^1.0.6" + queue-microtask@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" @@ -3058,6 +3142,18 @@ semver@^7.5.3, semver@^7.5.4: dependencies: lru-cache "^6.0.0" +set-function-length@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" + integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== + dependencies: + define-data-property "^1.1.4" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + gopd "^1.0.1" + has-property-descriptors "^1.0.2" + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" @@ -3070,6 +3166,16 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== +side-channel@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.6.tgz#abd25fb7cd24baf45466406b1096b7831c9215f2" + integrity sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA== + dependencies: + call-bind "^1.0.7" + es-errors "^1.3.0" + get-intrinsic "^1.2.4" + object-inspect "^1.13.1" + signal-exit@^3.0.3, signal-exit@^3.0.7: version "3.0.7" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"