iampawan / ChatGPT-Flutter-AIChatBot

A Chatbot chat app built using the Flutter framework and OpenAI's GPT-3 language model.
230 stars 99 forks source link

Annoying error #23

Open Memie1 opened 1 year ago

Memie1 commented 1 year ago

This widget is giving an error at this widget: void _sendMessage() async { if (_controller.text.isEmpty) return; ChatMessage message = ChatMessage( text: _controller.text, sender: "user", isImage: false, );

setState(() {
  _messages.insert(0, message);
  _isTyping = true;
});

_controller.clear();

if (_isImageSearch) {
  final request = GenerateImage(message.text, 1, size: "256x256");

  final response = await chatGPT!.generateImage(request);
  Vx.log(response!.data!.last!.url!);
  insertNewData(response.data!.last!.url!, isImage: true);
} else {
  final request =
      CompleteText(prompt: message.text, model: kTranslateModelV3);

  final response = await chatGPT!.onCompleteText(request: request);
  Vx.log(response!.choices[0].text);
  insertNewData(response.choices[0].text, isImage: false);
}

}

This is the error: [{ "resource": "", "owner": "_generated_diagnostic_collectionname#1", "code": { "value": "undefined_method", "target": { "$mid": 1, "path": "/diagnostics/undefined_method", "scheme": "https", "authority": "dart.dev" } }, "severity": 8, "message": "The method 'onCompleteText' isn't defined for the type 'OpenAI'.\nTry correcting the name to the name of an existing method, or defining a method named 'onCompleteText'.", "source": "dart", "startLineNumber": 68, "startColumn": 39, "endLineNumber": 68, "endColumn": 53 }]

I've been trying to troubleshoot this for a couple of hours. I've tried adding different dependencies, but nothing is working. Would appreciate help. It's literally just the onCompleteText that is giving me an error. I would have thought using the most up-to-date dependency would help but nothing is working.

ritz541 commented 12 months ago

chat_screen.txt

Refer to the uploaded file. The file is .txt replace it with dart and copy it in you project with an .dart extension Also add you api key where it is written past_your_api_key

And then you are good to go.

If any persists you can ask me...