mirror of
https://github.com/sst/opencode.git
synced 2025-08-06 14:28:09 +00:00
34 lines
692 B
Go
34 lines
692 B
Go
package provider
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
"os"
|
|
|
|
"google.golang.org/genai"
|
|
)
|
|
|
|
type VertexAIClient ProviderClient
|
|
|
|
func newVertexAIClient(opts providerClientOptions) VertexAIClient {
|
|
geminiOpts := geminiOptions{}
|
|
for _, o := range opts.geminiOptions {
|
|
o(&geminiOpts)
|
|
}
|
|
|
|
client, err := genai.NewClient(context.Background(), &genai.ClientConfig{
|
|
Project: os.Getenv("VERTEXAI_PROJECT"),
|
|
Location: os.Getenv("VERTEXAI_LOCATION"),
|
|
Backend: genai.BackendVertexAI,
|
|
})
|
|
if err != nil {
|
|
slog.Error("Failed to create VertexAI client", "error", err)
|
|
return nil
|
|
}
|
|
|
|
return &geminiClient{
|
|
providerOptions: opts,
|
|
options: geminiOpts,
|
|
client: client,
|
|
}
|
|
}
|