Skip to content

Commit 6361eb9

Browse files
authored
feat(go/plugins/vertexai): add Anthropic via Model Garden support (#2749)
1 parent 83efb55 commit 6361eb9

File tree

9 files changed

+965
-0
lines changed

9 files changed

+965
-0
lines changed

go/go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
firebase.google.com/go/v4 v4.14.1
1414
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.46.0
1515
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.22.0
16+
github.com/anthropics/anthropic-sdk-go v0.2.0-beta.3
1617
github.com/blues/jsonata-go v1.5.4
1718
github.com/google/dotprompt/go v0.0.0-20250415074656-072d95deb01d
1819
github.com/google/go-cmp v0.7.0
@@ -80,6 +81,10 @@ require (
8081
github.com/mitchellh/mapstructure v1.5.0 // indirect
8182
github.com/oklog/ulid v1.3.1 // indirect
8283
github.com/pkg/errors v0.9.1 // indirect
84+
github.com/tidwall/gjson v1.14.4 // indirect
85+
github.com/tidwall/match v1.1.1 // indirect
86+
github.com/tidwall/pretty v1.2.1 // indirect
87+
github.com/tidwall/sjson v1.2.5 // indirect
8388
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
8489
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
8590
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect

go/go.sum

+12
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN
4040
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
4141
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
4242
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
43+
github.com/anthropics/anthropic-sdk-go v0.2.0-beta.3 h1:b5t1ZJMvV/l99y4jbz7kRFdUp3BSDkI8EhSlHczivtw=
44+
github.com/anthropics/anthropic-sdk-go v0.2.0-beta.3/go.mod h1:AapDW22irxK2PSumZiQXYUFvsdQgkwIWlpESweWZI/c=
4345
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
4446
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
4547
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
@@ -258,7 +260,17 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
258260
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
259261
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
260262
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
263+
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
264+
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
265+
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
266+
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
267+
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
261268
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
269+
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
270+
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
271+
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
272+
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
273+
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
262274
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
263275
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
264276
github.com/uptrace/bun v1.1.12 h1:sOjDVHxNTuM6dNGaba0wUuz7KvDE1BmNu9Gqs2gJSXQ=

go/internal/base/json.go

+6
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ func SchemaAsMap(s *jsonschema.Schema) map[string]any {
104104
if err != nil {
105105
log.Panicf("failed to marshal schema: %v", err)
106106
}
107+
108+
// Check if the marshaled JSON is "true" (indicates an empty schema)
109+
if string(jsb) == "true" {
110+
return make(map[string]any)
111+
}
112+
107113
var m map[string]any
108114
err = json.Unmarshal(jsb, &m)
109115
if err != nil {

go/plugins/internal/models.go

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Package internal contains code that is common to all models
16+
package internal
17+
18+
import "github.com/firebase/genkit/go/ai"
19+
20+
var (
21+
// BasicText describes model capabilities for text-only models.
22+
BasicText = ai.ModelSupports{
23+
Multiturn: true,
24+
Tools: true,
25+
ToolChoice: true,
26+
SystemRole: true,
27+
Media: false,
28+
}
29+
30+
// Multimodal describes model capabilities for multimodal models.
31+
Multimodal = ai.ModelSupports{
32+
Multiturn: true,
33+
Tools: true,
34+
ToolChoice: true,
35+
SystemRole: true,
36+
Media: true,
37+
Constrained: ai.ConstrainedSupportNoTools,
38+
}
39+
)

0 commit comments

Comments
 (0)