Skip to content

Commit ab44a2c

Browse files
committed
feat: add gRPC client and endpoint options for GoogleAI
1 parent 0e58efc commit ab44a2c

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

llms/googleai/option.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"cloud.google.com/go/vertexai/genai"
99
"google.golang.org/api/option"
10+
"google.golang.org/grpc"
1011
)
1112

1213
// Options is a set of options for GoogleAI and Vertex clients.
@@ -90,6 +91,24 @@ func WithRest() Option {
9091
}
9192
}
9293

94+
// WithGRPCClient append a ClientOption that uses the provided gRPC client to
95+
// make requests.
96+
// This is useful for gemini clients.
97+
func WithGRPCClient(grpcClient *grpc.ClientConn) Option {
98+
return func(opts *Options) {
99+
opts.ClientOptions = append(opts.ClientOptions, option.WithGRPCConn(grpcClient))
100+
}
101+
}
102+
103+
// WithEndpoint append a ClientOption that uses the provided endpoint to
104+
// make requests.
105+
// This is useful for gemini clients.
106+
func WithEndpoint(endpoint string) Option {
107+
return func(opts *Options) {
108+
opts.ClientOptions = append(opts.ClientOptions, option.WithEndpoint(endpoint))
109+
}
110+
}
111+
93112
// WithHTTPClient append a ClientOption that uses the provided HTTP client to
94113
// make requests.
95114
// This is useful for vertex clients.

0 commit comments

Comments
 (0)