|
7 | 7 | addOutputText,
|
8 | 8 | } from '../../lib/ResponsesParser';
|
9 | 9 | import * as Core from '../../core';
|
10 |
| -import { APIPromise, isRequestOptions } from '../../core'; |
| 10 | +import { APIPromise } from '../../core'; |
11 | 11 | import { APIResource } from '../../resource';
|
12 | 12 | import * as Shared from '../shared';
|
13 | 13 | import * as InputItemsAPI from './input-items';
|
@@ -117,38 +117,26 @@ export class Responses extends APIResource {
|
117 | 117 | responseId: string,
|
118 | 118 | query?: ResponseRetrieveParamsNonStreaming,
|
119 | 119 | options?: Core.RequestOptions,
|
120 |
| - ): Core.APIPromise<Response>; |
| 120 | + ): APIPromise<Response>; |
121 | 121 | retrieve(
|
122 | 122 | responseId: string,
|
123 |
| - query?: ResponseRetrieveParamsStreaming, |
| 123 | + query: ResponseRetrieveParamsStreaming, |
124 | 124 | options?: Core.RequestOptions,
|
125 |
| - ): Core.APIPromise<Stream<ResponseStreamEvent>>; |
126 |
| - retrieve(responseId: string, options?: Core.RequestOptions): Core.APIPromise<Response>; |
| 125 | + ): APIPromise<Stream<ResponseStreamEvent>>; |
127 | 126 | retrieve(
|
128 | 127 | responseId: string,
|
129 |
| - query: ResponseRetrieveParams | Core.RequestOptions, |
| 128 | + query?: ResponseRetrieveParamsBase | undefined, |
130 | 129 | options?: Core.RequestOptions,
|
131 |
| - ): Core.APIPromise<Response> | Core.APIPromise<Stream<ResponseStreamEvent>>; |
| 130 | + ): APIPromise<Stream<ResponseStreamEvent> | Response>; |
132 | 131 | retrieve(
|
133 | 132 | responseId: string,
|
134 |
| - query: ResponseRetrieveParams | Core.RequestOptions = {}, |
| 133 | + query: ResponseRetrieveParams | undefined = {}, |
135 | 134 | options?: Core.RequestOptions,
|
136 |
| - ): Core.APIPromise<Response> | Core.APIPromise<Stream<ResponseStreamEvent>> { |
137 |
| - if (isRequestOptions(query) && options === undefined) { |
138 |
| - return this.retrieve(responseId, {}, query); |
139 |
| - } |
140 |
| - return ( |
141 |
| - this._client.get(`/responses/${responseId}`, { |
142 |
| - query, |
143 |
| - ...options, |
144 |
| - stream: query.stream ?? false, |
145 |
| - }) as APIPromise<Response> | APIPromise<Stream<ResponseStreamEvent>> |
146 |
| - )._thenUnwrap((rsp) => { |
147 |
| - if ('object' in rsp && rsp.object === 'response') { |
148 |
| - addOutputText(rsp as Response); |
149 |
| - } |
150 |
| - |
151 |
| - return rsp; |
| 135 | + ): APIPromise<Response> | APIPromise<Stream<ResponseStreamEvent>> { |
| 136 | + return this._client.get(`/responses/${responseId}`, { |
| 137 | + query, |
| 138 | + ...options, |
| 139 | + stream: query?.stream ?? false, |
152 | 140 | }) as APIPromise<Response> | APIPromise<Stream<ResponseStreamEvent>>;
|
153 | 141 | }
|
154 | 142 |
|
@@ -3320,6 +3308,8 @@ export interface ResponseOutputText {
|
3320 | 3308 | * The type of the output text. Always `output_text`.
|
3321 | 3309 | */
|
3322 | 3310 | type: 'output_text';
|
| 3311 | + |
| 3312 | + logprobs?: Array<ResponseOutputText.Logprob>; |
3323 | 3313 | }
|
3324 | 3314 |
|
3325 | 3315 | export namespace ResponseOutputText {
|
@@ -3392,6 +3382,32 @@ export namespace ResponseOutputText {
|
3392 | 3382 | */
|
3393 | 3383 | type: 'file_path';
|
3394 | 3384 | }
|
| 3385 | + |
| 3386 | + /** |
| 3387 | + * The log probability of a token. |
| 3388 | + */ |
| 3389 | + export interface Logprob { |
| 3390 | + token: string; |
| 3391 | + |
| 3392 | + bytes: Array<number>; |
| 3393 | + |
| 3394 | + logprob: number; |
| 3395 | + |
| 3396 | + top_logprobs: Array<Logprob.TopLogprob>; |
| 3397 | + } |
| 3398 | + |
| 3399 | + export namespace Logprob { |
| 3400 | + /** |
| 3401 | + * The top log probability of a token. |
| 3402 | + */ |
| 3403 | + export interface TopLogprob { |
| 3404 | + token: string; |
| 3405 | + |
| 3406 | + bytes: Array<number>; |
| 3407 | + |
| 3408 | + logprob: number; |
| 3409 | + } |
| 3410 | + } |
3395 | 3411 | }
|
3396 | 3412 |
|
3397 | 3413 | /**
|
@@ -4742,29 +4758,60 @@ export interface ResponseCreateParamsStreaming extends ResponseCreateParamsBase
|
4742 | 4758 | stream: true;
|
4743 | 4759 | }
|
4744 | 4760 |
|
4745 |
| -export type ResponseRetrieveParams = ResponseRetrieveParamsStreaming | ResponseRetrieveParamsNonStreaming; |
| 4761 | +export type ResponseRetrieveParams = ResponseRetrieveParamsNonStreaming | ResponseRetrieveParamsStreaming; |
| 4762 | + |
4746 | 4763 | export interface ResponseRetrieveParamsBase {
|
4747 | 4764 | /**
|
4748 | 4765 | * Additional fields to include in the response. See the `include` parameter for
|
4749 | 4766 | * Response creation above for more information.
|
4750 | 4767 | */
|
4751 | 4768 | include?: Array<ResponseIncludable>;
|
4752 | 4769 |
|
4753 |
| - starting_after?: number | null; |
4754 |
| - stream?: boolean | null; |
| 4770 | + /** |
| 4771 | + * The sequence number of the event after which to start streaming. |
| 4772 | + */ |
| 4773 | + starting_after?: number; |
| 4774 | + |
| 4775 | + /** |
| 4776 | + * If set to true, the model response data will be streamed to the client as it is |
| 4777 | + * generated using |
| 4778 | + * [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format). |
| 4779 | + * See the |
| 4780 | + * [Streaming section below](https://platform.openai.com/docs/api-reference/responses-streaming) |
| 4781 | + * for more information. |
| 4782 | + */ |
| 4783 | + stream?: boolean; |
4755 | 4784 | }
|
4756 | 4785 |
|
4757 |
| -export interface ResponseRetrieveParamsStreaming extends ResponseRetrieveParamsBase { |
4758 |
| - stream: true; |
| 4786 | +export namespace ResponseRetrieveParams { |
| 4787 | + export type ResponseRetrieveParamsNonStreaming = ResponsesAPI.ResponseRetrieveParamsNonStreaming; |
| 4788 | + export type ResponseRetrieveParamsStreaming = ResponsesAPI.ResponseRetrieveParamsStreaming; |
4759 | 4789 | }
|
| 4790 | + |
4760 | 4791 | export interface ResponseRetrieveParamsNonStreaming extends ResponseRetrieveParamsBase {
|
4761 |
| - stream?: false | null; |
| 4792 | + /** |
| 4793 | + * If set to true, the model response data will be streamed to the client as it is |
| 4794 | + * generated using |
| 4795 | + * [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format). |
| 4796 | + * See the |
| 4797 | + * [Streaming section below](https://platform.openai.com/docs/api-reference/responses-streaming) |
| 4798 | + * for more information. |
| 4799 | + */ |
| 4800 | + stream?: false; |
4762 | 4801 | }
|
4763 | 4802 |
|
4764 |
| -export namespace ResponseRetrieveParams { |
4765 |
| - export type ResponseRetrieveParamsStreaming = ResponsesAPI.ResponseRetrieveParamsStreaming; |
4766 |
| - export type ResponseRetrieveParamsNonStreaming = ResponsesAPI.ResponseRetrieveParamsNonStreaming; |
| 4803 | +export interface ResponseRetrieveParamsStreaming extends ResponseRetrieveParamsBase { |
| 4804 | + /** |
| 4805 | + * If set to true, the model response data will be streamed to the client as it is |
| 4806 | + * generated using |
| 4807 | + * [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format). |
| 4808 | + * See the |
| 4809 | + * [Streaming section below](https://platform.openai.com/docs/api-reference/responses-streaming) |
| 4810 | + * for more information. |
| 4811 | + */ |
| 4812 | + stream: true; |
4767 | 4813 | }
|
| 4814 | + |
4768 | 4815 | Responses.InputItems = InputItems;
|
4769 | 4816 |
|
4770 | 4817 | export declare namespace Responses {
|
@@ -4870,6 +4917,8 @@ export declare namespace Responses {
|
4870 | 4917 | type ResponseCreateParamsNonStreaming as ResponseCreateParamsNonStreaming,
|
4871 | 4918 | type ResponseCreateParamsStreaming as ResponseCreateParamsStreaming,
|
4872 | 4919 | type ResponseRetrieveParams as ResponseRetrieveParams,
|
| 4920 | + type ResponseRetrieveParamsNonStreaming as ResponseRetrieveParamsNonStreaming, |
| 4921 | + type ResponseRetrieveParamsStreaming as ResponseRetrieveParamsStreaming, |
4873 | 4922 | };
|
4874 | 4923 |
|
4875 | 4924 | export {
|
|
0 commit comments