openai 6.45.0 → 6.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/helpers/audio.d.mts.map +1 -1
- package/helpers/audio.d.ts.map +1 -1
- package/helpers/audio.js +16 -3
- package/helpers/audio.js.map +1 -1
- package/helpers/audio.mjs +17 -4
- package/helpers/audio.mjs.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.mts.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.ts.map +1 -1
- package/lib/AbstractChatCompletionRunner.js +14 -0
- package/lib/AbstractChatCompletionRunner.js.map +1 -1
- package/lib/AbstractChatCompletionRunner.mjs +14 -0
- package/lib/AbstractChatCompletionRunner.mjs.map +1 -1
- package/lib/AssistantStream.js +1 -1
- package/lib/AssistantStream.js.map +1 -1
- package/lib/AssistantStream.mjs +1 -1
- package/lib/AssistantStream.mjs.map +1 -1
- package/lib/ChatCompletionStream.d.mts.map +1 -1
- package/lib/ChatCompletionStream.d.ts.map +1 -1
- package/lib/ChatCompletionStream.js +7 -4
- package/lib/ChatCompletionStream.js.map +1 -1
- package/lib/ChatCompletionStream.mjs +7 -4
- package/lib/ChatCompletionStream.mjs.map +1 -1
- package/lib/responses/ResponseAccumulator.d.mts +6 -1
- package/lib/responses/ResponseAccumulator.d.mts.map +1 -1
- package/lib/responses/ResponseAccumulator.d.ts +6 -1
- package/lib/responses/ResponseAccumulator.d.ts.map +1 -1
- package/lib/responses/ResponseAccumulator.js +1 -0
- package/lib/responses/ResponseAccumulator.js.map +1 -1
- package/lib/responses/ResponseAccumulator.mjs +1 -0
- package/lib/responses/ResponseAccumulator.mjs.map +1 -1
- package/lib/responses/ResponseInputItems.d.mts.map +1 -1
- package/lib/responses/ResponseInputItems.d.ts.map +1 -1
- package/lib/responses/ResponseInputItems.js +2 -0
- package/lib/responses/ResponseInputItems.js.map +1 -1
- package/lib/responses/ResponseInputItems.mjs +2 -0
- package/lib/responses/ResponseInputItems.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/assistants.d.mts +12 -26
- package/resources/beta/assistants.d.mts.map +1 -1
- package/resources/beta/assistants.d.ts +12 -26
- package/resources/beta/assistants.d.ts.map +1 -1
- package/resources/beta/beta.d.mts +6 -1
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +6 -1
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js +4 -0
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs +4 -0
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/index.d.mts +1 -0
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +1 -0
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js +5 -3
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs +1 -0
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/responses/index.d.mts +6 -0
- package/resources/beta/responses/index.d.mts.map +1 -0
- package/resources/beta/responses/index.d.ts +6 -0
- package/resources/beta/responses/index.d.ts.map +1 -0
- package/resources/beta/responses/index.js +11 -0
- package/resources/beta/responses/index.js.map +1 -0
- package/resources/beta/responses/index.mjs +5 -0
- package/resources/beta/responses/index.mjs.map +1 -0
- package/resources/beta/responses/input-items.d.mts +69 -0
- package/resources/beta/responses/input-items.d.mts.map +1 -0
- package/resources/beta/responses/input-items.d.ts +69 -0
- package/resources/beta/responses/input-items.d.ts.map +1 -0
- package/resources/beta/responses/input-items.js +37 -0
- package/resources/beta/responses/input-items.js.map +1 -0
- package/resources/beta/responses/input-items.mjs +33 -0
- package/resources/beta/responses/input-items.mjs.map +1 -0
- package/resources/beta/responses/input-tokens.d.mts +191 -0
- package/resources/beta/responses/input-tokens.d.mts.map +1 -0
- package/resources/beta/responses/input-tokens.d.ts +191 -0
- package/resources/beta/responses/input-tokens.d.ts.map +1 -0
- package/resources/beta/responses/input-tokens.js +34 -0
- package/resources/beta/responses/input-tokens.js.map +1 -0
- package/resources/beta/responses/input-tokens.mjs +30 -0
- package/resources/beta/responses/input-tokens.mjs.map +1 -0
- package/resources/beta/responses/internal-base.d.mts +71 -0
- package/resources/beta/responses/internal-base.d.mts.map +1 -0
- package/resources/beta/responses/internal-base.d.ts +71 -0
- package/resources/beta/responses/internal-base.d.ts.map +1 -0
- package/resources/beta/responses/internal-base.js +48 -0
- package/resources/beta/responses/internal-base.js.map +1 -0
- package/resources/beta/responses/internal-base.mjs +42 -0
- package/resources/beta/responses/internal-base.mjs.map +1 -0
- package/resources/beta/responses/responses.d.mts +9985 -0
- package/resources/beta/responses/responses.d.mts.map +1 -0
- package/resources/beta/responses/responses.d.ts +9985 -0
- package/resources/beta/responses/responses.d.ts.map +1 -0
- package/resources/beta/responses/responses.js +121 -0
- package/resources/beta/responses/responses.js.map +1 -0
- package/resources/beta/responses/responses.mjs +116 -0
- package/resources/beta/responses/responses.mjs.map +1 -0
- package/resources/beta/responses/ws-base.d.mts +106 -0
- package/resources/beta/responses/ws-base.d.mts.map +1 -0
- package/resources/beta/responses/ws-base.d.ts +106 -0
- package/resources/beta/responses/ws-base.d.ts.map +1 -0
- package/resources/beta/responses/ws-base.js +476 -0
- package/resources/beta/responses/ws-base.js.map +1 -0
- package/resources/beta/responses/ws-base.mjs +472 -0
- package/resources/beta/responses/ws-base.mjs.map +1 -0
- package/resources/beta/responses/ws.d.mts +13 -0
- package/resources/beta/responses/ws.d.mts.map +1 -0
- package/resources/beta/responses/ws.d.ts +13 -0
- package/resources/beta/responses/ws.d.ts.map +1 -0
- package/resources/beta/responses/ws.js +31 -0
- package/resources/beta/responses/ws.js.map +1 -0
- package/resources/beta/responses/ws.mjs +26 -0
- package/resources/beta/responses/ws.mjs.map +1 -0
- package/resources/beta/responses.d.mts +2 -0
- package/resources/beta/responses.d.mts.map +1 -0
- package/resources/beta/responses.d.ts +2 -0
- package/resources/beta/responses.d.ts.map +1 -0
- package/resources/beta/responses.js +6 -0
- package/resources/beta/responses.js.map +1 -0
- package/resources/beta/responses.mjs +3 -0
- package/resources/beta/responses.mjs.map +1 -0
- package/resources/beta/threads/runs/runs.d.mts +6 -13
- package/resources/beta/threads/runs/runs.d.mts.map +1 -1
- package/resources/beta/threads/runs/runs.d.ts +6 -13
- package/resources/beta/threads/runs/runs.d.ts.map +1 -1
- package/resources/beta/threads/runs/runs.js.map +1 -1
- package/resources/beta/threads/runs/runs.mjs.map +1 -1
- package/resources/chat/completions/completions.d.mts +155 -14
- package/resources/chat/completions/completions.d.mts.map +1 -1
- package/resources/chat/completions/completions.d.ts +155 -14
- package/resources/chat/completions/completions.d.ts.map +1 -1
- package/resources/chat/completions/completions.js.map +1 -1
- package/resources/chat/completions/completions.mjs.map +1 -1
- package/resources/completions.d.mts +4 -0
- package/resources/completions.d.mts.map +1 -1
- package/resources/completions.d.ts +4 -0
- package/resources/completions.d.ts.map +1 -1
- package/resources/conversations/conversations.d.mts +19 -0
- package/resources/conversations/conversations.d.mts.map +1 -1
- package/resources/conversations/conversations.d.ts +19 -0
- package/resources/conversations/conversations.d.ts.map +1 -1
- package/resources/conversations/conversations.js.map +1 -1
- package/resources/conversations/conversations.mjs.map +1 -1
- package/resources/conversations/items.d.mts +45 -1
- package/resources/conversations/items.d.mts.map +1 -1
- package/resources/conversations/items.d.ts +45 -1
- package/resources/conversations/items.d.ts.map +1 -1
- package/resources/evals/runs/runs.d.mts +66 -143
- package/resources/evals/runs/runs.d.mts.map +1 -1
- package/resources/evals/runs/runs.d.ts +66 -143
- package/resources/evals/runs/runs.d.ts.map +1 -1
- package/resources/evals/runs/runs.js.map +1 -1
- package/resources/evals/runs/runs.mjs.map +1 -1
- package/resources/graders/grader-models.d.mts +6 -13
- package/resources/graders/grader-models.d.mts.map +1 -1
- package/resources/graders/grader-models.d.ts +6 -13
- package/resources/graders/grader-models.d.ts.map +1 -1
- package/resources/realtime/calls.d.mts +1 -1
- package/resources/realtime/calls.d.mts.map +1 -1
- package/resources/realtime/calls.d.ts +1 -1
- package/resources/realtime/calls.d.ts.map +1 -1
- package/resources/realtime/client-secrets.d.mts +5 -1
- package/resources/realtime/client-secrets.d.mts.map +1 -1
- package/resources/realtime/client-secrets.d.ts +5 -1
- package/resources/realtime/client-secrets.d.ts.map +1 -1
- package/resources/realtime/realtime.d.mts +9 -1
- package/resources/realtime/realtime.d.mts.map +1 -1
- package/resources/realtime/realtime.d.ts +9 -1
- package/resources/realtime/realtime.d.ts.map +1 -1
- package/resources/realtime/realtime.js.map +1 -1
- package/resources/realtime/realtime.mjs.map +1 -1
- package/resources/responses/input-tokens.d.mts +7 -1
- package/resources/responses/input-tokens.d.mts.map +1 -1
- package/resources/responses/input-tokens.d.ts +7 -1
- package/resources/responses/input-tokens.d.ts.map +1 -1
- package/resources/responses/responses.d.mts +816 -24
- package/resources/responses/responses.d.mts.map +1 -1
- package/resources/responses/responses.d.ts +816 -24
- package/resources/responses/responses.d.ts.map +1 -1
- package/resources/responses/responses.js +1 -1
- package/resources/responses/responses.js.map +1 -1
- package/resources/responses/responses.mjs +1 -1
- package/resources/responses/responses.mjs.map +1 -1
- package/resources/shared.d.mts +20 -28
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +20 -28
- package/resources/shared.d.ts.map +1 -1
- package/resources/webhooks/webhooks.d.mts +54 -2
- package/resources/webhooks/webhooks.d.mts.map +1 -1
- package/resources/webhooks/webhooks.d.ts +54 -2
- package/resources/webhooks/webhooks.d.ts.map +1 -1
- package/src/helpers/audio.ts +18 -4
- package/src/lib/AbstractChatCompletionRunner.ts +15 -0
- package/src/lib/AssistantStream.ts +1 -1
- package/src/lib/ChatCompletionStream.ts +7 -4
- package/src/lib/responses/ResponseAccumulator.ts +10 -1
- package/src/lib/responses/ResponseInputItems.ts +2 -0
- package/src/resources/beta/assistants.ts +12 -26
- package/src/resources/beta/beta.ts +330 -2
- package/src/resources/beta/index.ts +163 -0
- package/src/resources/beta/responses/index.ts +169 -0
- package/src/resources/beta/responses/input-items.ts +105 -0
- package/src/resources/beta/responses/input-tokens.ts +245 -0
- package/src/resources/beta/responses/internal-base.ts +117 -0
- package/src/resources/beta/responses/responses.ts +12632 -0
- package/src/resources/beta/responses/ws-base.ts +615 -0
- package/src/resources/beta/responses/ws.ts +38 -0
- package/src/resources/beta/responses.ts +3 -0
- package/src/resources/beta/threads/runs/runs.ts +6 -13
- package/src/resources/chat/completions/completions.ts +171 -14
- package/src/resources/completions.ts +5 -0
- package/src/resources/conversations/conversations.ts +21 -0
- package/src/resources/conversations/items.ts +56 -0
- package/src/resources/evals/runs/runs.ts +66 -143
- package/src/resources/graders/grader-models.ts +6 -13
- package/src/resources/realtime/calls.ts +2 -0
- package/src/resources/realtime/client-secrets.ts +7 -0
- package/src/resources/realtime/realtime.ts +12 -0
- package/src/resources/responses/input-tokens.ts +8 -0
- package/src/resources/responses/responses.ts +950 -15
- package/src/resources/shared.ts +23 -27
- package/src/resources/webhooks/api.md +1 -0
- package/src/resources/webhooks/webhooks.ts +65 -1
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { APIResource } from "../../../core/resource.js";
|
|
2
|
+
import * as ResponsesAPI from "./responses.js";
|
|
3
|
+
import { APIPromise } from "../../../core/api-promise.js";
|
|
4
|
+
import { RequestOptions } from "../../../internal/request-options.js";
|
|
5
|
+
export declare class InputTokens extends APIResource {
|
|
6
|
+
/**
|
|
7
|
+
* Returns input token counts of the request.
|
|
8
|
+
*
|
|
9
|
+
* Returns an object with `object` set to `response.input_tokens` and an
|
|
10
|
+
* `input_tokens` count.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const response =
|
|
15
|
+
* await client.beta.responses.inputTokens.count();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
count(params?: InputTokenCountParams | null | undefined, options?: RequestOptions): APIPromise<InputTokenCountResponse>;
|
|
19
|
+
}
|
|
20
|
+
export interface InputTokenCountResponse {
|
|
21
|
+
input_tokens: number;
|
|
22
|
+
object: 'response.input_tokens';
|
|
23
|
+
}
|
|
24
|
+
export interface InputTokenCountParams {
|
|
25
|
+
/**
|
|
26
|
+
* Body param: The conversation that this response belongs to. Items from this
|
|
27
|
+
* conversation are prepended to `input_items` for this response request. Input
|
|
28
|
+
* items and output items from this response are automatically added to this
|
|
29
|
+
* conversation after this response completes.
|
|
30
|
+
*/
|
|
31
|
+
conversation?: string | ResponsesAPI.BetaResponseConversationParam | null;
|
|
32
|
+
/**
|
|
33
|
+
* Body param: Text, image, or file inputs to the model, used to generate a
|
|
34
|
+
* response
|
|
35
|
+
*/
|
|
36
|
+
input?: string | Array<ResponsesAPI.BetaResponseInputItem> | null;
|
|
37
|
+
/**
|
|
38
|
+
* Body param: A system (or developer) message inserted into the model's context.
|
|
39
|
+
* When used along with `previous_response_id`, the instructions from a previous
|
|
40
|
+
* response will not be carried over to the next response. This makes it simple to
|
|
41
|
+
* swap out system (or developer) messages in new responses.
|
|
42
|
+
*/
|
|
43
|
+
instructions?: string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Body param: Model ID used to generate the response, like `gpt-4o` or `o3`.
|
|
46
|
+
* OpenAI offers a wide range of models with different capabilities, performance
|
|
47
|
+
* characteristics, and price points. Refer to the
|
|
48
|
+
* [model guide](https://platform.openai.com/docs/models) to browse and compare
|
|
49
|
+
* available models.
|
|
50
|
+
*/
|
|
51
|
+
model?: string | null;
|
|
52
|
+
/**
|
|
53
|
+
* Body param: Whether to allow the model to run tool calls in parallel.
|
|
54
|
+
*/
|
|
55
|
+
parallel_tool_calls?: boolean | null;
|
|
56
|
+
/**
|
|
57
|
+
* Body param: A model-owned style preset to apply to this request. Omit this
|
|
58
|
+
* parameter to use the model's default style. Supported values may expand over
|
|
59
|
+
* time. Values must be at most 64 characters.
|
|
60
|
+
*/
|
|
61
|
+
personality?: (string & {}) | 'friendly' | 'pragmatic';
|
|
62
|
+
/**
|
|
63
|
+
* Body param: The unique ID of the previous response to the model. Use this to
|
|
64
|
+
* create multi-turn conversations. Learn more about
|
|
65
|
+
* [conversation state](https://platform.openai.com/docs/guides/conversation-state).
|
|
66
|
+
* Cannot be used in conjunction with `conversation`.
|
|
67
|
+
*/
|
|
68
|
+
previous_response_id?: string | null;
|
|
69
|
+
/**
|
|
70
|
+
* Body param: **gpt-5 and o-series models only** Configuration options for
|
|
71
|
+
* [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
|
72
|
+
*/
|
|
73
|
+
reasoning?: InputTokenCountParams.Reasoning | null;
|
|
74
|
+
/**
|
|
75
|
+
* Body param: Configuration options for a text response from the model. Can be
|
|
76
|
+
* plain text or structured JSON data. Learn more:
|
|
77
|
+
*
|
|
78
|
+
* - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
|
79
|
+
* - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
|
|
80
|
+
*/
|
|
81
|
+
text?: InputTokenCountParams.Text | null;
|
|
82
|
+
/**
|
|
83
|
+
* Body param: Controls which tool the model should use, if any.
|
|
84
|
+
*/
|
|
85
|
+
tool_choice?: ResponsesAPI.BetaToolChoiceOptions | ResponsesAPI.BetaToolChoiceAllowed | ResponsesAPI.BetaToolChoiceTypes | ResponsesAPI.BetaToolChoiceFunction | ResponsesAPI.BetaToolChoiceMcp | ResponsesAPI.BetaToolChoiceCustom | InputTokenCountParams.BetaSpecificProgrammaticToolCallingParam | ResponsesAPI.BetaToolChoiceApplyPatch | ResponsesAPI.BetaToolChoiceShell | null;
|
|
86
|
+
/**
|
|
87
|
+
* Body param: An array of tools the model may call while generating a response.
|
|
88
|
+
* You can specify which tool to use by setting the `tool_choice` parameter.
|
|
89
|
+
*/
|
|
90
|
+
tools?: Array<ResponsesAPI.BetaTool> | null;
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Body param: The truncation strategy to use for the model response. -
|
|
93
|
+
* `auto`: If the input to this Response exceeds the model's context window size,
|
|
94
|
+
* the model will truncate the response to fit the context window by dropping items
|
|
95
|
+
* from the beginning of the conversation. - `disabled` (default): If the input
|
|
96
|
+
* size will exceed the context window size for a model, the request will fail with
|
|
97
|
+
* a 400 error.
|
|
98
|
+
*/
|
|
99
|
+
truncation?: 'auto' | 'disabled';
|
|
100
|
+
/**
|
|
101
|
+
* Header param: Optional beta features to enable for this request.
|
|
102
|
+
*/
|
|
103
|
+
betas?: Array<'responses_multi_agent=v1'>;
|
|
104
|
+
}
|
|
105
|
+
export declare namespace InputTokenCountParams {
|
|
106
|
+
/**
|
|
107
|
+
* **gpt-5 and o-series models only** Configuration options for
|
|
108
|
+
* [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
|
109
|
+
*/
|
|
110
|
+
interface Reasoning {
|
|
111
|
+
/**
|
|
112
|
+
* Controls which reasoning items are rendered back to the model on later turns.
|
|
113
|
+
* When returned on a response, this is the effective reasoning context mode used
|
|
114
|
+
* for the response.
|
|
115
|
+
*/
|
|
116
|
+
context?: 'auto' | 'current_turn' | 'all_turns' | null;
|
|
117
|
+
/**
|
|
118
|
+
* Constrains effort on reasoning for reasoning models. Currently supported values
|
|
119
|
+
* are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing
|
|
120
|
+
* reasoning effort can result in faster responses and fewer tokens used on
|
|
121
|
+
* reasoning in a response. Not all reasoning models support every value. See the
|
|
122
|
+
* [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for
|
|
123
|
+
* model-specific support.
|
|
124
|
+
*/
|
|
125
|
+
effort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null;
|
|
126
|
+
/**
|
|
127
|
+
* @deprecated **Deprecated:** use `summary` instead.
|
|
128
|
+
*
|
|
129
|
+
* A summary of the reasoning performed by the model. This can be useful for
|
|
130
|
+
* debugging and understanding the model's reasoning process. One of `auto`,
|
|
131
|
+
* `concise`, or `detailed`.
|
|
132
|
+
*/
|
|
133
|
+
generate_summary?: 'auto' | 'concise' | 'detailed' | null;
|
|
134
|
+
/**
|
|
135
|
+
* Controls the reasoning execution mode for the request.
|
|
136
|
+
*
|
|
137
|
+
* When returned on a response, this is the effective execution mode.
|
|
138
|
+
*/
|
|
139
|
+
mode?: (string & {}) | 'standard' | 'pro';
|
|
140
|
+
/**
|
|
141
|
+
* A summary of the reasoning performed by the model. This can be useful for
|
|
142
|
+
* debugging and understanding the model's reasoning process. One of `auto`,
|
|
143
|
+
* `concise`, or `detailed`.
|
|
144
|
+
*
|
|
145
|
+
* `concise` is supported for `computer-use-preview` models and all reasoning
|
|
146
|
+
* models after `gpt-5`.
|
|
147
|
+
*/
|
|
148
|
+
summary?: 'auto' | 'concise' | 'detailed' | null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Configuration options for a text response from the model. Can be plain text or
|
|
152
|
+
* structured JSON data. Learn more:
|
|
153
|
+
*
|
|
154
|
+
* - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
|
155
|
+
* - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
|
|
156
|
+
*/
|
|
157
|
+
interface Text {
|
|
158
|
+
/**
|
|
159
|
+
* An object specifying the format that the model must output.
|
|
160
|
+
*
|
|
161
|
+
* Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
|
|
162
|
+
* ensures the model will match your supplied JSON schema. Learn more in the
|
|
163
|
+
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
|
|
164
|
+
*
|
|
165
|
+
* The default format is `{ "type": "text" }` with no additional options.
|
|
166
|
+
*
|
|
167
|
+
* **Not recommended for gpt-4o and newer models:**
|
|
168
|
+
*
|
|
169
|
+
* Setting to `{ "type": "json_object" }` enables the older JSON mode, which
|
|
170
|
+
* ensures the message the model generates is valid JSON. Using `json_schema` is
|
|
171
|
+
* preferred for models that support it.
|
|
172
|
+
*/
|
|
173
|
+
format?: ResponsesAPI.BetaResponseFormatTextConfig;
|
|
174
|
+
/**
|
|
175
|
+
* Constrains the verbosity of the model's response. Lower values will result in
|
|
176
|
+
* more concise responses, while higher values will result in more verbose
|
|
177
|
+
* responses. Currently supported values are `low`, `medium`, and `high`.
|
|
178
|
+
*/
|
|
179
|
+
verbosity?: 'low' | 'medium' | 'high' | null;
|
|
180
|
+
}
|
|
181
|
+
interface BetaSpecificProgrammaticToolCallingParam {
|
|
182
|
+
/**
|
|
183
|
+
* The tool to call. Always `programmatic_tool_calling`.
|
|
184
|
+
*/
|
|
185
|
+
type: 'programmatic_tool_calling';
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
export declare namespace InputTokens {
|
|
189
|
+
export { type InputTokenCountResponse as InputTokenCountResponse, type InputTokenCountParams as InputTokenCountParams, };
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=input-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-tokens.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/responses/input-tokens.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,kCAA+B;AACrD,OAAO,KAAK,YAAY,uBAAoB;AAC5C,OAAO,EAAE,UAAU,EAAE,qCAAkC;AAEvD,OAAO,EAAE,cAAc,EAAE,6CAA0C;AAEnE,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;;;;;;;;;;OAWG;IACH,KAAK,CACH,MAAM,GAAE,qBAAqB,GAAG,IAAI,GAAG,SAAc,EACrD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,uBAAuB,CAAC;CAYvC;AAED,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,CAAC;IAErB,MAAM,EAAE,uBAAuB,CAAC;CACjC;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,6BAA6B,GAAG,IAAI,CAAC;IAE1E;;;OAGG;IACH,KAAK,CAAC,E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,GAAG,WAAW,GAAG,IAAI,CAAC;QAEvD;;;;;;;WAOG;QACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC;QAEjF;;;;;;WAMG;QACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,CAAC;QAE1D;;;;WAIG;QACH,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,UAAU,GAAG,KAAK,CAAC;QAE1C;;;;;;;WAOG;QACH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,CAAC;KAClD;IAED;;;;;;OAMG;IACH,UAAiB,IAAI;QACnB;;;;;;;;;;;;;;WAcG;QACH,MAAM,CAAC,EAAE,YAAY,CAAC,4BAA4B,CAAC;QAEnD;;;;WAIG;QACH,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC;KAC9C;IAED,UAAiB,wCAAwC;QACvD;;WAEG;QACH,IAAI,EAAE,2BAA2B,CAAC;KACnC;CACF;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,OAAO,EACL,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,qBAAqB,IAAI,qBAAqB,GACpD,CAAC;CACH"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.InputTokens = void 0;
|
|
5
|
+
const resource_1 = require("../../../core/resource.js");
|
|
6
|
+
const headers_1 = require("../../../internal/headers.js");
|
|
7
|
+
class InputTokens extends resource_1.APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Returns input token counts of the request.
|
|
10
|
+
*
|
|
11
|
+
* Returns an object with `object` set to `response.input_tokens` and an
|
|
12
|
+
* `input_tokens` count.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const response =
|
|
17
|
+
* await client.beta.responses.inputTokens.count();
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
count(params = {}, options) {
|
|
21
|
+
const { betas, ...body } = params ?? {};
|
|
22
|
+
return this._client.post('/responses/input_tokens?beta=true', {
|
|
23
|
+
body,
|
|
24
|
+
...options,
|
|
25
|
+
headers: (0, headers_1.buildHeaders)([
|
|
26
|
+
{ ...(betas?.toString() != null ? { 'openai-beta': betas?.toString() } : undefined) },
|
|
27
|
+
options?.headers,
|
|
28
|
+
]),
|
|
29
|
+
__security: { bearerAuth: true },
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.InputTokens = InputTokens;
|
|
34
|
+
//# sourceMappingURL=input-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-tokens.js","sourceRoot":"","sources":["../../../src/resources/beta/responses/input-tokens.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wDAAqD;AAGrD,0DAAyD;AAGzD,MAAa,WAAY,SAAQ,sBAAW;IAC1C;;;;;;;;;;;OAWG;IACH,KAAK,CACH,SAAmD,EAAE,EACrD,OAAwB;QAExB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE;YAC5D,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC;gBACpB,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;gBACrF,OAAO,EAAE,OAAO;aACjB,CAAC;YACF,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AA5BD,kCA4BC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../../../core/resource.mjs";
|
|
3
|
+
import { buildHeaders } from "../../../internal/headers.mjs";
|
|
4
|
+
export class InputTokens extends APIResource {
|
|
5
|
+
/**
|
|
6
|
+
* Returns input token counts of the request.
|
|
7
|
+
*
|
|
8
|
+
* Returns an object with `object` set to `response.input_tokens` and an
|
|
9
|
+
* `input_tokens` count.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const response =
|
|
14
|
+
* await client.beta.responses.inputTokens.count();
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
count(params = {}, options) {
|
|
18
|
+
const { betas, ...body } = params ?? {};
|
|
19
|
+
return this._client.post('/responses/input_tokens?beta=true', {
|
|
20
|
+
body,
|
|
21
|
+
...options,
|
|
22
|
+
headers: buildHeaders([
|
|
23
|
+
{ ...(betas?.toString() != null ? { 'openai-beta': betas?.toString() } : undefined) },
|
|
24
|
+
options?.headers,
|
|
25
|
+
]),
|
|
26
|
+
__security: { bearerAuth: true },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=input-tokens.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-tokens.mjs","sourceRoot":"","sources":["../../../src/resources/beta/responses/input-tokens.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AAGrD,OAAO,EAAE,YAAY,EAAE,sCAAkC;AAGzD,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C;;;;;;;;;;;OAWG;IACH,KAAK,CACH,SAAmD,EAAE,EACrD,OAAwB;QAExB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE;YAC5D,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC;gBACpB,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;gBACrF,OAAO,EAAE,OAAO;aACjB,CAAC;YACF,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as ResponsesAPI from "./responses.mjs";
|
|
2
|
+
import { OpenAI } from "../../../client.mjs";
|
|
3
|
+
import { EventEmitter } from "../../../core/EventEmitter.mjs";
|
|
4
|
+
import { OpenAIError } from "../../../core/error.mjs";
|
|
5
|
+
import type { RawWebSocketData, ReconnectingEvent, UnsentMessage } from "../../../internal/ws.mjs";
|
|
6
|
+
export type ResponsesStreamMessage = {
|
|
7
|
+
type: 'connecting' | 'open' | 'closing';
|
|
8
|
+
} | {
|
|
9
|
+
type: 'close';
|
|
10
|
+
code: number;
|
|
11
|
+
reason: string;
|
|
12
|
+
unsent: UnsentMessage<ResponsesAPI.BetaResponsesClientEvent>[];
|
|
13
|
+
} | {
|
|
14
|
+
type: 'reconnecting';
|
|
15
|
+
reconnect: ReconnectingEvent;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'reconnected';
|
|
18
|
+
} | {
|
|
19
|
+
type: 'message';
|
|
20
|
+
message: ResponsesAPI.BetaResponsesServerEvent;
|
|
21
|
+
} | {
|
|
22
|
+
type: 'raw';
|
|
23
|
+
data: RawWebSocketData;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'error';
|
|
26
|
+
error: WebSocketError;
|
|
27
|
+
};
|
|
28
|
+
export declare class WebSocketError extends OpenAIError {
|
|
29
|
+
/**
|
|
30
|
+
* The error data that the API sent back in an error event.
|
|
31
|
+
*/
|
|
32
|
+
error?: ResponsesAPI.BetaResponseErrorEvent | undefined;
|
|
33
|
+
constructor(message: string, event: ResponsesAPI.BetaResponseErrorEvent | null);
|
|
34
|
+
}
|
|
35
|
+
type Simplify<T> = {
|
|
36
|
+
[KeyType in keyof T]: T[KeyType];
|
|
37
|
+
} & {};
|
|
38
|
+
type WebSocketEvents = Simplify<{
|
|
39
|
+
event: (event: ResponsesAPI.BetaResponsesServerEvent) => void;
|
|
40
|
+
raw: (data: RawWebSocketData) => void;
|
|
41
|
+
error: (error: WebSocketError) => void;
|
|
42
|
+
close: (code: number, reason: string, unsent: UnsentMessage<ResponsesAPI.BetaResponsesClientEvent>[]) => void;
|
|
43
|
+
reconnecting: (event: ReconnectingEvent) => void;
|
|
44
|
+
reconnected: () => void;
|
|
45
|
+
} & {
|
|
46
|
+
[EventType in Exclude<NonNullable<ResponsesAPI.BetaResponsesServerEvent['type']>, 'error'>]: (event: Extract<ResponsesAPI.BetaResponsesServerEvent, {
|
|
47
|
+
type?: EventType;
|
|
48
|
+
}>) => unknown;
|
|
49
|
+
}>;
|
|
50
|
+
export declare abstract class ResponsesEmitter extends EventEmitter<WebSocketEvents> {
|
|
51
|
+
/**
|
|
52
|
+
* Send an event to the API.
|
|
53
|
+
*/
|
|
54
|
+
abstract send(event: ResponsesAPI.BetaResponsesClientEvent): void;
|
|
55
|
+
/**
|
|
56
|
+
* Send raw data over the WebSocket without JSON serialization.
|
|
57
|
+
*/
|
|
58
|
+
abstract sendRaw(data: RawWebSocketData): void;
|
|
59
|
+
/**
|
|
60
|
+
* Close the WebSocket connection.
|
|
61
|
+
*/
|
|
62
|
+
abstract close(props?: {
|
|
63
|
+
code: number;
|
|
64
|
+
reason: string;
|
|
65
|
+
}): void;
|
|
66
|
+
protected _onError(event: null, message: string, cause: any): void;
|
|
67
|
+
protected _onError(event: ResponsesAPI.BetaResponseErrorEvent, message?: string | undefined): void;
|
|
68
|
+
}
|
|
69
|
+
export declare function buildURL(client: OpenAI, parameters: Record<string, unknown>): URL;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=internal-base.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-base.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/responses/internal-base.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,YAAY,wBAAoB;AAC5C,OAAO,EAAE,MAAM,EAAE,4BAAwB;AACzC,OAAO,EAAE,YAAY,EAAE,uCAAmC;AAC1D,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAElD,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,iCAA6B;AAE/F,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,GAC3C;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,CAAC,YAAY,CAAC,wBAAwB,CAAC,EAAE,CAAC;CAChE,GACD;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,iBAAiB,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,YAAY,CAAC,wBAAwB,CAAA;CAAE,GACnE;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,CAAC;AAE7C,qBAAa,cA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gBAAgB,GAAG,IAAI;IAE9C;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAE9D,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAClE,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,sBAAsB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;CA0BnG;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,CAMjF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as ResponsesAPI from "./responses.js";
|
|
2
|
+
import { OpenAI } from "../../../client.js";
|
|
3
|
+
import { EventEmitter } from "../../../core/EventEmitter.js";
|
|
4
|
+
import { OpenAIError } from "../../../core/error.js";
|
|
5
|
+
import type { RawWebSocketData, ReconnectingEvent, UnsentMessage } from "../../../internal/ws.js";
|
|
6
|
+
export type ResponsesStreamMessage = {
|
|
7
|
+
type: 'connecting' | 'open' | 'closing';
|
|
8
|
+
} | {
|
|
9
|
+
type: 'close';
|
|
10
|
+
code: number;
|
|
11
|
+
reason: string;
|
|
12
|
+
unsent: UnsentMessage<ResponsesAPI.BetaResponsesClientEvent>[];
|
|
13
|
+
} | {
|
|
14
|
+
type: 'reconnecting';
|
|
15
|
+
reconnect: ReconnectingEvent;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'reconnected';
|
|
18
|
+
} | {
|
|
19
|
+
type: 'message';
|
|
20
|
+
message: ResponsesAPI.BetaResponsesServerEvent;
|
|
21
|
+
} | {
|
|
22
|
+
type: 'raw';
|
|
23
|
+
data: RawWebSocketData;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'error';
|
|
26
|
+
error: WebSocketError;
|
|
27
|
+
};
|
|
28
|
+
export declare class WebSocketError extends OpenAIError {
|
|
29
|
+
/**
|
|
30
|
+
* The error data that the API sent back in an error event.
|
|
31
|
+
*/
|
|
32
|
+
error?: ResponsesAPI.BetaResponseErrorEvent | undefined;
|
|
33
|
+
constructor(message: string, event: ResponsesAPI.BetaResponseErrorEvent | null);
|
|
34
|
+
}
|
|
35
|
+
type Simplify<T> = {
|
|
36
|
+
[KeyType in keyof T]: T[KeyType];
|
|
37
|
+
} & {};
|
|
38
|
+
type WebSocketEvents = Simplify<{
|
|
39
|
+
event: (event: ResponsesAPI.BetaResponsesServerEvent) => void;
|
|
40
|
+
raw: (data: RawWebSocketData) => void;
|
|
41
|
+
error: (error: WebSocketError) => void;
|
|
42
|
+
close: (code: number, reason: string, unsent: UnsentMessage<ResponsesAPI.BetaResponsesClientEvent>[]) => void;
|
|
43
|
+
reconnecting: (event: ReconnectingEvent) => void;
|
|
44
|
+
reconnected: () => void;
|
|
45
|
+
} & {
|
|
46
|
+
[EventType in Exclude<NonNullable<ResponsesAPI.BetaResponsesServerEvent['type']>, 'error'>]: (event: Extract<ResponsesAPI.BetaResponsesServerEvent, {
|
|
47
|
+
type?: EventType;
|
|
48
|
+
}>) => unknown;
|
|
49
|
+
}>;
|
|
50
|
+
export declare abstract class ResponsesEmitter extends EventEmitter<WebSocketEvents> {
|
|
51
|
+
/**
|
|
52
|
+
* Send an event to the API.
|
|
53
|
+
*/
|
|
54
|
+
abstract send(event: ResponsesAPI.BetaResponsesClientEvent): void;
|
|
55
|
+
/**
|
|
56
|
+
* Send raw data over the WebSocket without JSON serialization.
|
|
57
|
+
*/
|
|
58
|
+
abstract sendRaw(data: RawWebSocketData): void;
|
|
59
|
+
/**
|
|
60
|
+
* Close the WebSocket connection.
|
|
61
|
+
*/
|
|
62
|
+
abstract close(props?: {
|
|
63
|
+
code: number;
|
|
64
|
+
reason: string;
|
|
65
|
+
}): void;
|
|
66
|
+
protected _onError(event: null, message: string, cause: any): void;
|
|
67
|
+
protected _onError(event: ResponsesAPI.BetaResponseErrorEvent, message?: string | undefined): void;
|
|
68
|
+
}
|
|
69
|
+
export declare function buildURL(client: OpenAI, parameters: Record<string, unknown>): URL;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=internal-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-base.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/responses/internal-base.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,YAAY,uBAAoB;AAC5C,OAAO,EAAE,MAAM,EAAE,2BAAwB;AACzC,OAAO,EAAE,YAAY,EAAE,sCAAmC;AAC1D,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAElD,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,gCAA6B;AAE/F,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,GAC3C;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,CAAC,YAAY,CAAC,wBAAwB,CAAC,EAAE,CAAC;CAChE,GACD;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,iBAAiB,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,YAAY,CAAC,wBAAwB,CAAA;CAAE,GACnE;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,CAAC;AAE7C,qBAAa,cAAe,SAAQ,WAAW;IAC7C;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9C;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAE9D,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAClE,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,sBAAsB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;CA0BnG;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,CAMjF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ResponsesEmitter = exports.WebSocketError = void 0;
|
|
5
|
+
exports.buildURL = buildURL;
|
|
6
|
+
const EventEmitter_1 = require("../../../core/EventEmitter.js");
|
|
7
|
+
const error_1 = require("../../../core/error.js");
|
|
8
|
+
class WebSocketError extends error_1.OpenAIError {
|
|
9
|
+
constructor(message, event) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.error = event ?? undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.WebSocketError = WebSocketError;
|
|
15
|
+
class ResponsesEmitter extends EventEmitter_1.EventEmitter {
|
|
16
|
+
_onError(event, message, cause) {
|
|
17
|
+
message = message ?? safeJSONStringify(event) ?? 'unknown error';
|
|
18
|
+
if (!this._hasListener('error')) {
|
|
19
|
+
const error = new WebSocketError(message +
|
|
20
|
+
`\n\nTo resolve these unhandled rejection errors you should bind an \`error\` callback, e.g. \`ws.on('error', (error) => ...)\` `, event);
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
error.cause = cause;
|
|
23
|
+
Promise.reject(error);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const error = new WebSocketError(message, event);
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
error.cause = cause;
|
|
29
|
+
this._emit('error', error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ResponsesEmitter = ResponsesEmitter;
|
|
33
|
+
function buildURL(client, parameters) {
|
|
34
|
+
const { ...query } = parameters;
|
|
35
|
+
const endpoint = '/responses';
|
|
36
|
+
const url = new URL(client.buildURL(endpoint, query, undefined));
|
|
37
|
+
url.protocol = url.protocol === 'http:' || url.protocol === 'ws:' ? 'ws:' : 'wss:';
|
|
38
|
+
return url;
|
|
39
|
+
}
|
|
40
|
+
function safeJSONStringify(value) {
|
|
41
|
+
try {
|
|
42
|
+
return JSON.stringify(value);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=internal-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-base.js","sourceRoot":"","sources":["../../../src/resources/beta/responses/internal-base.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAsGtF,4BAMC;AAxGD,gEAA0D;AAC1D,kDAAkD;AAkBlD,MAAa,cAAe,SAAQ,mBAAW;IAM7C,YAAY,OAAe,EAAE,KAAiD;QAC5E,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,SAAS,CAAC;IAClC,CAAC;CACF;AAXD,wCAWC;AAuBD,MAAsB,gBAAiB,SAAQ,2BAA6B;IAkBhE,QAAQ,CAChB,KAAiD,EACjD,OAA4B,EAC5B,KAAW;QAEX,OAAO,GAAG,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC;QAEjE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,IAAI,cAAc,CAC9B,OAAO;gBACL,iIAAiI,EACnI,KAAK,CACN,CAAC;YACF,aAAa;YACb,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;YACpB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACtB,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACjD,aAAa;QACb,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QAEpB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF;AA3CD,4CA2CC;AAED,SAAgB,QAAQ,CAAC,MAAc,EAAE,UAAmC;IAC1E,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,UAAU,CAAC;IAChC,MAAM,QAAQ,GAAG,YAAY,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;IACjE,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IACnF,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { EventEmitter } from "../../../core/EventEmitter.mjs";
|
|
3
|
+
import { OpenAIError } from "../../../core/error.mjs";
|
|
4
|
+
export class WebSocketError extends OpenAIError {
|
|
5
|
+
constructor(message, event) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.error = event ?? undefined;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class ResponsesEmitter extends EventEmitter {
|
|
11
|
+
_onError(event, message, cause) {
|
|
12
|
+
message = message ?? safeJSONStringify(event) ?? 'unknown error';
|
|
13
|
+
if (!this._hasListener('error')) {
|
|
14
|
+
const error = new WebSocketError(message +
|
|
15
|
+
`\n\nTo resolve these unhandled rejection errors you should bind an \`error\` callback, e.g. \`ws.on('error', (error) => ...)\` `, event);
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
error.cause = cause;
|
|
18
|
+
Promise.reject(error);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const error = new WebSocketError(message, event);
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
error.cause = cause;
|
|
24
|
+
this._emit('error', error);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function buildURL(client, parameters) {
|
|
28
|
+
const { ...query } = parameters;
|
|
29
|
+
const endpoint = '/responses';
|
|
30
|
+
const url = new URL(client.buildURL(endpoint, query, undefined));
|
|
31
|
+
url.protocol = url.protocol === 'http:' || url.protocol === 'ws:' ? 'ws:' : 'wss:';
|
|
32
|
+
return url;
|
|
33
|
+
}
|
|
34
|
+
function safeJSONStringify(value) {
|
|
35
|
+
try {
|
|
36
|
+
return JSON.stringify(value);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=internal-base.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-base.mjs","sourceRoot":"","sources":["../../../src/resources/beta/responses/internal-base.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAItF,OAAO,EAAE,YAAY,EAAE,uCAAmC;AAC1D,O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