Skip to content

Commit c071491

Browse files
stainless-app[bot]RobertCraigie
authored andcommitted
feat(api): new streaming helpers for background responses
1 parent 3ffca5c commit c071491

File tree

7 files changed

+34
-138
lines changed

7 files changed

+34
-138
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 111
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-6af14840a810139bf407013167ce1c8fb21b6ef8eb0cc3db58b51af7d52c4b5a.yml
3-
openapi_spec_hash: 3241bde6b273cfec0035e522bd07985d
4-
config_hash: 7367b68a4e7db36885c1a886f57b17f6
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fc64d7c2c8f51f750813375356c3f3fdfc7fc1b1b34f19c20a5410279d445d37.yml
3+
openapi_spec_hash: 618285fc70199ee32b9ebe4bf72f7e4c
4+
config_hash: c497f6b750cc89c0bf2eefc0bc839c70

api.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,6 @@ Types:
691691
- <code><a href="./src/resources/responses/responses.ts">ResponseRefusalDoneEvent</a></code>
692692
- <code><a href="./src/resources/responses/responses.ts">ResponseStatus</a></code>
693693
- <code><a href="./src/resources/responses/responses.ts">ResponseStreamEvent</a></code>
694-
- <code><a href="./src/resources/responses/responses.ts">ResponseTextAnnotationDeltaEvent</a></code>
695694
- <code><a href="./src/resources/responses/responses.ts">ResponseTextConfig</a></code>
696695
- <code><a href="./src/resources/responses/responses.ts">ResponseTextDeltaEvent</a></code>
697696
- <code><a href="./src/resources/responses/responses.ts">ResponseTextDoneEvent</a></code>

src/resources/beta/realtime/realtime.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ export namespace RealtimeClientEvent {
928928
* the server to stop generating audio and emit a `output_audio_buffer.cleared`
929929
* event. This event should be preceded by a `response.cancel` client event to stop
930930
* the generation of the current response.
931-
* [Learn more](https://platform.openai.com/docs/guides/realtime-model-capabilities#client-and-server-events-for-audio-in-webrtc).
931+
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
932932
*/
933933
export interface OutputAudioBufferClear {
934934
/**
@@ -1227,7 +1227,7 @@ export namespace RealtimeServerEvent {
12271227
* **WebRTC Only:** Emitted when the server begins streaming audio to the client.
12281228
* This event is emitted after an audio content part has been added
12291229
* (`response.content_part.added`) to the response.
1230-
* [Learn more](https://platform.openai.com/docs/guides/realtime-model-capabilities#client-and-server-events-for-audio-in-webrtc).
1230+
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
12311231
*/
12321232
export interface OutputAudioBufferStarted {
12331233
/**
@@ -1250,7 +1250,7 @@ export namespace RealtimeServerEvent {
12501250
* **WebRTC Only:** Emitted when the output audio buffer has been completely
12511251
* drained on the server, and no more audio is forthcoming. This event is emitted
12521252
* after the full response data has been sent to the client (`response.done`).
1253-
* [Learn more](https://platform.openai.com/docs/guides/realtime-model-capabilities#client-and-server-events-for-audio-in-webrtc).
1253+
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
12541254
*/
12551255
export interface OutputAudioBufferStopped {
12561256
/**
@@ -1275,7 +1275,7 @@ export namespace RealtimeServerEvent {
12751275
* (`input_audio_buffer.speech_started`), or when the client has emitted the
12761276
* `output_audio_buffer.clear` event to manually cut off the current audio
12771277
* response.
1278-
* [Learn more](https://platform.openai.com/docs/guides/realtime-model-capabilities#client-and-server-events-for-audio-in-webrtc).
1278+
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
12791279
*/
12801280
export interface OutputAudioBufferCleared {
12811281
/**

src/resources/chat/completions/completions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,8 +1437,8 @@ export interface ChatCompletionCreateParamsBase {
14371437
top_p?: number | null;
14381438

14391439
/**
1440-
* A unique identifier representing your end-user, which can help OpenAI to monitor
1441-
* and detect abuse.
1440+
* A stable identifier for your end-users. Used to boost cache hit rates by better
1441+
* bucketing similar requests and to help OpenAI detect and prevent abuse.
14421442
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
14431443
*/
14441444
user?: string;

src/resources/containers/files/files.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { CursorPage, type CursorPageParams, PagePromise } from '../../../core/pa
88
import { type Uploadable } from '../../../core/uploads';
99
import { buildHeaders } from '../../../internal/headers';
1010
import { RequestOptions } from '../../../internal/request-options';
11+
import { multipartFormRequestOptions } from '../../../internal/uploads';
1112
import { path } from '../../../internal/utils/path';
1213

1314
export class Files extends APIResource {
@@ -24,7 +25,10 @@ export class Files extends APIResource {
2425
body: FileCreateParams,
2526
options?: RequestOptions,
2627
): APIPromise<FileCreateResponse> {
27-
return this._client.post(path`/containers/${containerID}/files`, { body, ...options });
28+
return this._client.post(
29+
path`/containers/${containerID}/files`,
30+
multipartFormRequestOptions({ body, ...options }, this._client),
31+
);
2832
}
2933

3034
/**

src/resources/responses/input-items.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export interface InputItemListParams extends CursorPageParams {
7777
include?: Array<ResponsesAPI.ResponseIncludable>;
7878

7979
/**
80-
* The order to return the input items in. Default is `asc`.
80+
* The order to return the input items in. Default is `desc`.
8181
*
8282
* - `asc`: Return the input items in ascending order.
8383
* - `desc`: Return the input items in descending order.

src/resources/responses/responses.ts

Lines changed: 19 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@ export interface Response {
443443
usage?: ResponseUsage;
444444

445445
/**
446-
* A unique identifier representing your end-user, which can help OpenAI to monitor
447-
* and detect abuse.
446+
* A stable identifier for your end-users. Used to boost cache hit rates by better
447+
* bucketing similar requests and to help OpenAI detect and prevent abuse.
448448
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
449449
*/
450450
user?: string;
@@ -3825,7 +3825,6 @@ export type ResponseStreamEvent =
38253825
| ResponseReasoningSummaryTextDoneEvent
38263826
| ResponseRefusalDeltaEvent
38273827
| ResponseRefusalDoneEvent
3828-
| ResponseTextAnnotationDeltaEvent
38293828
| ResponseTextDeltaEvent
38303829
| ResponseTextDoneEvent
38313830
| ResponseWebSearchCallCompletedEvent
@@ -3850,121 +3849,6 @@ export type ResponseStreamEvent =
38503849
| ResponseReasoningSummaryDeltaEvent
38513850
| ResponseReasoningSummaryDoneEvent;
38523851

3853-
/**
3854-
* Emitted when a text annotation is added.
3855-
*/
3856-
export interface ResponseTextAnnotationDeltaEvent {
3857-
/**
3858-
* A citation to a file.
3859-
*/
3860-
annotation:
3861-
| ResponseTextAnnotationDeltaEvent.FileCitation
3862-
| ResponseTextAnnotationDeltaEvent.URLCitation
3863-
| ResponseTextAnnotationDeltaEvent.FilePath;
3864-
3865-
/**
3866-
* The index of the annotation that was added.
3867-
*/
3868-
annotation_index: number;
3869-
3870-
/**
3871-
* The index of the content part that the text annotation was added to.
3872-
*/
3873-
content_index: number;
3874-
3875-
/**
3876-
* The ID of the output item that the text annotation was added to.
3877-
*/
3878-
item_id: string;
3879-
3880-
/**
3881-
* The index of the output item that the text annotation was added to.
3882-
*/
3883-
output_index: number;
3884-
3885-
/**
3886-
* The sequence number of this event.
3887-
*/
3888-
sequence_number: number;
3889-
3890-
/**
3891-
* The type of the event. Always `response.output_text.annotation.added`.
3892-
*/
3893-
type: 'response.output_text.annotation.added';
3894-
}
3895-
3896-
export namespace ResponseTextAnnotationDeltaEvent {
3897-
/**
3898-
* A citation to a file.
3899-
*/
3900-
export interface FileCitation {
3901-
/**
3902-
* The ID of the file.
3903-
*/
3904-
file_id: string;
3905-
3906-
/**
3907-
* The index of the file in the list of files.
3908-
*/
3909-
index: number;
3910-
3911-
/**
3912-
* The type of the file citation. Always `file_citation`.
3913-
*/
3914-
type: 'file_citation';
3915-
}
3916-
3917-
/**
3918-
* A citation for a web resource used to generate a model response.
3919-
*/
3920-
export interface URLCitation {
3921-
/**
3922-
* The index of the last character of the URL citation in the message.
3923-
*/
3924-
end_index: number;
3925-
3926-
/**
3927-
* The index of the first character of the URL citation in the message.
3928-
*/
3929-
start_index: number;
3930-
3931-
/**
3932-
* The title of the web resource.
3933-
*/
3934-
title: string;
3935-
3936-
/**
3937-
* The type of the URL citation. Always `url_citation`.
3938-
*/
3939-
type: 'url_citation';
3940-
3941-
/**
3942-
* The URL of the web resource.
3943-
*/
3944-
url: string;
3945-
}
3946-
3947-
/**
3948-
* A path to a file.
3949-
*/
3950-
export interface FilePath {
3951-
/**
3952-
* The ID of the file.
3953-
*/
3954-
file_id: string;
3955-
3956-
/**
3957-
* The index of the file in the list of files.
3958-
*/
3959-
index: number;
3960-
3961-
/**
3962-
* The type of the file path. Always `file_path`.
3963-
*/
3964-
type: 'file_path';
3965-
}
3966-
}
3967-
39683852
/**
39693853
* Configuration options for a text response from the model. Can be plain text or
39703854
* structured JSON data. Learn more:
@@ -4129,6 +4013,11 @@ export interface ResponseWebSearchCallCompletedEvent {
41294013
*/
41304014
output_index: number;
41314015

4016+
/**
4017+
* The sequence number of the web search call being processed.
4018+
*/
4019+
sequence_number: number;
4020+
41324021
/**
41334022
* The type of the event. Always `response.web_search_call.completed`.
41344023
*/
@@ -4149,6 +4038,11 @@ export interface ResponseWebSearchCallInProgressEvent {
41494038
*/
41504039
output_index: number;
41514040

4041+
/**
4042+
* The sequence number of the web search call being processed.
4043+
*/
4044+
sequence_number: number;
4045+
41524046
/**
41534047
* The type of the event. Always `response.web_search_call.in_progress`.
41544048
*/
@@ -4169,6 +4063,11 @@ export interface ResponseWebSearchCallSearchingEvent {
41694063
*/
41704064
output_index: number;
41714065

4066+
/**
4067+
* The sequence number of the web search call being processed.
4068+
*/
4069+
sequence_number: number;
4070+
41724071
/**
41734072
* The type of the event. Always `response.web_search_call.searching`.
41744073
*/
@@ -4248,11 +4147,6 @@ export namespace Tool {
42484147
* A list of tools that never require approval.
42494148
*/
42504149
never?: McpToolApprovalFilter.Never;
4251-
4252-
/**
4253-
* List of allowed tool names.
4254-
*/
4255-
tool_names?: Array<string>;
42564150
}
42574151

42584152
export namespace McpToolApprovalFilter {
@@ -4709,8 +4603,8 @@ export interface ResponseCreateParamsBase {
47094603
truncation?: 'auto' | 'disabled' | null;
47104604

47114605
/**
4712-
* A unique identifier representing your end-user, which can help OpenAI to monitor
4713-
* and detect abuse.
4606+
* A stable identifier for your end-users. Used to boost cache hit rates by better
4607+
* bucketing similar requests and to help OpenAI detect and prevent abuse.
47144608
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
47154609
*/
47164610
user?: string;
@@ -4842,7 +4736,6 @@ export declare namespace Responses {
48424736
type ResponseRefusalDoneEvent as ResponseRefusalDoneEvent,
48434737
type ResponseStatus as ResponseStatus,
48444738
type ResponseStreamEvent as ResponseStreamEvent,
4845-
type ResponseTextAnnotationDeltaEvent as ResponseTextAnnotationDeltaEvent,
48464739
type ResponseTextConfig as ResponseTextConfig,
48474740
type ResponseTextDeltaEvent as ResponseTextDeltaEvent,
48484741
type ResponseTextDoneEvent as ResponseTextDoneEvent,

0 commit comments

Comments
 (0)