LLPhant
LLPhant copied to clipboard
[Bug] `generateChat` does not process tools like `generateText` does
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.
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?