MCPcopy Create free account
hub / github.com/InferCore/InferCore / Invoke

Method Invoke

internal/adapters/mock/mock.go:24–52  ·  view source on GitHub ↗
(ctx context.Context, req types.BackendRequest)

Source from the content-addressed store, hash-verified

22}
23
24func (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
54func (a *Adapter) Health(_ context.Context) error {
55 return nil

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected