Skip to content

Commit

Permalink
Merge pull request openai#113 from openai/nikunj/bump-to-latest-inter…
Browse files Browse the repository at this point in the history
…nal-spec

bump to latest internal spec
  • Loading branch information
schnerd committed Nov 8, 2023
2 parents 2a11b83 + efe171b commit 5c1857e
Showing 1 changed file with 97 additions and 79 deletions.
176 changes: 97 additions & 79 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,45 +142,73 @@ paths:
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "VAR_model_id",
"model": "gpt-4-vision-preview",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
"content": [
{
"type": "text",
"text": "What’s in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
}
]
}
]
],
"max_tokens": 300
}'
python: |
from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create(
model="VAR_model_id",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
response = client.chat.completions.create(
model="gpt-4-vision-preview",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What’s in this image?"},
{
"type": "image_url",
"image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
],
}
],
max_tokens=300,
)
print(completion.choices[0].message)
print(response.choices[0])
node.js: |-
import OpenAI from "openai";
const openai = new OpenAI();
async function main() {
const completion = await openai.chat.completions.create({
messages: [{ role: "system", content: "You are a helpful assistant." }],
model: "VAR_model_id",
const response = await openai.chat.completions.create({
model: "gpt-4-vision-preview",
messages: [
{
role: "user",
content: [
{ type: "text", text: "What’s in this image?" },
{
type: "image_url",
image_url:
"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
],
},
],
});
console.log(completion.choices[0]);
console.log(response.choices[0]);
}
main();
response: &chat_completion_image_example |
{
Expand Down Expand Up @@ -2593,7 +2621,7 @@ paths:
from openai import OpenAI
client = OpenAI()
my_assistants = openai.beta.assistants.list(
my_assistants = client.beta.assistants.list(
order="desc",
limit="20",
)
Expand Down Expand Up @@ -2699,7 +2727,7 @@ paths:
from openai import OpenAI
client = OpenAI()
my_assistant = openai.beta.assistants.create(
my_assistant = client.beta.assistants.create(
instructions="You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
name="Math Tutor",
tools=[{"type": "code_interpreter"}],
Expand Down Expand Up @@ -2758,7 +2786,7 @@ paths:
from openai import OpenAI
client = OpenAI()
my_assistant = openai.beta.assistants.create(
my_assistant = client.beta.assistants.create(
instructions="You are an HR bot, and you have access to files to answer employee questions about company policies.",
name="HR Helper",
tools=[{"type": "retrieval"}],
Expand Down Expand Up @@ -2840,7 +2868,7 @@ paths:
from openai import OpenAI
client = OpenAI()
my_assistant = openai.beta.assistants.retrieve("asst_abc123")
my_assistant = client.beta.assistants.retrieve("asst_abc123")
print(my_assistant)
node.js: |-
import OpenAI from "openai";
Expand Down Expand Up @@ -2920,7 +2948,8 @@ paths:
python: |
from openai import OpenAI
client = OpenAI()
my_updated_assistant = openai.beta.assistants.update(
my_updated_assistant = client.beta.assistants.update(
"asst_abc123",
instructions="You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.",
name="HR Helper",
Expand Down Expand Up @@ -3009,7 +3038,8 @@ paths:
python: |
from openai import OpenAI
client = OpenAI()
response = openai.beta.assistants.delete("asst_QLoItBbqwyAJEzlTy4y9kOMM")
response = client.beta.assistants.delete("asst_QLoItBbqwyAJEzlTy4y9kOMM")
print(response)
node.js: |-
import OpenAI from "openai";
Expand Down Expand Up @@ -3064,7 +3094,7 @@ paths:
from openai import OpenAI
client = OpenAI()
empty_thread = openai.beta.threads.create()
empty_thread = client.beta.threads.create()
print(empty_thread)
node.js: |-
import OpenAI from "openai";
Expand Down Expand Up @@ -3106,7 +3136,7 @@ paths:
from openai import OpenAI
client = OpenAI()
message_thread = openai.beta.threads.create(
message_thread = client.beta.threads.create(
messages=[
{
"role": "user",
Expand Down Expand Up @@ -3188,7 +3218,7 @@ paths:
from openai import OpenAI
client = OpenAI()
my_thread = openai.beta.threads.retrieve("thread_abc123")
my_thread = client.beta.threads.retrieve("thread_abc123")
print(my_thread)
node.js: |-
import OpenAI from "openai";
Expand Down Expand Up @@ -3257,7 +3287,7 @@ paths:
from openai import OpenAI
client = OpenAI()
my_updated_thread = openai.beta.threads.update(
my_updated_thread = client.beta.threads.update(
"thread_abc123",
metadata={
"modified": "true",
Expand Down Expand Up @@ -3327,7 +3357,7 @@ paths:
from openai import OpenAI
client = OpenAI()
response = openai.beta.threads.delete("thread_abc123")
response = client.beta.threads.delete("thread_abc123")
print(response)
node.js: |-
import OpenAI from "openai";
Expand Down Expand Up @@ -3406,7 +3436,7 @@ paths:
from openai import OpenAI
client = OpenAI()
thread_messages = openai.beta.threads.messages.list("thread_1OWaSqVIxJdy3KYnJLbXEWhy")
thread_messages = client.beta.threads.messages.list("thread_1OWaSqVIxJdy3KYnJLbXEWhy")
print(thread_messages.data)
node.js: |-
import OpenAI from "openai";
Expand Down Expand Up @@ -3517,7 +3547,7 @@ paths:
from openai import OpenAI
client = OpenAI()
thread_message = openai.beta.threads.messages.create(
thread_message = client.beta.threads.messages.create(
"thread_abc123",
role="user",
content="How does AI work? Explain it in simple terms.",
Expand Down Expand Up @@ -3601,7 +3631,7 @@ paths:
from openai import OpenAI
client = OpenAI()
message = openai.beta.threads.messages.retrieve(
message = client.beta.threads.messages.retrieve(
message_id="msg_abc123",
thread_id="thread_abc123",
)
Expand Down Expand Up @@ -3694,7 +3724,7 @@ paths:
from openai import OpenAI
client = OpenAI()
message = openai.beta.threads.messages.update(
message = client.beta.threads.messages.update(
message_id="msg_abc12",
thread_id="thread_abc123",
metadata={
Expand Down Expand Up @@ -5477,7 +5507,7 @@ components:
items:
type: object
additionalProperties:
type: integer
type: number
text:
type: string
created:
Expand Down Expand Up @@ -5700,7 +5730,7 @@ components:
- name
- content

ChatCompletionFunctionParameters:
FunctionParameters:
type: object
description: "The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/gpt/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.\n\nTo describe a function that accepts no parameters, provide the value `{\"type\": \"object\", \"properties\": {}}`."
additionalProperties: true
Expand All @@ -5716,7 +5746,7 @@ components:
type: string
description: 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.
parameters:
$ref: "#/components/schemas/ChatCompletionFunctionParameters"
$ref: "#/components/schemas/FunctionParameters"
required:
- name
- parameters
Expand All @@ -5740,23 +5770,26 @@ components:
enum: ["function"]
description: The type of the tool. Currently, only `function` is supported.
function:
type: object
properties:
description:
type: string
description: A description of what the function does, used by the model to choose when and how to call the function.
name:
type: string
description: 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.
parameters:
$ref: "#/components/schemas/ChatCompletionFunctionParameters"
required:
- name
- parameters
$ref: "#/components/schemas/FunctionObject"
required:
- type
- function

FunctionObject:
type: object
properties:
description:
type: string
description: A description of what the function does, used by the model to choose when and how to call the function.
name:
type: string
description: 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.
parameters:
$ref: "#/components/schemas/FunctionParameters"
required:
- name
- parameters

ChatCompletionToolChoiceOption:
description: |
Controls which (if any) function is called by the model.
Expand Down Expand Up @@ -5996,19 +6029,19 @@ components:
description: *completions_presence_penalty_description
response_format:
type: object
description: An object specifying the format that the model must output. Used to enable JSON mode.
description: |
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.
properties:
type:
type: string
enum: ["text", "json_object"]
example: "json_object"
default: "text"
description: |
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`.
description: Must be one of `text` or `json_object`.
seed:
type: integer
minimum: -9223372036854775808
Expand Down Expand Up @@ -6284,7 +6317,6 @@ components:
type: string
description: |
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.
object:
type: string
Expand Down Expand Up @@ -7956,21 +7988,7 @@ components:
description: "The type of tool being defined: `function`"
enum: ["function"]
function:
type: object
description: The function definition.
properties:
description:
type: string
description: A description of what the function does, used by the model to choose when and how to call the function.
name:
type: string
description: 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.
parameters:
$ref: "#/components/schemas/ChatCompletionFunctionParameters"
required:
- name
- parameters
- description
$ref: "#/components/schemas/FunctionObject"
required:
- type
- function
Expand All @@ -7984,9 +8002,9 @@ components:
description: The identifier, which can be referenced in API endpoints.
type: string
object:
description: The object type, which is always `assistant.run`.
description: The object type, which is always `thread.run`.
type: string
enum: ["assistant.run"]
enum: ["thread.run"]
created_at:
description: The Unix timestamp (in seconds) for when the run was created.
type: integer
Expand Down Expand Up @@ -8685,9 +8703,9 @@ components:
description: The identifier of the run step, which can be referenced in API endpoints.
type: string
object:
description: The object type, which is always `assistant.run.step``.
description: The object type, which is always `thread.run.step``.
type: string
enum: ["assistant.run.step"]
enum: ["thread.run.step"]
created_at:
description: The Unix timestamp (in seconds) for when the run step was created.
type: integer
Expand All @@ -8705,7 +8723,7 @@ components:
type: string
enum: ["message_creation", "tool_calls"]
status:
description: The status of the run, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`.
description: The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`.
type: string
enum: ["in_progress", "cancelled", "failed", "completed", "expired"]
step_details:
Expand Down

0 comments on commit 5c1857e

Please sign in to comment.