Chat Completion Error #129
hanchao2407
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
can anybody help? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey All, I'm using this package for the first time today and trying the Chat Completion example code, the console shows below error. How to fix?
[OpenAI] api key set to ***********D
[OpenAI] accessing endpoint: /chat/completions
E/flutter ( 5165): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: NoSuchMethodError: Class 'String' has no instance getter 'value'.
E/flutter ( 5165): Receiver: "auto"
E/flutter ( 5165): Tried calling: value
E/flutter ( 5165): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
E/flutter ( 5165): #1 OpenAIChat.create
The example code:
// the system message that will be sent to the request.
final systemMessage = OpenAIChatCompletionChoiceMessageModel(
content: [
OpenAIChatCompletionChoiceMessageContentItemModel.text(
"return any message you are given as JSON.",
),
],
role: OpenAIChatMessageRole.assistant,
);
// the user message that will be sent to the request.
final userMessage = OpenAIChatCompletionChoiceMessageModel(
content: [
OpenAIChatCompletionChoiceMessageContentItemModel.text(
"Hello, I am a chatbot created by OpenAI. How are you today?",
),
],
role: OpenAIChatMessageRole.user,
);
// all messages to be sent.
final requestMessages = [
systemMessage,
userMessage,
];
// the actual request.
OpenAIChatCompletionModel chatCompletion = await OpenAI.instance.chat.create(
model: "gpt-3.5-turbo-1106",
responseFormat: {"type": "json_object"},
seed: 6,
messages: requestMessages,
temperature: 0.2,
maxTokens: 500,
toolChoice: "auto",
);
print(chatCompletion.choices.first.message); // ...
print(chatCompletion.systemFingerprint); // ...
print(chatCompletion.usage.promptTokens); // ...
print(chatCompletion.id); // ...
Beta Was this translation helpful? Give feedback.
All reactions