[go: nahoru, domu]

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

vertexai: more than one element in Tools throws an InvalidArgument rpc error #10393

Open
mrothroc opened this issue Jun 18, 2024 · 6 comments
Open
Labels
aiplatform Issues related to the AI Platform (Unified) API. triage me I really want to be triaged.

Comments

@mrothroc
Copy link

Client

vertexai/genai

Environment

Local running on Mac OS X

Go Environment

go version
go version go1.22.2 darwin/arm64

go env
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/mrothroc/Library/Caches/go-build'
GOENV='/Users/mrothroc/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/mrothroc/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/mrothroc/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/mrothroc/IdeaProjects/scrapertest2/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/5c/cwjs85zx5f73qtn3mv7_zh3r0000gn/T/go-build3282724130=/tmp/go-build -gno-record-gcc-switches -fno-common'

Code

	toolSet := make([]tools.Tool, 0)
	funcNames := make(map[string]tools.Tool)

	toolSet = append(toolSet, tools.NewFirstFunction())
	toolSet = append(toolSet, tools.NewSecondFunction())

	gTools := make([]*genai.Tool, 0)
	for _, tool := range toolSet {
		for _, name := range tool.GetNames() {
			funcNames[name] = tool
		}

		gTools = append(gTools, tool.GetDeclaration())
	}

	gemini.Tools = []*genai.Tool{toolSet[0].GetDeclaration(), toolSet[1].GetDeclaration()}

Expected behavior

Call to vertexai to work without an error.

Actual behavior

Error code returned:
rpc error: code = InvalidArgument desc = Request contains an invalid argument.

Additional context

I have validated that providing either tool alone works, so the declaration is valid.

E.g.
gemini.Tools = []*genai.Tool{toolSet[0].GetDeclaration()}
and
gemini.Tools = []*genai.Tool{toolSet[1].GetDeclaration()}

both work without error, but

gemini.Tools = []*genai.Tool{toolSet[0].GetDeclaration(), toolSet[1].GetDeclaration()}

fails with the above error.

@mrothroc mrothroc added the triage me I really want to be triaged. label Jun 18, 2024
@codyoss
Copy link
Member
codyoss commented Jun 18, 2024

cc @jba @eliben

@mrothroc
Copy link
Author

Can anyone suggest workarounds here? Has anyone been able to send multiple tools in an API call to gemini?

@eliben
Copy link
Contributor
eliben commented Jun 24, 2024

@mrothroc could you try to specify a single tool with a list of your functions?
A tool (https://pkg.go.dev/cloud.google.com/go/vertexai/genai#Tool) has a list of function decls you can specify

@mrothroc
Copy link
Author

I thought a tool was supposed to be a group of related functions. The functions I have are completely unrelated, so I thought I was supposed to do it this way.

As a workaround I can try stuffing them all the functions into a single tool.

@mrothroc
Copy link
Author

I can confirm that putting all the functions in the single tool works.

@eliben eliben added the aiplatform Issues related to the AI Platform (Unified) API. label Jun 26, 2024
@eliben
Copy link
Contributor
eliben commented Jun 26, 2024

Thanks for checking. I've labeled the issue aiplatform to indicate it's the underlying API that has the issue - it's not SDK specific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aiplatform Issues related to the AI Platform (Unified) API. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants