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

Update to the latest OpenAI OpenAPI Specification #18

Merged
merged 3 commits into from
Dec 15, 2024

Conversation

AbQaadir
Copy link
Contributor

@AbQaadir AbQaadir commented Dec 8, 2024

Overview

This pull request introduces significant updates to the ChatCompletionRequest specifications, enhancing the API's capabilities and providing more flexible options for developers.

Key Changes

New Models

  • Added support for new model variants:
    • o1-preview and o1-preview-2024-09-12
    • gpt-4o-realtime-preview
    • gpt-4o-audio-preview
    • chatgpt-4o-latest

New Parameters

  1. Store Parameter

    • Added store (boolean) to optionally store model responses
    • Default is set to false
    • Enables persistent response storage for later retrieval
  2. Metadata Support

    • Introduced metadata parameter
    • Allows adding custom metadata to requests
    • Improves request tracking and categorization
  3. Enhanced Token Management

    • Deprecated max_tokens
    • Introduced max_completion_tokens for more precise output token control
  4. Modalities

    • Added modalities parameter
    • Supports specifying interaction types (text, image, audio)
  5. Prediction and Audio

    • New prediction parameter for advanced response predictions
    • Added audio parameter to handle audio input/output
    • Enables more sophisticated multimodal interactions

Response Format Improvements

  • Expanded response_format to support:
    • JsonObject
    • JsonSchema
    • Provides more structured data handling options

Service Tier

  • Explicitly set default service_tier to "auto"

Benefits

  • Enhanced multimodal capabilities
  • Improved response management
  • Better support for diverse use cases

Specifications Comparison ChatCompletionRequest

Parameters Old Specifications Updated Specifications Differences and Additional Information
model gpt-4o, gpt-4o-2024-05-13, gpt-4o-mini, gpt-4o-mini-2024-07-18, gpt-4-turbo, gpt-4-turbo-2024-04-09, gpt-4-0125-preview, gpt-4-turbo-preview, gpt-4-1106-preview, gpt-4-vision-preview, gpt-4, gpt-4-0314, gpt-4-0613, gpt-4-32k, gpt-4-32k-0314, gpt-4-32k-0613, gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-3.5-turbo-0301, gpt-3.5-turbo-0613, gpt-3.5-turbo-1106, gpt-3.5-turbo-0125, gpt-3.5-turbo-16k-0613 o1-preview, o1-preview-2024-09-12, o1-mini, o1-mini-2024-09-12, gpt-4o, gpt-4o-2024-11-20, gpt-4o-2024-08-06, gpt-4o-2024-05-13, gpt-4o-realtime-preview, gpt-4o-realtime-preview-2024-10-01, gpt-4o-audio-preview, gpt-4o-audio-preview-2024-10-01, chatgpt-4o-latest, gpt-4o-mini, gpt-4o-mini-2024-07-18, gpt-4-turbo, gpt-4-turbo-2024-04-09, gpt-4-0125-preview, gpt-4-turbo-preview, gpt-4-1106-preview, gpt-4-vision-preview, gpt-4, gpt-4-0314, gpt-4-0613, gpt-4-32k, gpt-4-32k-0314, gpt-4-32k-0613, gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-3.5-turbo-0301, gpt-3.5-turbo-0613, gpt-3.5-turbo-1106, gpt-3.5-turbo-0125, gpt-3.5-turbo-16k-0613 New models introduced "o1-preview", "o1-preview-2024-09-12", "gpt-4o-realtime-preview", "gpt-4o-audio-preview", "chatgpt-4o-latest".
store Not present boolean? store = false; New parameter. Allows storing model responses for later use. Default value is false.
metadata Not present record { string...; }? metadata?; New parameter. Developers can add custom metadata to requests, allowing better tracking or categorization.
max_tokens int? max_tokens?; @deprecated int? max_tokens?; Deprecated. max_tokens is replaced with max_completion_tokens in the new version to provide more flexibility.
max_completion_tokens Not present int? max_completion_tokens?; New parameter. Specifies a hard limit on the number of tokens for model output, replacing max_tokens.
modalities Not present ChatCompletionModalities? modalities?; New parameter. Specifies the interaction modalities (e.g., text, image, or audio).
prediction Not present PredictionContent? prediction?; New parameter. Specifies the content prediction for responses, enabling more advanced predictions.
audio Not present CreateChatCompletionRequest_audio? audio?; New parameter. Handles audio input/output, enabling multimodal features.
response_format CreateChatCompletionRequest_response_format response_format?; ResponseFormatText ResponseFormatJsonObject ResponseFormatJsonSchema response_format?; Updated. Supports new response formats (JsonObject, JsonSchema) for structured data handling.
service_tier "auto" "default"? service_tier?; "auto" "default"? service_tier = "auto"; Default value. Explicitly sets the default value to "auto"

Resources and References

Official Documentation

@CLAassistant
Copy link

CLAassistant commented Dec 8, 2024

CLA assistant check
All committers have signed the CLA.

@AbQaadir AbQaadir changed the title [Update] openapi spec :) Update to the latest OpenAI OpenAPI Specification Dec 10, 2024
@xlight05
Copy link
Contributor

This is great, As we discussed offline, even though from openai did not change the version in this case, it seems like a breaking change according to semver tool. So shall we bump the version to 4.0.0?

@AbQaadir
Copy link
Contributor Author

Thank you! I’ve added some minor documentation to the code and bumped the version to 4.0.0 as discussed.

Copy link
Contributor

@xlight05 xlight05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xlight05 xlight05 merged commit 3602190 into ballerina-platform:main Dec 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants