API OpenAI не работает после того, как я изменил API
void callAPIs(String personalityType, String weightCount) async {
ImageService imageService = ImageService();
String gptPrompt =
"Analyze My personality type and create a stable diffusion prompt. Do not ever write a word except the prompt or my app will be crashed. Just the prompt please! Here’s a formula for a Stable Diffusion image prompt: An image of [adjective] [subject] [doing action], [creative lighting style], detailed, realistic, trending on artstation, in style of [famous artist 1], [famous artist 2], [famous artist 3]. " +
personalityType;
String imageInput = await OpenAIService.generateStory(gptPrompt);
print(imageInput);
}
import 'package:dart_openai/dart_openai.dart';
class OpenAIService {
static Future<String> generateStory(String input) async {
try {
OpenAI.apiKey = "my beautiful apiKey";
var messages = [
OpenAIChatCompletionChoiceMessageModel(
content: input,
role: OpenAIChatMessageRole.user,
),
];
var chatModel = await OpenAI.instance.chat.create(
model: "gpt-3.5-turbo",
messages: messages,
);
return chatModel.choices.first.message.content;
} catch (e) {
print('An error occurred: $e');
throw Exception('Failed to generate story');
}
}
}
Код был в порядке, пока я не изменил apiKey в openai. И нет ни ответа, ни отладочной печати.
Я пытался переписать код снова и снова, но ответа по-прежнему не было. Пожалуйста помоги