ChatGPT-Flutter-AIChatBot icon indicating copy to clipboard operation
ChatGPT-Flutter-AIChatBot copied to clipboard

Annoying error

Open Memie1 opened this issue 2 years ago • 1 comments

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_collection_name#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.

Memie1 avatar Jun 25 '23 21:06 Memie1

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...

ritz541 avatar Jul 12 '23 16:07 ritz541