Skip to content

Commit 4548326

Browse files
fix(types): improve responses type names (#1392)
1 parent d2be74a commit 4548326

File tree

6 files changed

+298
-234
lines changed

6 files changed

+298
-234
lines changed

Diff for: .stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 81
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-f763c1a35c8b9b02f1e31b9b2e09e21f98bfe8413e5079c86cbb07da2dd7779b.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-f3bce04386c4fcfd5037e0477fbaa39010003fd1558eb5185fe4a71dd6a05fdd.yml

Diff for: api.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,8 @@ Types:
548548
- <code><a href="./src/resources/responses/responses.ts">ResponseCodeInterpreterToolCall</a></code>
549549
- <code><a href="./src/resources/responses/responses.ts">ResponseCompletedEvent</a></code>
550550
- <code><a href="./src/resources/responses/responses.ts">ResponseComputerToolCall</a></code>
551+
- <code><a href="./src/resources/responses/responses.ts">ResponseComputerToolCallOutputItem</a></code>
552+
- <code><a href="./src/resources/responses/responses.ts">ResponseComputerToolCallOutputScreenshot</a></code>
551553
- <code><a href="./src/resources/responses/responses.ts">ResponseContent</a></code>
552554
- <code><a href="./src/resources/responses/responses.ts">ResponseContentPartAddedEvent</a></code>
553555
- <code><a href="./src/resources/responses/responses.ts">ResponseContentPartDoneEvent</a></code>
@@ -564,6 +566,8 @@ Types:
564566
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionCallArgumentsDeltaEvent</a></code>
565567
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionCallArgumentsDoneEvent</a></code>
566568
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionToolCall</a></code>
569+
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionToolCallItem</a></code>
570+
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionToolCallOutputItem</a></code>
567571
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionWebSearch</a></code>
568572
- <code><a href="./src/resources/responses/responses.ts">ResponseInProgressEvent</a></code>
569573
- <code><a href="./src/resources/responses/responses.ts">ResponseIncludable</a></code>
@@ -575,7 +579,9 @@ Types:
575579
- <code><a href="./src/resources/responses/responses.ts">ResponseInputImage</a></code>
576580
- <code><a href="./src/resources/responses/responses.ts">ResponseInputItem</a></code>
577581
- <code><a href="./src/resources/responses/responses.ts">ResponseInputMessageContentList</a></code>
582+
- <code><a href="./src/resources/responses/responses.ts">ResponseInputMessageItem</a></code>
578583
- <code><a href="./src/resources/responses/responses.ts">ResponseInputText</a></code>
584+
- <code><a href="./src/resources/responses/responses.ts">ResponseItem</a></code>
579585
- <code><a href="./src/resources/responses/responses.ts">ResponseOutputAudio</a></code>
580586
- <code><a href="./src/resources/responses/responses.ts">ResponseOutputItem</a></code>
581587
- <code><a href="./src/resources/responses/responses.ts">ResponseOutputItemAddedEvent</a></code>
@@ -616,4 +622,4 @@ Types:
616622

617623
Methods:
618624

619-
- <code title="get /responses/{response_id}/input_items">client.responses.inputItems.<a href="./src/resources/responses/input-items.ts">list</a>(responseId, { ...params }) -> ResponseItemListDataPage</code>
625+
- <code title="get /responses/{response_id}/input_items">client.responses.inputItems.<a href="./src/resources/responses/input-items.ts">list</a>(responseId, { ...params }) -> ResponseItemsPage</code>

Diff for: src/resources/responses/index.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
export {
4-
ResponseItemListDataPage,
5-
InputItems,
6-
type ResponseItemList,
7-
type InputItemListParams,
8-
} from './input-items';
3+
export { InputItems, type ResponseItemList, type InputItemListParams } from './input-items';
94
export { Responses } from './responses';

Diff for: src/resources/responses/input-items.ts

+10-200
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { APIResource } from '../../resource';
44
import { isRequestOptions } from '../../core';
55
import * as Core from '../../core';
66
import * as ResponsesAPI from './responses';
7-
import { CursorPage, type CursorPageParams } from '../../pagination';
7+
import { ResponseItemsPage } from './responses';
8+
import { type CursorPageParams } from '../../pagination';
89

910
export class InputItems extends APIResource {
1011
/**
@@ -14,85 +15,34 @@ export class InputItems extends APIResource {
1415
responseId: string,
1516
query?: InputItemListParams,
1617
options?: Core.RequestOptions,
17-
): Core.PagePromise<
18-
ResponseItemListDataPage,
19-
| ResponseItemList.Message
20-
| ResponsesAPI.ResponseOutputMessage
21-
| ResponsesAPI.ResponseFileSearchToolCall
22-
| ResponsesAPI.ResponseComputerToolCall
23-
| ResponseItemList.ComputerCallOutput
24-
| ResponsesAPI.ResponseFunctionWebSearch
25-
| ResponsesAPI.ResponseFunctionToolCall
26-
| ResponseItemList.FunctionCallOutput
27-
>;
18+
): Core.PagePromise<ResponseItemsPage, ResponsesAPI.ResponseItem>;
2819
list(
2920
responseId: string,
3021
options?: Core.RequestOptions,
31-
): Core.PagePromise<
32-
ResponseItemListDataPage,
33-
| ResponseItemList.Message
34-
| ResponsesAPI.ResponseOutputMessage
35-
| ResponsesAPI.ResponseFileSearchToolCall
36-
| ResponsesAPI.ResponseComputerToolCall
37-
| ResponseItemList.ComputerCallOutput
38-
| ResponsesAPI.ResponseFunctionWebSearch
39-
| ResponsesAPI.ResponseFunctionToolCall
40-
| ResponseItemList.FunctionCallOutput
41-
>;
22+
): Core.PagePromise<ResponseItemsPage, ResponsesAPI.ResponseItem>;
4223
list(
4324
responseId: string,
4425
query: InputItemListParams | Core.RequestOptions = {},
4526
options?: Core.RequestOptions,
46-
): Core.PagePromise<
47-
ResponseItemListDataPage,
48-
| ResponseItemList.Message
49-
| ResponsesAPI.ResponseOutputMessage
50-
| ResponsesAPI.ResponseFileSearchToolCall
51-
| ResponsesAPI.ResponseComputerToolCall
52-
| ResponseItemList.ComputerCallOutput
53-
| ResponsesAPI.ResponseFunctionWebSearch
54-
| ResponsesAPI.ResponseFunctionToolCall
55-
| ResponseItemList.FunctionCallOutput
56-
> {
27+
): Core.PagePromise<ResponseItemsPage, ResponsesAPI.ResponseItem> {
5728
if (isRequestOptions(query)) {
5829
return this.list(responseId, {}, query);
5930
}
60-
return this._client.getAPIList(`/responses/${responseId}/input_items`, ResponseItemListDataPage, {
31+
return this._client.getAPIList(`/responses/${responseId}/input_items`, ResponseItemsPage, {
6132
query,
6233
...options,
6334
});
6435
}
6536
}
6637

67-
export class ResponseItemListDataPage extends CursorPage<
68-
// @ts-ignore some items don't necessarily have the `id` property
69-
| ResponseItemList.Message
70-
| ResponsesAPI.ResponseOutputMessage
71-
| ResponsesAPI.ResponseFileSearchToolCall
72-
| ResponsesAPI.ResponseComputerToolCall
73-
| ResponseItemList.ComputerCallOutput
74-
| ResponsesAPI.ResponseFunctionWebSearch
75-
| ResponsesAPI.ResponseFunctionToolCall
76-
| ResponseItemList.FunctionCallOutput
77-
> {}
78-
7938
/**
8039
* A list of Response items.
8140
*/
8241
export interface ResponseItemList {
8342
/**
8443
* A list of items used to generate this response.
8544
*/
86-
data: Array<
87-
| ResponseItemList.Message
88-
| ResponsesAPI.ResponseOutputMessage
89-
| ResponsesAPI.ResponseFileSearchToolCall
90-
| ResponsesAPI.ResponseComputerToolCall
91-
| ResponseItemList.ComputerCallOutput
92-
| ResponsesAPI.ResponseFunctionWebSearch
93-
| ResponsesAPI.ResponseFunctionToolCall
94-
| ResponseItemList.FunctionCallOutput
95-
>;
45+
data: Array<ResponsesAPI.ResponseItem>;
9646

9747
/**
9848
* The ID of the first item in the list.
@@ -115,142 +65,6 @@ export interface ResponseItemList {
11565
object: 'list';
11666
}
11767

118-
export namespace ResponseItemList {
119-
export interface Message {
120-
/**
121-
* The unique ID of the message input.
122-
*/
123-
id: string;
124-
125-
/**
126-
* A list of one or many input items to the model, containing different content
127-
* types.
128-
*/
129-
content: ResponsesAPI.ResponseInputMessageContentList;
130-
131-
/**
132-
* The role of the message input. One of `user`, `system`, or `developer`.
133-
*/
134-
role: 'user' | 'system' | 'developer';
135-
136-
/**
137-
* The status of item. One of `in_progress`, `completed`, or `incomplete`.
138-
* Populated when items are returned via API.
139-
*/
140-
status?: 'in_progress' | 'completed' | 'incomplete';
141-
142-
/**
143-
* The type of the message input. Always set to `message`.
144-
*/
145-
type?: 'message';
146-
}
147-
148-
export interface ComputerCallOutput {
149-
/**
150-
* The unique ID of the computer call tool output.
151-
*/
152-
id: string;
153-
154-
/**
155-
* The ID of the computer tool call that produced the output.
156-
*/
157-
call_id: string;
158-
159-
/**
160-
* A computer screenshot image used with the computer use tool.
161-
*/
162-
output: ComputerCallOutput.Output;
163-
164-
/**
165-
* The type of the computer tool call output. Always `computer_call_output`.
166-
*/
167-
type: 'computer_call_output';
168-
169-
/**
170-
* The safety checks reported by the API that have been acknowledged by the
171-
* developer.
172-
*/
173-
acknowledged_safety_checks?: Array<ComputerCallOutput.AcknowledgedSafetyCheck>;
174-
175-
/**
176-
* The status of the message input. One of `in_progress`, `completed`, or
177-
* `incomplete`. Populated when input items are returned via API.
178-
*/
179-
status?: 'in_progress' | 'completed' | 'incomplete';
180-
}
181-
182-
export namespace ComputerCallOutput {
183-
/**
184-
* A computer screenshot image used with the computer use tool.
185-
*/
186-
export interface Output {
187-
/**
188-
* Specifies the event type. For a computer screenshot, this property is always set
189-
* to `computer_screenshot`.
190-
*/
191-
type: 'computer_screenshot';
192-
193-
/**
194-
* The identifier of an uploaded file that contains the screenshot.
195-
*/
196-
file_id?: string;
197-
198-
/**
199-
* The URL of the screenshot image.
200-
*/
201-
image_url?: string;
202-
}
203-
204-
/**
205-
* A pending safety check for the computer call.
206-
*/
207-
export interface AcknowledgedSafetyCheck {
208-
/**
209-
* The ID of the pending safety check.
210-
*/
211-
id: string;
212-
213-
/**
214-
* The type of the pending safety check.
215-
*/
216-
code: string;
217-
218-
/**
219-
* Details about the pending safety check.
220-
*/
221-
message: string;
222-
}
223-
}
224-
225-
export interface FunctionCallOutput {
226-
/**
227-
* The unique ID of the function call tool output.
228-
*/
229-
id: string;
230-
231-
/**
232-
* The unique ID of the function tool call generated by the model.
233-
*/
234-
call_id: string;
235-
236-
/**
237-
* A JSON string of the output of the function tool call.
238-
*/
239-
output: string;
240-
241-
/**
242-
* The type of the function tool call output. Always `function_call_output`.
243-
*/
244-
type: 'function_call_output';
245-
246-
/**
247-
* The status of the item. One of `in_progress`, `completed`, or `incomplete`.
248-
* Populated when items are returned via API.
249-
*/
250-
status?: 'in_progress' | 'completed' | 'incomplete';
251-
}
252-
}
253-
25468
export interface InputItemListParams extends CursorPageParams {
25569
/**
25670
* An item ID to list items before, used in pagination.
@@ -266,12 +80,8 @@ export interface InputItemListParams extends CursorPageParams {
26680
order?: 'asc' | 'desc';
26781
}
26882

269-
InputItems.ResponseItemListDataPage = ResponseItemListDataPage;
270-
27183
export declare namespace InputItems {
272-
export {
273-
type ResponseItemList as ResponseItemList,
274-
ResponseItemListDataPage as ResponseItemListDataPage,
275-
type InputItemListParams as InputItemListParams,
276-
};
84+
export { type ResponseItemList as ResponseItemList, type InputItemListParams as InputItemListParams };
27785
}
86+
87+
export { ResponseItemsPage };

0 commit comments

Comments
 (0)