(ctx context.Context, req types.BackendRequest)
| 111 | } |
| 112 | |
| 113 | func (a *Adapter) Invoke(ctx context.Context, req types.BackendRequest) (types.BackendResponse, error) { |
| 114 | text, _ := req.Input["text"].(string) |
| 115 | if text == "" { |
| 116 | text = "No text provided." |
| 117 | } |
| 118 | model := a.modelID() |
| 119 | if model == "" { |
| 120 | return types.BackendResponse{}, upstream.New(upstream.KindBackendError, "gemini backend requires default_model") |
| 121 | } |
| 122 | if a.apiKey() == "" { |
| 123 | return types.BackendResponse{}, upstream.New(upstream.KindBackendError, "gemini backend requires api_key") |
| 124 | } |
| 125 | |
| 126 | if req.Options.Stream { |
| 127 | return a.invokeStream(ctx, text, model) |
| 128 | } |
| 129 | return a.invokeNonStream(ctx, text, model) |
| 130 | } |
| 131 | |
| 132 | func (a *Adapter) invokeNonStream(ctx context.Context, text, model string) (types.BackendResponse, error) { |
| 133 | t0 := time.Now() |
nothing calls this directly
no test coverage detected