Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to let the AI continue the conversation after calling function #251

Open
samuelgjekic opened this issue Nov 1, 2024 · 1 comment
Open

Comments

@samuelgjekic
Copy link
Contributor

So basically, if i use the return function called method, the AI will respond with the value that got returned from the function.

Is there a way to make it so the AI answers instead?

Example

*Me: Hi!

*AI: hi there!

*Save my email email@mail

AI ...... < I want the AI to continue the conversation, for example say "i have now added your email to the list"

For now, all it does is show me the returned value from the function, the ai is not responding on its own i would have to ask something again for it to talk

Im sorry if this was complicated , i am on my phone just curious to see how other people do when they want to achieve this ?.

@f-lombardo
Copy link
Contributor

f-lombardo commented Nov 1, 2024

Hi @samuelgjekic , it's an interesting question.
generateChat and generateText work that way, i.e. they call the provided functions, if AI engine requires that, and they provide the answer to the user. See for example:

it('can call a function', function () {

or
it('can use the result of a function', function () {

or
it('calls tool functions during a chat', function () {

Note that AnthropicChat can also handle nested function calls:
return $this->generateChat(\array_merge($messages, [AnthropicMessage::fromAssistantAnswer($responses), AnthropicMessage::toolResultMessage($toolsOutput)]));

The generateChatOrReturnFunctionCalled is designed to manually handle this loop: you have to call functions as a result of AI request and then manually provide the results to the engine again.
See for example
it('can call a function and provide the result to the assistant', function () {

I think that @MaximeThoonsen could give a better explanation, maybe correcting me if I missed anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants