(cfg config.BackendConfig)
| 57 | } |
| 58 | |
| 59 | func New(cfg config.BackendConfig) *Adapter { |
| 60 | timeout := time.Duration(cfg.TimeoutMS) * time.Millisecond |
| 61 | if timeout <= 0 { |
| 62 | timeout = 60 * time.Second |
| 63 | } |
| 64 | vertex := cfg.Type == "gemini_vertex" |
| 65 | base := strings.TrimSpace(cfg.Endpoint) |
| 66 | if base == "" { |
| 67 | if vertex { |
| 68 | loc := strings.TrimSpace(cfg.VertexLocation) |
| 69 | if loc == "" { |
| 70 | loc = "us-central1" |
| 71 | } |
| 72 | base = fmt.Sprintf("https://%s-aiplatform.googleapis.com", loc) |
| 73 | } else { |
| 74 | base = defaultGeminiEndpoint |
| 75 | } |
| 76 | } |
| 77 | return &Adapter{ |
| 78 | cfg: cfg, |
| 79 | vertex: vertex, |
| 80 | baseURL: strings.TrimRight(base, "/"), |
| 81 | httpClient: &http.Client{ |
| 82 | Timeout: timeout, |
| 83 | }, |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | func (a *Adapter) Name() string { |
| 88 | return a.cfg.Name |
no outgoing calls