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

gemini (vertex): add tool function calling support #748

Closed
semanser opened this issue Apr 2, 2024 · 7 comments · Fixed by #796
Closed

gemini (vertex): add tool function calling support #748

semanser opened this issue Apr 2, 2024 · 7 comments · Fixed by #796

Comments

@semanser
Copy link

semanser commented Apr 2, 2024

Hi, is there any specific reason why function calling wasn't implemented for Vertex in #709? I may give it a try, but I just want to make sure that there are no known blockers.

case schema.ChatMessageTypeFunction, schema.ChatMessageTypeTool:
fallthrough
default:
return nil, fmt.Errorf("role %v not supported", content.Role)

Resources:

@semanser
Copy link
Author

semanser commented Apr 2, 2024

I started implementing this but immediately found an issue: function calling is supported in Vertex (cloud.google.com/go/vertexai/genai) but not in github.com/google/generative-ai-go/genai.

vertex.go is generated based on the googleai.go with the main difference that GenerativeModel returns different models in both files. That means that we can't use vertexGenAI "cloud.google.com/go/vertexai/genai" inside of googleai.go...

Screenshot 2024-04-02 at 18 01 52 Screenshot 2024-04-02 at 18 02 07

@semanser
Copy link
Author

semanser commented Apr 2, 2024

In other words, we can't add any vertex-specific logic inside of googleai.go, and the only way to do that is to change it via generate-vertex.go. This might increase the difference between the two files (vertex and googleai), but I'm not sure if it's significant enough to stopp the use of the generator. I will wait for input from @tmc here.

@eliben
Copy link
Collaborator

eliben commented Apr 4, 2024

Tool calling is implemented in the latest version of googleai -- see https://pkg.go.dev/github.com/google/generative-ai-go@v0.10.0/genai#example-Tool

Happy to review PRs here

@eliben
Copy link
Collaborator

eliben commented Apr 17, 2024

@semanser are you planning to continue working on this in the immediate future? I want this implemented, so I was thinking of tackling it myself unless you have a PR in progress already

@semanser
Copy link
Author

@eliben I'm not planning to, so feel free to continue 👍

@eliben
Copy link
Collaborator

eliben commented Apr 19, 2024

The Google AI part (ai.google.dev) is done in #794
I'll look into implementing this for the Vertex side as well

@eliben
Copy link
Collaborator

eliben commented Apr 19, 2024

#795 adds vertex ai support.

Next, an example and this issue can be closed

eliben added a commit that referenced this issue Apr 19, 2024
eliben added a commit that referenced this issue Apr 19, 2024
* googleai: add example of tool calling

Fixes #748
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 a pull request may close this issue.

2 participants