googleapis / googleapis/google-cloud-go

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

Open
#10,393 6 comments 0 reactions 0 assignees View on GitHub
aiplatform triage me
Dominant language
Go
Stars
4.5k
Forks
1.6k
Avg merge
1d 13h
Merged PRs (30d)
109

Description

**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**

```go
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.