(ctx context.Context, req types.BackendRequest)
| 22 | } |
| 23 | |
| 24 | func (a *Adapter) Invoke(ctx context.Context, req types.BackendRequest) (types.BackendResponse, error) { |
| 25 | start := time.Now() |
| 26 | // Simulate small processing latency. |
| 27 | delay := 20 * time.Millisecond |
| 28 | select { |
| 29 | case <-ctx.Done(): |
| 30 | return types.BackendResponse{}, ctx.Err() |
| 31 | case <-time.After(delay): |
| 32 | } |
| 33 | |
| 34 | text, _ := req.Input["text"].(string) |
| 35 | if text == "" { |
| 36 | text = "No text provided." |
| 37 | } |
| 38 | |
| 39 | end := time.Now() |
| 40 | latency := end.Sub(start).Milliseconds() |
| 41 | return types.BackendResponse{ |
| 42 | Output: map[string]any{ |
| 43 | "text": fmt.Sprintf("[%s] %s", a.cfg.Name, text), |
| 44 | "backend": a.cfg.Name, |
| 45 | }, |
| 46 | Timing: &types.BackendTiming{ |
| 47 | TTFTMs: latency, |
| 48 | CompletionLatencyMs: latency, |
| 49 | Streamed: false, |
| 50 | }, |
| 51 | }, nil |
| 52 | } |
| 53 | |
| 54 | func (a *Adapter) Health(_ context.Context) error { |
| 55 | return nil |
nothing calls this directly
no outgoing calls
no test coverage detected