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

Implement constrained function calling #121

Merged
merged 3 commits into from
Apr 17, 2024
Merged

Implement constrained function calling #121

merged 3 commits into from
Apr 17, 2024

Conversation

natebosch
Copy link
Collaborator

@natebosch natebosch commented Apr 12, 2024

Function calling configuration allows specifying that the model must, or
must not, call a function on the current response. By default the model
is allowed to choose whether to call a function or reply in natural
language.

Add a ToolConfig class and a toolConfig argument to the
GenerativeModel constructor and the methods for generating content.
The classes and fields match the API model directly.

Add support for overriding the tools for a specific generate content
call from what was set during instantiation.

Function calling configuration allows specifying that the model must, or
must not, call a function on the current response. By default the model
is allowed to choose whether to call a function or reply in natural
language.

Add a `FunctionCallingConfig` class and a `functionCallingConfig`
argument to the `GeneratieModel` constructor and the methods for
generating content. The classes are fields match the API model directly.

Add support for overriding the `tools` for a specific generate content
call.
@natebosch natebosch requested a review from devoncarew April 12, 2024 22:17
@natebosch natebosch marked this pull request as draft April 12, 2024 22:34
@natebosch natebosch removed the request for review from devoncarew April 12, 2024 22:35
@natebosch natebosch requested a review from devoncarew April 12, 2024 23:03
@natebosch natebosch marked this pull request as ready for review April 12, 2024 23:03
Copy link
Collaborator

@devoncarew devoncarew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention how to use tools in the package docs? Point to more comprehensive online docs?

Similarly, we should have an example of how to use tools in samples/dart (if we don't want to do that as part of this PR we should track in an issue).

pkgs/google_generative_ai/lib/src/model.dart Show resolved Hide resolved
pkgs/google_generative_ai/lib/src/model.dart Show resolved Hide resolved
@natebosch
Copy link
Collaborator Author

Similarly, we should have an example of how to use tools in samples/dart (if we don't want to do that as part of this PR we should track in an issue).

We have an example with basic function calling. Brian's guessing game is also a nice example to implement on top of constrained function calling so I think that's probably the best sample to run with.

83be363

@natebosch natebosch merged commit 95b2cfb into main Apr 17, 2024
7 checks passed
@natebosch natebosch deleted the tool-config branch April 17, 2024 00:25
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

Successfully merging this pull request may close these issues.

2 participants