LLPhant icon indicating copy to clipboard operation
LLPhant copied to clipboard

[Bug] `generateChat` does not process tools like `generateText` does

Open vijaythecoder opened this issue 1 year ago • 1 comments
trafficstars

I've come across a bug in our code where the generateChat function isn't dealing with tools the same way generateText does. Here's the situation:

For generateChat, the function looks like this:

/**
 * @param  Message[]  $messages
 */
public function generateChat(array $messages): string
{
    $openAiArgs = $this->getOpenAiArgs($messages);
    $answer = $this->client->chat()->create($openAiArgs);

    return $answer->choices[0]->message->content ?? '';
}

and for generateText, it looks like below

public function generateText(string $prompt): string
{
    $answer = $this->generate($prompt);
    $this->handleTools($answer);

    return $answer->choices[0]->message->content ?? '';
}

Expected: generateChat needs to handle the tools.

vijaythecoder avatar Apr 05 '24 19:04 vijaythecoder

Hey @vijaythecoder , do you prefer the behavior of generateText or the behavior of generateTextOrReturnFunctionCalled that gives you more control over the way the function is called?

MaximeThoonsen avatar Apr 10 '24 09:04 MaximeThoonsen