maximerenou / php-bing-ai

⚠️ Deprecated PHP client for Bing AI (Chat / GPT-4, Image Creator / DALL-E)
MIT License
42 stars 13 forks source link

[improvement] We should reduce array-returns in Favor of Objects for Conversion::ask #19

Closed typoworx-de closed 7 months ago

typoworx-de commented 9 months ago
    public function ask(Prompt $message, $callback = null)
    {
....
        return [$this->current_text, $this->current_messages];
    }

https://github.com/maximerenou/php-bing-ai/blob/ca23404009ec1960776caf097b20e68ad624dd81/src/Chat/Conversation.php#L200

Should be refactored like done with createImages:

$conversation = $ai->createChatConversation();
$prompt = new \MaximeRenou\BingAI\Chat\Prompt('Wer ist Albert Einstein');
$request = $conversation->ask('Who is Albert Einstein');
$request->wait();

if (!$request->hasFailed)
{
    debug($request->currentText, $request->currentMessages);
}

This makes everything more smooth and the code will be much cleaner than working like this (see example-code):

$prompt = new \MaximeRenou\BingAI\Chat\Prompt('Wer ist Albert Einstein'); list($text, $cards) = $conversation->ask($prompt);

maximerenou commented 7 months ago

Hello, I'm sorry but using std classes instead of arrays wouldn't necessarily be more convenient for everyone. I understand that the syntax is not ideal, but it seems right considering those variables aren't class properties. Thanks for the suggestion, Greetings