| 12345678910111213141516171819202122232425262728293031323334 |
- 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,
- }
- }
|