Skip to content

Commit 708f8e2

Browse files
feat(api): updates (#967)
- This commit removes the `AssistantResponseFormat` type
1 parent b70ac5b commit 708f8e2

File tree

22 files changed

+238
-77
lines changed

22 files changed

+238
-77
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b04761ffd2adad3cc19a6dc6fc696ac445878219972f891881a967340fa9a6b0.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-4097c2f86beb3f3bb021775cd1dfa240e960caf842aeefc2e08da4dc0851ea79.yml

api.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Types:
55
- <code><a href="./src/resources/shared.ts">ErrorObject</a></code>
66
- <code><a href="./src/resources/shared.ts">FunctionDefinition</a></code>
77
- <code><a href="./src/resources/shared.ts">FunctionParameters</a></code>
8+
- <code><a href="./src/resources/shared.ts">ResponseFormatJSONObject</a></code>
9+
- <code><a href="./src/resources/shared.ts">ResponseFormatJSONSchema</a></code>
10+
- <code><a href="./src/resources/shared.ts">ResponseFormatText</a></code>
811

912
# Completions
1013

@@ -33,6 +36,7 @@ Types:
3336
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionChunk</a></code>
3437
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPart</a></code>
3538
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartImage</a></code>
39+
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartRefusal</a></code>
3640
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartText</a></code>
3741
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionFunctionCallOption</a></code>
3842
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionFunctionMessageParam</a></code>
@@ -259,7 +263,6 @@ Methods:
259263

260264
Types:
261265

262-
- <code><a href="./src/resources/beta/threads/threads.ts">AssistantResponseFormat</a></code>
263266
- <code><a href="./src/resources/beta/threads/threads.ts">AssistantResponseFormatOption</a></code>
264267
- <code><a href="./src/resources/beta/threads/threads.ts">AssistantToolChoice</a></code>
265268
- <code><a href="./src/resources/beta/threads/threads.ts">AssistantToolChoiceFunction</a></code>
@@ -344,6 +347,8 @@ Types:
344347
- <code><a href="./src/resources/beta/threads/messages.ts">MessageDeleted</a></code>
345348
- <code><a href="./src/resources/beta/threads/messages.ts">MessageDelta</a></code>
346349
- <code><a href="./src/resources/beta/threads/messages.ts">MessageDeltaEvent</a></code>
350+
- <code><a href="./src/resources/beta/threads/messages.ts">RefusalContentBlock</a></code>
351+
- <code><a href="./src/resources/beta/threads/messages.ts">RefusalDeltaBlock</a></code>
347352
- <code><a href="./src/resources/beta/threads/messages.ts">Text</a></code>
348353
- <code><a href="./src/resources/beta/threads/messages.ts">TextContentBlock</a></code>
349354
- <code><a href="./src/resources/beta/threads/messages.ts">TextContentBlockParam</a></code>

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ export namespace OpenAI {
248248
export import ChatCompletionChunk = API.ChatCompletionChunk;
249249
export import ChatCompletionContentPart = API.ChatCompletionContentPart;
250250
export import ChatCompletionContentPartImage = API.ChatCompletionContentPartImage;
251+
export import ChatCompletionContentPartRefusal = API.ChatCompletionContentPartRefusal;
251252
export import ChatCompletionContentPartText = API.ChatCompletionContentPartText;
252253
export import ChatCompletionFunctionCallOption = API.ChatCompletionFunctionCallOption;
253254
export import ChatCompletionFunctionMessageParam = API.ChatCompletionFunctionMessageParam;
@@ -322,6 +323,9 @@ export namespace OpenAI {
322323
export import ErrorObject = API.ErrorObject;
323324
export import FunctionDefinition = API.FunctionDefinition;
324325
export import FunctionParameters = API.FunctionParameters;
326+
export import ResponseFormatJSONObject = API.ResponseFormatJSONObject;
327+
export import ResponseFormatJSONSchema = API.ResponseFormatJSONSchema;
328+
export import ResponseFormatText = API.ResponseFormatText;
325329
}
326330

327331
export default OpenAI;

src/resources/beta/assistants.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ export interface Assistant {
149149
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
150150
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
151151
*
152+
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
153+
* Outputs which guarantees the model will match your supplied JSON schema. Learn
154+
* more in the
155+
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
156+
*
152157
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
153158
* message the model generates is valid JSON.
154159
*
@@ -648,8 +653,8 @@ export namespace FileSearchTool {
648653
export interface FileSearch {
649654
/**
650655
* The maximum number of results the file search tool should output. The default is
651-
* 20 for gpt-4\* models and 5 for gpt-3.5-turbo. This number should be between 1
652-
* and 50 inclusive.
656+
* 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
657+
* 1 and 50 inclusive.
653658
*
654659
* Note that the file search tool may output fewer than `max_num_results` results.
655660
* See the
@@ -1086,6 +1091,11 @@ export interface AssistantCreateParams {
10861091
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
10871092
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
10881093
*
1094+
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
1095+
* Outputs which guarantees the model will match your supplied JSON schema. Learn
1096+
* more in the
1097+
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
1098+
*
10891099
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
10901100
* message the model generates is valid JSON.
10911101
*
@@ -1278,6 +1288,11 @@ export interface AssistantUpdateParams {
12781288
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
12791289
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
12801290
*
1291+
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
1292+
* Outputs which guarantees the model will match your supplied JSON schema. Learn
1293+
* more in the
1294+
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
1295+
*
12811296
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
12821297
* message the model generates is valid JSON.
12831298
*

src/resources/beta/beta.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export namespace Beta {
3636
export import AssistantUpdateParams = AssistantsAPI.AssistantUpdateParams;
3737
export import AssistantListParams = AssistantsAPI.AssistantListParams;
3838
export import Threads = ThreadsAPI.Threads;
39-
export import AssistantResponseFormat = ThreadsAPI.AssistantResponseFormat;
4039
export import AssistantResponseFormatOption = ThreadsAPI.AssistantResponseFormatOption;
4140
export import AssistantToolChoice = ThreadsAPI.AssistantToolChoice;
4241
export import AssistantToolChoiceFunction = ThreadsAPI.AssistantToolChoiceFunction;

src/resources/beta/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export {
1919
Assistants,
2020
} from './assistants';
2121
export {
22-
AssistantResponseFormat,
2322
AssistantResponseFormatOption,
2423
AssistantToolChoice,
2524
AssistantToolChoiceFunction,

src/resources/beta/threads/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export {
2222
MessageDeleted,
2323
MessageDelta,
2424
MessageDeltaEvent,
25+
RefusalContentBlock,
26+
RefusalDeltaBlock,
2527
Text,
2628
TextContentBlock,
2729
TextContentBlockParam,
@@ -34,7 +36,6 @@ export {
3436
Messages,
3537
} from './messages';
3638
export {
37-
AssistantResponseFormat,
3839
AssistantResponseFormatOption,
3940
AssistantToolChoice,
4041
AssistantToolChoiceFunction,

src/resources/beta/threads/messages.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,21 @@ export namespace Message {
481481
* References an image [File](https://platform.openai.com/docs/api-reference/files)
482482
* in the content of a message.
483483
*/
484-
export type MessageContent = ImageFileContentBlock | ImageURLContentBlock | TextContentBlock;
484+
export type MessageContent =
485+
| ImageFileContentBlock
486+
| ImageURLContentBlock
487+
| TextContentBlock
488+
| RefusalContentBlock;
485489

486490
/**
487491
* References an image [File](https://platform.openai.com/docs/api-reference/files)
488492
* in the content of a message.
489493
*/
490-
export type MessageContentDelta = ImageFileDeltaBlock | TextDeltaBlock | ImageURLDeltaBlock;
494+
export type MessageContentDelta =
495+
| ImageFileDeltaBlock
496+
| TextDeltaBlock
497+
| RefusalDeltaBlock
498+
| ImageURLDeltaBlock;
491499

492500
/**
493501
* References an image [File](https://platform.openai.com/docs/api-reference/files)
@@ -539,6 +547,35 @@ export interface MessageDeltaEvent {
539547
object: 'thread.message.delta';
540548
}
541549

550+
/**
551+
* The refusal content generated by the assistant.
552+
*/
553+
export interface RefusalContentBlock {
554+
refusal: string;
555+
556+
/**
557+
* Always `refusal`.
558+
*/
559+
type: 'refusal';
560+
}
561+
562+
/**
563+
* The refusal content that is part of a message.
564+
*/
565+
export interface RefusalDeltaBlock {
566+
/**
567+
* The index of the refusal part in the message.
568+
*/
569+
index: number;
570+
571+
/**
572+
* Always `refusal`.
573+
*/
574+
type: 'refusal';
575+
576+
refusal?: string;
577+
}
578+
542579
export interface Text {
543580
annotations: Array<Annotation>;
544581

@@ -707,6 +744,8 @@ export namespace Messages {
707744
export import MessageDeleted = MessagesAPI.MessageDeleted;
708745
export import MessageDelta = MessagesAPI.MessageDelta;
709746
export import MessageDeltaEvent = MessagesAPI.MessageDeltaEvent;
747+
export import RefusalContentBlock = MessagesAPI.RefusalContentBlock;
748+
export import RefusalDeltaBlock = MessagesAPI.RefusalDeltaBlock;
710749
export import Text = MessagesAPI.Text;
711750
export import TextContentBlock = MessagesAPI.TextContentBlock;
712751
export import TextContentBlockParam = MessagesAPI.TextContentBlockParam;

src/resources/beta/threads/runs/runs.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ export interface Run {
296296
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
297297
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
298298
*
299+
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
300+
* Outputs which guarantees the model will match your supplied JSON schema. Learn
301+
* more in the
302+
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
303+
*
299304
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
300305
* message the model generates is valid JSON.
301306
*
@@ -558,6 +563,11 @@ export interface RunCreateParamsBase {
558563
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
559564
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
560565
*
566+
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
567+
* Outputs which guarantees the model will match your supplied JSON schema. Learn
568+
* more in the
569+
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
570+
*
561571
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
562572
* message the model generates is valid JSON.
563573
*

src/resources/beta/threads/threads.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { isRequestOptions } from '../../../core';
55
import { APIPromise } from '../../../core';
66
import * as Core from '../../../core';
77
import * as ThreadsAPI from './threads';
8+
import * as Shared from '../../shared';
89
import * as AssistantsAPI from '../assistants';
910
import * as ChatAPI from '../../chat/chat';
1011
import * as MessagesAPI from './messages';
@@ -93,24 +94,17 @@ export class Threads extends APIResource {
9394
}
9495
}
9596

96-
/**
97-
* An object describing the expected output of the model. If `json_object` only
98-
* `function` type `tools` are allowed to be passed to the Run. If `text` the model
99-
* can return text or any value needed.
100-
*/
101-
export interface AssistantResponseFormat {
102-
/**
103-
* Must be one of `text` or `json_object`.
104-
*/
105-
type?: 'text' | 'json_object';
106-
}
107-
10897
/**
10998
* Specifies the format that the model must output. Compatible with
11099
* [GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
111100
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
112101
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
113102
*
103+
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
104+
* Outputs which guarantees the model will match your supplied JSON schema. Learn
105+
* more in the
106+
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
107+
*
114108
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
115109
* message the model generates is valid JSON.
116110
*
@@ -122,7 +116,11 @@ export interface AssistantResponseFormat {
122116
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
123117
* max context length.
124118
*/
125-
export type AssistantResponseFormatOption = 'none' | 'auto' | AssistantResponseFormat;
119+
export type AssistantResponseFormatOption =
120+
| 'auto'
121+
| Shared.ResponseFormatText
122+
| Shared.ResponseFormatJSONObject
123+
| Shared.ResponseFormatJSONSchema;
126124

127125
/**
128126
* Specifies a tool the model should use. Use to force the model to call a specific
@@ -537,6 +535,11 @@ export interface ThreadCreateAndRunParamsBase {
537535
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
538536
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
539537
*
538+
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
539+
* Outputs which guarantees the model will match your supplied JSON schema. Learn
540+
* more in the
541+
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
542+
*
540543
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
541544
* message the model generates is valid JSON.
542545
*
@@ -876,7 +879,6 @@ export interface ThreadCreateAndRunParamsStreaming extends ThreadCreateAndRunPar
876879
}
877880

878881
export namespace Threads {
879-
export import AssistantResponseFormat = ThreadsAPI.AssistantResponseFormat;
880882
export import AssistantResponseFormatOption = ThreadsAPI.AssistantResponseFormatOption;
881883
export import AssistantToolChoice = ThreadsAPI.AssistantToolChoice;
882884
export import AssistantToolChoiceFunction = ThreadsAPI.AssistantToolChoiceFunction;
@@ -923,6 +925,8 @@ export namespace Threads {
923925
export import MessageDeleted = MessagesAPI.MessageDeleted;
924926
export import MessageDelta = MessagesAPI.MessageDelta;
925927
export import MessageDeltaEvent = MessagesAPI.MessageDeltaEvent;
928+
export import RefusalContentBlock = MessagesAPI.RefusalContentBlock;
929+
export import RefusalDeltaBlock = MessagesAPI.RefusalDeltaBlock;
926930
export import Text = MessagesAPI.Text;
927931
export import TextContentBlock = MessagesAPI.TextContentBlock;
928932
export import TextContentBlockParam = MessagesAPI.TextContentBlockParam;

src/resources/beta/vector-stores/files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export namespace VectorStoreFile {
146146
/**
147147
* One of `server_error` or `rate_limit_exceeded`.
148148
*/
149-
code: 'internal_error' | 'file_not_found' | 'parsing_error' | 'unhandled_mime_type';
149+
code: 'server_error' | 'unsupported_file' | 'invalid_file';
150150

151151
/**
152152
* A human-readable description of the error.

src/resources/chat/chat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class Chat extends APIResource {
1010

1111
export type ChatModel =
1212
| 'gpt-4o'
13+
| 'gpt-4o-2024-08-06'
1314
| 'gpt-4o-2024-05-13'
1415
| 'gpt-4o-mini'
1516
| 'gpt-4o-mini-2024-07-18'
@@ -41,6 +42,7 @@ export namespace Chat {
4142
export import ChatCompletionChunk = CompletionsAPI.ChatCompletionChunk;
4243
export import ChatCompletionContentPart = CompletionsAPI.ChatCompletionContentPart;
4344
export import ChatCompletionContentPartImage = CompletionsAPI.ChatCompletionContentPartImage;
45+
export import ChatCompletionContentPartRefusal = CompletionsAPI.ChatCompletionContentPartRefusal;
4446
export import ChatCompletionContentPartText = CompletionsAPI.ChatCompletionContentPartText;
4547
export import ChatCompletionFunctionCallOption = CompletionsAPI.ChatCompletionFunctionCallOption;
4648
export import ChatCompletionFunctionMessageParam = CompletionsAPI.ChatCompletionFunctionMessageParam;

0 commit comments

Comments
 (0)