diff --git a/api.md b/api.md
index 60b04de22..0ea5eae95 100644
--- a/api.md
+++ b/api.md
@@ -1,3 +1,10 @@
+# Shared
+
+Types:
+
+- FunctionObject
+- FunctionParameters
+
# Completions
Types:
diff --git a/build-deno b/build-deno
index c29faef64..c6c34389e 100755
--- a/build-deno
+++ b/build-deno
@@ -15,7 +15,7 @@ This is a build produced from https://github.com/openai/openai-node – please g
Usage:
\`\`\`ts
-import OpenAI from "$(echo 'https://deno.land/x/openai@v4.16.1/mod.ts' | sed -E s/@\.+\\//@"$PACKAGE_VERSION"\\//)";
+import OpenAI from "$(echo 'https://deno.land/x/openai@v4.16.2/mod.ts' | sed -E s/@\.+\\//@"$PACKAGE_VERSION"\\//)";
const client = new OpenAI();
\`\`\`
diff --git a/src/index.ts b/src/index.ts
index e213a00b6..152ee3b03 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -296,6 +296,9 @@ export namespace OpenAI {
export import FineTuneListEventsParamsStreaming = API.FineTuneListEventsParamsStreaming;
export import Beta = API.Beta;
+
+ export import FunctionObject = API.FunctionObject;
+ export import FunctionParameters = API.FunctionParameters;
}
export default OpenAI;
diff --git a/src/resources/beta/assistants/assistants.ts b/src/resources/beta/assistants/assistants.ts
index 89095daa7..949d305af 100644
--- a/src/resources/beta/assistants/assistants.ts
+++ b/src/resources/beta/assistants/assistants.ts
@@ -4,6 +4,7 @@ import * as Core from 'openai/core';
import { APIResource } from 'openai/resource';
import { isRequestOptions } from 'openai/core';
import * as AssistantsAPI from 'openai/resources/beta/assistants/assistants';
+import * as Shared from 'openai/resources/shared';
import * as FilesAPI from 'openai/resources/beta/assistants/files';
import { CursorPage, type CursorPageParams } from 'openai/pagination';
@@ -163,47 +164,13 @@ export namespace Assistant {
}
export interface Function {
- /**
- * The function definition.
- */
- function: Function.Function;
+ function: Shared.FunctionObject;
/**
* The type of tool being defined: `function`
*/
type: 'function';
}
-
- export namespace Function {
- /**
- * The function definition.
- */
- export interface Function {
- /**
- * A description of what the function does, used by the model to choose when and
- * how to call the function.
- */
- description: string;
-
- /**
- * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
- * underscores and dashes, with a maximum length of 64.
- */
- name: string;
-
- /**
- * The parameters the functions accepts, described as a JSON Schema object. See the
- * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for
- * examples, and the
- * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
- * documentation about the format.
- *
- * To describe a function that accepts no parameters, provide the value
- * `{"type": "object", "properties": {}}`.
- */
- parameters: Record;
- }
- }
}
export interface AssistantDeleted {
@@ -282,47 +249,13 @@ export namespace AssistantCreateParams {
}
export interface AssistantToolsFunction {
- /**
- * The function definition.
- */
- function: AssistantToolsFunction.Function;
+ function: Shared.FunctionObject;
/**
* The type of tool being defined: `function`
*/
type: 'function';
}
-
- export namespace AssistantToolsFunction {
- /**
- * The function definition.
- */
- export interface Function {
- /**
- * A description of what the function does, used by the model to choose when and
- * how to call the function.
- */
- description: string;
-
- /**
- * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
- * underscores and dashes, with a maximum length of 64.
- */
- name: string;
-
- /**
- * The parameters the functions accepts, described as a JSON Schema object. See the
- * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for
- * examples, and the
- * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
- * documentation about the format.
- *
- * To describe a function that accepts no parameters, provide the value
- * `{"type": "object", "properties": {}}`.
- */
- parameters: Record;
- }
- }
}
export interface AssistantUpdateParams {
@@ -395,47 +328,13 @@ export namespace AssistantUpdateParams {
}
export interface AssistantToolsFunction {
- /**
- * The function definition.
- */
- function: AssistantToolsFunction.Function;
+ function: Shared.FunctionObject;
/**
* The type of tool being defined: `function`
*/
type: 'function';
}
-
- export namespace AssistantToolsFunction {
- /**
- * The function definition.
- */
- export interface Function {
- /**
- * A description of what the function does, used by the model to choose when and
- * how to call the function.
- */
- description: string;
-
- /**
- * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
- * underscores and dashes, with a maximum length of 64.
- */
- name: string;
-
- /**
- * The parameters the functions accepts, described as a JSON Schema object. See the
- * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for
- * examples, and the
- * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
- * documentation about the format.
- *
- * To describe a function that accepts no parameters, provide the value
- * `{"type": "object", "properties": {}}`.
- */
- parameters: Record;
- }
- }
}
export interface AssistantListParams extends CursorPageParams {
diff --git a/src/resources/beta/threads/runs/runs.ts b/src/resources/beta/threads/runs/runs.ts
index 7d92c66bd..4579214a2 100644
--- a/src/resources/beta/threads/runs/runs.ts
+++ b/src/resources/beta/threads/runs/runs.ts
@@ -4,6 +4,7 @@ import * as Core from 'openai/core';
import { APIResource } from 'openai/resource';
import { isRequestOptions } from 'openai/core';
import * as RunsAPI from 'openai/resources/beta/threads/runs/runs';
+import * as Shared from 'openai/resources/shared';
import * as StepsAPI from 'openai/resources/beta/threads/runs/steps';
import { CursorPage, type CursorPageParams } from 'openai/pagination';
@@ -221,9 +222,9 @@ export interface Run {
model: string;
/**
- * The object type, which is always `assistant.run`.
+ * The object type, which is always `thread.run`.
*/
- object: 'assistant.run';
+ object: 'thread.run';
/**
* Details on the action required to continue the run. Will be `null` if no action
@@ -324,47 +325,13 @@ export namespace Run {
}
export interface AssistantToolsFunction {
- /**
- * The function definition.
- */
- function: AssistantToolsFunction.Function;
+ function: Shared.FunctionObject;
/**
* The type of tool being defined: `function`
*/
type: 'function';
}
-
- export namespace AssistantToolsFunction {
- /**
- * The function definition.
- */
- export interface Function {
- /**
- * A description of what the function does, used by the model to choose when and
- * how to call the function.
- */
- description: string;
-
- /**
- * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
- * underscores and dashes, with a maximum length of 64.
- */
- name: string;
-
- /**
- * The parameters the functions accepts, described as a JSON Schema object. See the
- * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for
- * examples, and the
- * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
- * documentation about the format.
- *
- * To describe a function that accepts no parameters, provide the value
- * `{"type": "object", "properties": {}}`.
- */
- parameters: Record;
- }
- }
}
export interface RunCreateParams {
@@ -424,47 +391,13 @@ export namespace RunCreateParams {
}
export interface AssistantToolsFunction {
- /**
- * The function definition.
- */
- function: AssistantToolsFunction.Function;
+ function: Shared.FunctionObject;
/**
* The type of tool being defined: `function`
*/
type: 'function';
}
-
- export namespace AssistantToolsFunction {
- /**
- * The function definition.
- */
- export interface Function {
- /**
- * A description of what the function does, used by the model to choose when and
- * how to call the function.
- */
- description: string;
-
- /**
- * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
- * underscores and dashes, with a maximum length of 64.
- */
- name: string;
-
- /**
- * The parameters the functions accepts, described as a JSON Schema object. See the
- * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for
- * examples, and the
- * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
- * documentation about the format.
- *
- * To describe a function that accepts no parameters, provide the value
- * `{"type": "object", "properties": {}}`.
- */
- parameters: Record;
- }
- }
}
export interface RunUpdateParams {
diff --git a/src/resources/beta/threads/runs/steps.ts b/src/resources/beta/threads/runs/steps.ts
index 6819aa269..6f3b5624a 100644
--- a/src/resources/beta/threads/runs/steps.ts
+++ b/src/resources/beta/threads/runs/steps.ts
@@ -269,9 +269,9 @@ export interface RunStep {
metadata: unknown | null;
/**
- * The object type, which is always `assistant.run.step``.
+ * The object type, which is always `thread.run.step``.
*/
- object: 'assistant.run.step';
+ object: 'thread.run.step';
/**
* The ID of the [run](https://platform.openai.com/docs/api-reference/runs) that
@@ -280,8 +280,8 @@ export interface RunStep {
run_id: string;
/**
- * The status of the run, which can be either `in_progress`, `cancelled`, `failed`,
- * `completed`, or `expired`.
+ * The status of the run step, which can be either `in_progress`, `cancelled`,
+ * `failed`, `completed`, or `expired`.
*/
status: 'in_progress' | 'cancelled' | 'failed' | 'completed' | 'expired';
diff --git a/src/resources/beta/threads/threads.ts b/src/resources/beta/threads/threads.ts
index 641f48738..0d72b2311 100644
--- a/src/resources/beta/threads/threads.ts
+++ b/src/resources/beta/threads/threads.ts
@@ -4,6 +4,7 @@ import * as Core from 'openai/core';
import { APIResource } from 'openai/resource';
import { isRequestOptions } from 'openai/core';
import * as ThreadsAPI from 'openai/resources/beta/threads/threads';
+import * as Shared from 'openai/resources/shared';
import * as MessagesAPI from 'openai/resources/beta/threads/messages/messages';
import * as RunsAPI from 'openai/resources/beta/threads/runs/runs';
@@ -279,47 +280,13 @@ export namespace ThreadCreateAndRunParams {
}
export interface AssistantToolsFunction {
- /**
- * The function definition.
- */
- function: AssistantToolsFunction.Function;
+ function: Shared.FunctionObject;
/**
* The type of tool being defined: `function`
*/
type: 'function';
}
-
- export namespace AssistantToolsFunction {
- /**
- * The function definition.
- */
- export interface Function {
- /**
- * A description of what the function does, used by the model to choose when and
- * how to call the function.
- */
- description: string;
-
- /**
- * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
- * underscores and dashes, with a maximum length of 64.
- */
- name: string;
-
- /**
- * The parameters the functions accepts, described as a JSON Schema object. See the
- * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for
- * examples, and the
- * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
- * documentation about the format.
- *
- * To describe a function that accepts no parameters, provide the value
- * `{"type": "object", "properties": {}}`.
- */
- parameters: Record;
- }
- }
}
export namespace Threads {
diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts
index 412688dfa..38a27de67 100644
--- a/src/resources/chat/completions.ts
+++ b/src/resources/chat/completions.ts
@@ -5,6 +5,7 @@ import { APIPromise } from 'openai/core';
import { APIResource } from 'openai/resource';
import * as ChatCompletionsAPI from 'openai/resources/chat/completions';
import * as CompletionsAPI from 'openai/resources/completions';
+import * as Shared from 'openai/resources/shared';
import { Stream } from 'openai/streaming';
export class Completions extends APIResource {
@@ -180,7 +181,6 @@ export interface ChatCompletionChunk {
/**
* This fingerprint represents the backend configuration that the model runs with.
- *
* Can be used in conjunction with the `seed` request parameter to understand when
* backend changes have been made that might impact determinism.
*/
@@ -486,7 +486,7 @@ export interface ChatCompletionSystemMessageParam {
}
export interface ChatCompletionTool {
- function: ChatCompletionTool.Function;
+ function: Shared.FunctionObject;
/**
* The type of the tool. Currently, only `function` is supported.
@@ -494,34 +494,6 @@ export interface ChatCompletionTool {
type: 'function';
}
-export namespace ChatCompletionTool {
- export interface Function {
- /**
- * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
- * underscores and dashes, with a maximum length of 64.
- */
- name: string;
-
- /**
- * The parameters the functions accepts, described as a JSON Schema object. See the
- * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for
- * examples, and the
- * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
- * documentation about the format.
- *
- * To describe a function that accepts no parameters, provide the value
- * `{"type": "object", "properties": {}}`.
- */
- parameters: Record;
-
- /**
- * A description of what the function does, used by the model to choose when and
- * how to call the function.
- */
- description?: string;
- }
-}
-
/**
* Controls which (if any) function is called by the model. `none` means the model
* will not call a function and instead generates a message. `auto` means the model
@@ -668,8 +640,18 @@ export interface ChatCompletionCreateParamsBase {
presence_penalty?: number | null;
/**
- * An object specifying the format that the model must output. Used to enable JSON
- * mode.
+ * An object specifying the format that the model must output.
+ *
+ * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
+ * message the model generates is valid JSON.
+ *
+ * **Important:** when using JSON mode, you **must** also instruct the model to
+ * produce JSON yourself via a system or user message. Without this, the model may
+ * generate an unending stream of whitespace until the generation reaches the token
+ * limit, resulting in increased latency and appearance of a "stuck" request. Also
+ * note that the message content may be partially cut off if
+ * `finish_reason="length"`, which indicates the generation exceeded `max_tokens`
+ * or the conversation exceeded the max context length.
*/
response_format?: ChatCompletionCreateParams.ResponseFormat;
@@ -761,7 +743,7 @@ export namespace ChatCompletionCreateParams {
* To describe a function that accepts no parameters, provide the value
* `{"type": "object", "properties": {}}`.
*/
- parameters: Record;
+ parameters: Shared.FunctionParameters;
/**
* A description of what the function does, used by the model to choose when and
@@ -771,21 +753,21 @@ export namespace ChatCompletionCreateParams {
}
/**
- * An object specifying the format that the model must output. Used to enable JSON
- * mode.
+ * An object specifying the format that the model must output.
+ *
+ * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
+ * message the model generates is valid JSON.
+ *
+ * **Important:** when using JSON mode, you **must** also instruct the model to
+ * produce JSON yourself via a system or user message. Without this, the model may
+ * generate an unending stream of whitespace until the generation reaches the token
+ * limit, resulting in increased latency and appearance of a "stuck" request. Also
+ * note that the message content may be partially cut off if
+ * `finish_reason="length"`, which indicates the generation exceeded `max_tokens`
+ * or the conversation exceeded the max context length.
*/
export interface ResponseFormat {
/**
- * Setting to `json_object` enables JSON mode. This guarantees that the message the
- * model generates is valid JSON.
- *
- * Note that your system prompt must still instruct the model to produce JSON, and
- * to help ensure you don't forget, the API will throw an error if the string
- * `JSON` does not appear in your system message. Also note that the message
- * content may be partial (i.e. cut off) if `finish_reason="length"`, which
- * indicates the generation exceeded `max_tokens` or the conversation exceeded the
- * max context length.
- *
* Must be one of `text` or `json_object`.
*/
type?: 'text' | 'json_object';
diff --git a/src/resources/index.ts b/src/resources/index.ts
index 67a4ed227..3bc17fdc2 100644
--- a/src/resources/index.ts
+++ b/src/resources/index.ts
@@ -1,6 +1,7 @@
// File generated from our OpenAPI spec by Stainless.
export * from './chat/index';
+export * from './shared';
export { Audio } from './audio/audio';
export { Beta } from './beta/beta';
export {
diff --git a/src/resources/shared.ts b/src/resources/shared.ts
new file mode 100644
index 000000000..873278df5
--- /dev/null
+++ b/src/resources/shared.ts
@@ -0,0 +1,39 @@
+// File generated from our OpenAPI spec by Stainless.
+
+export interface FunctionObject {
+ /**
+ * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
+ * underscores and dashes, with a maximum length of 64.
+ */
+ name: string;
+
+ /**
+ * The parameters the functions accepts, described as a JSON Schema object. See the
+ * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for
+ * examples, and the
+ * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
+ * documentation about the format.
+ *
+ * To describe a function that accepts no parameters, provide the value
+ * `{"type": "object", "properties": {}}`.
+ */
+ parameters: FunctionParameters;
+
+ /**
+ * A description of what the function does, used by the model to choose when and
+ * how to call the function.
+ */
+ description?: string;
+}
+
+/**
+ * The parameters the functions accepts, described as a JSON Schema object. See the
+ * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for
+ * examples, and the
+ * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
+ * documentation about the format.
+ *
+ * To describe a function that accepts no parameters, provide the value
+ * `{"type": "object", "properties": {}}`.
+ */
+export type FunctionParameters = Record;