Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): updates #967

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 68
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b04761ffd2adad3cc19a6dc6fc696ac445878219972f891881a967340fa9a6b0.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-4097c2f86beb3f3bb021775cd1dfa240e960caf842aeefc2e08da4dc0851ea79.yml
7 changes: 6 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Types:
- <code><a href="./src/resources/shared.ts">ErrorObject</a></code>
- <code><a href="./src/resources/shared.ts">FunctionDefinition</a></code>
- <code><a href="./src/resources/shared.ts">FunctionParameters</a></code>
- <code><a href="./src/resources/shared.ts">ResponseFormatJSONObject</a></code>
- <code><a href="./src/resources/shared.ts">ResponseFormatJSONSchema</a></code>
- <code><a href="./src/resources/shared.ts">ResponseFormatText</a></code>

# Completions

Expand Down Expand Up @@ -33,6 +36,7 @@ Types:
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionChunk</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPart</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartImage</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartRefusal</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartText</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionFunctionCallOption</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionFunctionMessageParam</a></code>
Expand Down Expand Up @@ -259,7 +263,6 @@ Methods:

Types:

- <code><a href="./src/resources/beta/threads/threads.ts">AssistantResponseFormat</a></code>
- <code><a href="./src/resources/beta/threads/threads.ts">AssistantResponseFormatOption</a></code>
- <code><a href="./src/resources/beta/threads/threads.ts">AssistantToolChoice</a></code>
- <code><a href="./src/resources/beta/threads/threads.ts">AssistantToolChoiceFunction</a></code>
Expand Down Expand Up @@ -344,6 +347,8 @@ Types:
- <code><a href="./src/resources/beta/threads/messages.ts">MessageDeleted</a></code>
- <code><a href="./src/resources/beta/threads/messages.ts">MessageDelta</a></code>
- <code><a href="./src/resources/beta/threads/messages.ts">MessageDeltaEvent</a></code>
- <code><a href="./src/resources/beta/threads/messages.ts">RefusalContentBlock</a></code>
- <code><a href="./src/resources/beta/threads/messages.ts">RefusalDeltaBlock</a></code>
- <code><a href="./src/resources/beta/threads/messages.ts">Text</a></code>
- <code><a href="./src/resources/beta/threads/messages.ts">TextContentBlock</a></code>
- <code><a href="./src/resources/beta/threads/messages.ts">TextContentBlockParam</a></code>
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export namespace OpenAI {
export import ChatCompletionChunk = API.ChatCompletionChunk;
export import ChatCompletionContentPart = API.ChatCompletionContentPart;
export import ChatCompletionContentPartImage = API.ChatCompletionContentPartImage;
export import ChatCompletionContentPartRefusal = API.ChatCompletionContentPartRefusal;
export import ChatCompletionContentPartText = API.ChatCompletionContentPartText;
export import ChatCompletionFunctionCallOption = API.ChatCompletionFunctionCallOption;
export import ChatCompletionFunctionMessageParam = API.ChatCompletionFunctionMessageParam;
Expand Down Expand Up @@ -322,6 +323,9 @@ export namespace OpenAI {
export import ErrorObject = API.ErrorObject;
export import FunctionDefinition = API.FunctionDefinition;
export import FunctionParameters = API.FunctionParameters;
export import ResponseFormatJSONObject = API.ResponseFormatJSONObject;
export import ResponseFormatJSONSchema = API.ResponseFormatJSONSchema;
export import ResponseFormatText = API.ResponseFormatText;
}

export default OpenAI;
19 changes: 17 additions & 2 deletions src/resources/beta/assistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ export interface Assistant {
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which guarantees the model will match your supplied JSON schema. Learn
* more in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
* message the model generates is valid JSON.
*
Expand Down Expand Up @@ -648,8 +653,8 @@ export namespace FileSearchTool {
export interface FileSearch {
/**
* The maximum number of results the file search tool should output. The default is
* 20 for gpt-4\* models and 5 for gpt-3.5-turbo. This number should be between 1
* and 50 inclusive.
* 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
* 1 and 50 inclusive.
*
* Note that the file search tool may output fewer than `max_num_results` results.
* See the
Expand Down Expand Up @@ -1086,6 +1091,11 @@ export interface AssistantCreateParams {
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which guarantees the model will match your supplied JSON schema. Learn
* more in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
* message the model generates is valid JSON.
*
Expand Down Expand Up @@ -1278,6 +1288,11 @@ export interface AssistantUpdateParams {
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which guarantees the model will match your supplied JSON schema. Learn
* more in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
* message the model generates is valid JSON.
*
Expand Down
1 change: 0 additions & 1 deletion src/resources/beta/beta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export namespace Beta {
export import AssistantUpdateParams = AssistantsAPI.AssistantUpdateParams;
export import AssistantListParams = AssistantsAPI.AssistantListParams;
export import Threads = ThreadsAPI.Threads;
export import AssistantResponseFormat = ThreadsAPI.AssistantResponseFormat;
export import AssistantResponseFormatOption = ThreadsAPI.AssistantResponseFormatOption;
export import AssistantToolChoice = ThreadsAPI.AssistantToolChoice;
export import AssistantToolChoiceFunction = ThreadsAPI.AssistantToolChoiceFunction;
Expand Down
1 change: 0 additions & 1 deletion src/resources/beta/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export {
Assistants,
} from './assistants';
export {
AssistantResponseFormat,
AssistantResponseFormatOption,
AssistantToolChoice,
AssistantToolChoiceFunction,
Expand Down
3 changes: 2 additions & 1 deletion src/resources/beta/threads/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export {
MessageDeleted,
MessageDelta,
MessageDeltaEvent,
RefusalContentBlock,
RefusalDeltaBlock,
Text,
TextContentBlock,
TextContentBlockParam,
Expand All @@ -34,7 +36,6 @@ export {
Messages,
} from './messages';
export {
AssistantResponseFormat,
AssistantResponseFormatOption,
AssistantToolChoice,
AssistantToolChoiceFunction,
Expand Down
43 changes: 41 additions & 2 deletions src/resources/beta/threads/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,21 @@ export namespace Message {
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export type MessageContent = ImageFileContentBlock | ImageURLContentBlock | TextContentBlock;
export type MessageContent =
| ImageFileContentBlock
| ImageURLContentBlock
| TextContentBlock
| RefusalContentBlock;

/**
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export type MessageContentDelta = ImageFileDeltaBlock | TextDeltaBlock | ImageURLDeltaBlock;
export type MessageContentDelta =
| ImageFileDeltaBlock
| TextDeltaBlock
| RefusalDeltaBlock
| ImageURLDeltaBlock;

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

/**
* The refusal content generated by the assistant.
*/
export interface RefusalContentBlock {
refusal: string;

/**
* Always `refusal`.
*/
type: 'refusal';
}

/**
* The refusal content that is part of a message.
*/
export interface RefusalDeltaBlock {
/**
* The index of the refusal part in the message.
*/
index: number;

/**
* Always `refusal`.
*/
type: 'refusal';

refusal?: string;
}

export interface Text {
annotations: Array<Annotation>;

Expand Down Expand Up @@ -707,6 +744,8 @@ export namespace Messages {
export import MessageDeleted = MessagesAPI.MessageDeleted;
export import MessageDelta = MessagesAPI.MessageDelta;
export import MessageDeltaEvent = MessagesAPI.MessageDeltaEvent;
export import RefusalContentBlock = MessagesAPI.RefusalContentBlock;
export import RefusalDeltaBlock = MessagesAPI.RefusalDeltaBlock;
export import Text = MessagesAPI.Text;
export import TextContentBlock = MessagesAPI.TextContentBlock;
export import TextContentBlockParam = MessagesAPI.TextContentBlockParam;
Expand Down
10 changes: 10 additions & 0 deletions src/resources/beta/threads/runs/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ export interface Run {
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which guarantees the model will match your supplied JSON schema. Learn
* more in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
* message the model generates is valid JSON.
*
Expand Down Expand Up @@ -558,6 +563,11 @@ export interface RunCreateParamsBase {
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which guarantees the model will match your supplied JSON schema. Learn
* more in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
* message the model generates is valid JSON.
*
Expand Down
32 changes: 18 additions & 14 deletions src/resources/beta/threads/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { isRequestOptions } from '../../../core';
import { APIPromise } from '../../../core';
import * as Core from '../../../core';
import * as ThreadsAPI from './threads';
import * as Shared from '../../shared';
import * as AssistantsAPI from '../assistants';
import * as ChatAPI from '../../chat/chat';
import * as MessagesAPI from './messages';
Expand Down Expand Up @@ -93,24 +94,17 @@ export class Threads extends APIResource {
}
}

/**
* An object describing the expected output of the model. If `json_object` only
* `function` type `tools` are allowed to be passed to the Run. If `text` the model
* can return text or any value needed.
*/
export interface AssistantResponseFormat {
/**
* Must be one of `text` or `json_object`.
*/
type?: 'text' | 'json_object';
}

/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which guarantees the model will match your supplied JSON schema. Learn
* more in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
* message the model generates is valid JSON.
*
Expand All @@ -122,7 +116,11 @@ export interface AssistantResponseFormat {
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
export type AssistantResponseFormatOption = 'none' | 'auto' | AssistantResponseFormat;
export type AssistantResponseFormatOption =
| 'auto'
| Shared.ResponseFormatText
| Shared.ResponseFormatJSONObject
| Shared.ResponseFormatJSONSchema;

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

export namespace Threads {
export import AssistantResponseFormat = ThreadsAPI.AssistantResponseFormat;
export import AssistantResponseFormatOption = ThreadsAPI.AssistantResponseFormatOption;
export import AssistantToolChoice = ThreadsAPI.AssistantToolChoice;
export import AssistantToolChoiceFunction = ThreadsAPI.AssistantToolChoiceFunction;
Expand Down Expand Up @@ -923,6 +925,8 @@ export namespace Threads {
export import MessageDeleted = MessagesAPI.MessageDeleted;
export import MessageDelta = MessagesAPI.MessageDelta;
export import MessageDeltaEvent = MessagesAPI.MessageDeltaEvent;
export import RefusalContentBlock = MessagesAPI.RefusalContentBlock;
export import RefusalDeltaBlock = MessagesAPI.RefusalDeltaBlock;
export import Text = MessagesAPI.Text;
export import TextContentBlock = MessagesAPI.TextContentBlock;
export import TextContentBlockParam = MessagesAPI.TextContentBlockParam;
Expand Down
2 changes: 1 addition & 1 deletion src/resources/beta/vector-stores/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export namespace VectorStoreFile {
/**
* One of `server_error` or `rate_limit_exceeded`.
*/
code: 'internal_error' | 'file_not_found' | 'parsing_error' | 'unhandled_mime_type';
code: 'server_error' | 'unsupported_file' | 'invalid_file';

/**
* A human-readable description of the error.
Expand Down
2 changes: 2 additions & 0 deletions src/resources/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class Chat extends APIResource {

export type ChatModel =
| 'gpt-4o'
| 'gpt-4o-2024-08-06'
| 'gpt-4o-2024-05-13'
| 'gpt-4o-mini'
| 'gpt-4o-mini-2024-07-18'
Expand Down Expand Up @@ -41,6 +42,7 @@ export namespace Chat {
export import ChatCompletionChunk = CompletionsAPI.ChatCompletionChunk;
export import ChatCompletionContentPart = CompletionsAPI.ChatCompletionContentPart;
export import ChatCompletionContentPartImage = CompletionsAPI.ChatCompletionContentPartImage;
export import ChatCompletionContentPartRefusal = CompletionsAPI.ChatCompletionContentPartRefusal;
export import ChatCompletionContentPartText = CompletionsAPI.ChatCompletionContentPartText;
export import ChatCompletionFunctionCallOption = CompletionsAPI.ChatCompletionFunctionCallOption;
export import ChatCompletionFunctionMessageParam = CompletionsAPI.ChatCompletionFunctionMessageParam;
Expand Down
Loading