Skip to content

Commit

Permalink
feat: Add five new voice types to Chat Completions API in openai_dart (
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmigloz authored Oct 31, 2024
1 parent 6d0c8d3 commit 543f297
Show file tree
Hide file tree
Showing 7 changed files with 3,559 additions and 3,885 deletions.
6 changes: 5 additions & 1 deletion packages/openai_dart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ await for (final res in stream) {
// 789
```

**Multi-modal prompt:** ([docs](https://platform.openai.com/docs/guides/vision))
**Multi-modal prompt (text/image/audio):**

You can either provide the image URL:

Expand Down Expand Up @@ -223,6 +223,8 @@ ChatCompletionMessage.user(
//...
```

Check the [Vision](https://platform.openai.com/docs/guides/vision) guide for more information.

In addition to generating text and images, some models enable you to generate a spoken audio response to a prompt:

```dart
Expand Down Expand Up @@ -297,6 +299,8 @@ print(audio?.transcript);
print(audio?.data);
```

Check the [Audio generation](https://platform.openai.com/docs/guides/audio) guide for more information.

**Structured output: ([docs](https://platform.openai.com/docs/guides/structured-outputs))**

Structured Outputs is a feature that ensures the model will always generate responses that adhere to your supplied JSON Schema.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class ChatCompletionAudioOptions with _$ChatCompletionAudioOptions {

/// Factory constructor for ChatCompletionAudioOptions
const factory ChatCompletionAudioOptions({
/// Specifies the voice type. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`.
/// The voice the model uses to respond. Supported voices are `alloy`,
/// `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
required ChatCompletionAudioVoice voice,

/// Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`, or `pcm16`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ part of open_a_i_schema;
// ENUM: ChatCompletionAudioVoice
// ==========================================

/// Specifies the voice type. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`.
/// The voice the model uses to respond. Supported voices are `alloy`,
/// `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
enum ChatCompletionAudioVoice {
@JsonValue('alloy')
alloy,
@JsonValue('ash')
ash,
@JsonValue('ballad')
ballad,
@JsonValue('coral')
coral,
@JsonValue('echo')
echo,
@JsonValue('fable')
fable,
@JsonValue('onyx')
onyx,
@JsonValue('nova')
nova,
@JsonValue('sage')
sage,
@JsonValue('shimmer')
shimmer,
@JsonValue('verse')
verse,
}
Original file line number Diff line number Diff line change
Expand Up @@ -8446,7 +8446,8 @@ ChatCompletionAudioOptions _$ChatCompletionAudioOptionsFromJson(

/// @nodoc
mixin _$ChatCompletionAudioOptions {
/// Specifies the voice type. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`.
/// The voice the model uses to respond. Supported voices are `alloy`,
/// `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
ChatCompletionAudioVoice get voice => throw _privateConstructorUsedError;

/// Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`, or `pcm16`.
Expand Down Expand Up @@ -8558,7 +8559,8 @@ class _$ChatCompletionAudioOptionsImpl extends _ChatCompletionAudioOptions {
Map<String, dynamic> json) =>
_$$ChatCompletionAudioOptionsImplFromJson(json);

/// Specifies the voice type. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`.
/// The voice the model uses to respond. Supported voices are `alloy`,
/// `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
@override
final ChatCompletionAudioVoice voice;

Expand Down Expand Up @@ -8611,7 +8613,8 @@ abstract class _ChatCompletionAudioOptions extends ChatCompletionAudioOptions {
factory _ChatCompletionAudioOptions.fromJson(Map<String, dynamic> json) =
_$ChatCompletionAudioOptionsImpl.fromJson;

/// Specifies the voice type. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`.
/// The voice the model uses to respond. Supported voices are `alloy`,
/// `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
@override
ChatCompletionAudioVoice get voice;

Expand Down
8 changes: 5 additions & 3 deletions packages/openai_dart/lib/src/generated/schema/schema.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 25 additions & 22 deletions packages/openai_dart/oas/openapi_curated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,7 @@ components:
- type: string
description: The text contents of the user message.
- type: array
description: |
description: |
An array of content parts with a defined type. Supported options differ based on the
[model](https://platform.openai.com/docs/models)
being used to generate the response. Can contain text, image, or audio inputs.
Expand Down Expand Up @@ -2301,7 +2301,7 @@ components:
- image_url
ChatCompletionMessageContentPartAudio:
type: object
description: |
description: |
An audio content part of a user message.
Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).
properties:
Expand Down Expand Up @@ -2571,26 +2571,29 @@ components:
format:
$ref: "#/components/schemas/ChatCompletionAudioFormat"
ChatCompletionAudioVoice:
type: string
description: |
Specifies the voice type. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`.
enum:
- alloy
- echo
- fable
- onyx
- nova
- shimmer
type: string
description: |
The voice the model uses to respond. Supported voices are `alloy`,
`ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
enum:
- alloy
- ash
- ballad
- coral
- echo
- sage
- shimmer
- verse
ChatCompletionAudioFormat:
type: string
description: |
Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`, or `pcm16`.
enum:
- wav
- mp3
- flac
- opus
- pcm16
- wav
- mp3
- flac
- opus
- pcm16
ChatCompletionStreamOptions:
description: |
Options for streaming response. Only set this when you set `stream: true`.
Expand Down Expand Up @@ -4811,7 +4814,7 @@ components:
additionalProperties: false
properties:
assistant_id:
description: |
description: |
The ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to execute this
run.
type: string
Expand All @@ -4820,7 +4823,7 @@ components:
description: If no thread is provided, an empty thread will be created.
model:
title: ThreadAndRunModel
description: |
description: |
The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to be used to execute this run.
If a value is provided here, it will override the model associated with the assistant. If not, the model
associated with the assistant will be used.
Expand Down Expand Up @@ -4865,13 +4868,13 @@ components:
"o1-preview-2024-09-12",
]
instructions:
description: |
description: |
Override the default system message of the assistant. This is useful for modifying the behavior on a per-run
basis.
type: string
nullable: true
tools:
description: |
description: |
Override the tools the assistant can use for this run. This is useful for modifying the behavior on a
per-run basis.
nullable: true
Expand Down Expand Up @@ -4994,7 +4997,7 @@ components:
additionalProperties: false
properties:
messages:
description: |
description: |
A list of [messages](https://platform.openai.com/docs/api-reference/messages) to start the thread with.
type: array
items:
Expand Down
Loading

0 comments on commit 543f297

Please sign in to comment.