Open EluvK opened 3 months ago
openai_dart supports both:
String:
ChatCompletionMessage.user(
content: ChatCompletionUserMessageContent.string('Hello!'),
),
Or parts for multi-modal:
ChatCompletionMessage.user(
content: ChatCompletionUserMessageContent.parts(
[
ChatCompletionMessageContentPart.text(
text: 'What fruit is this?',
),
ChatCompletionMessageContentPart.image(
imageUrl: ChatCompletionMessageImageUrl(
url: 'https://upload.wikimedia.org/wikipedia/commons/9/92/95apple.jpeg',
),
),
],
),
),
Description
In the recent update to the
dart_openai
library (version 5.0.0), thecontent
field in the request body has been changed fromString
toList<Object>
. While this change aligns with OpenAI's latest API updates, it causes compatibility issues with other large model APIs that still expectcontent
to be aString
.Impact
This change prevents users from easily migrating to or using other large model APIs that follow the original OpenAI API format. As a result, users who rely on these APIs are facing difficulties in integrating with the updated
dart_openai
library. Specifically, the following error is encountered:Suggested Solution
To maintain compatibility and ease of migration, I suggest the following:
String
field.content
field.Example Code
Here is an example of how the library could support both formats: (something like this, I'm a newbie in Dart)
This approach would ensure that users can continue to use the library with other large model APIs without any issues.
Additional Context
dart_openai
is 5.0.0.String
was 4.1.2, and the commit.I sinicerely hope you can consider this suggestion.
Thank you!