Skip to content

Commit

Permalink
[ Edit ] removed the non-usable url field in the chat completion cont…
Browse files Browse the repository at this point in the history
…ent model
  • Loading branch information
anasfik committed May 8, 2024
1 parent f4d3ca7 commit 7cd58e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## NEXT

- Support for logprobs in the chat completions API.

- Bug fixes.

## 5.1.0

- Massive issues fixes related to incorrecr use of types, model fields..., audio transcription file streaming error handling, and more.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,20 @@ class OpenAIChatCompletionChoiceMessageContentItemModel {
/// The text content of the item.
final String? text;

/// The image url content of the item.
final String? url;

/// The image url object.
final Map<String, dynamic>? imageUrl;

final String? imageBase64;

@override
int get hashCode => type.hashCode ^ text.hashCode ^ imageUrl.hashCode ^ url.hashCode;
int get hashCode => type.hashCode ^ text.hashCode ^ imageUrl.hashCode;

/// {@macro openai_chat_completion_choice_message_content_item_model}
OpenAIChatCompletionChoiceMessageContentItemModel._({
required this.type,
this.text,
this.imageUrl,
this.url
this.imageBase64,

});

/// This is used to convert a [Map<String, dynamic>] object to a [OpenAIChatCompletionChoiceMessageContentItemModel] object.
Expand All @@ -38,9 +33,7 @@ class OpenAIChatCompletionChoiceMessageContentItemModel {
type: asMap['type'],
text: asMap['text'],
imageUrl: asMap['image_url'],
url: asMap['url']
imageBase64: asMap['imageBase64'],

);
}

Expand Down Expand Up @@ -77,7 +70,8 @@ class OpenAIChatCompletionChoiceMessageContentItemModel {
"type": type,
if (text != null) "text": text,
if (imageUrl != null) "image_url": imageUrl,
if (imageBase64 != null) "image_url": {"url": "data:image/jpeg;base64,${imageBase64}"}
if (imageBase64 != null)
"image_url": {"url": "data:image/jpeg;base64,${imageBase64}"}
};
}

Expand All @@ -99,7 +93,7 @@ class OpenAIChatCompletionChoiceMessageContentItemModel {
'OpenAIChatCompletionChoiceMessageContentItemModel(type: $type, text: $text)',
'image' =>
'OpenAIChatCompletionChoiceMessageContentItemModel(type: $type, imageUrl: $imageUrl)',
'image_base64' =>
'image_base64' =>
'OpenAIChatCompletionChoiceMessageContentItemModel(type: $type, imageBase64: $imageBase64)',
_ => 'OpenAIChatCompletionChoiceMessageContentItemModel(type: $type)',
};
Expand Down

0 comments on commit 7cd58e5

Please sign in to comment.