| 9 | ) |
| 10 | |
| 11 | func TestAdapter_InvokeAndMetadata(t *testing.T) { |
| 12 | a := New(config.BackendConfig{ |
| 13 | Name: "m", |
| 14 | Type: "mock", |
| 15 | Capabilities: []string{"chat"}, |
| 16 | Cost: config.CostConfig{Unit: 1}, |
| 17 | }) |
| 18 | resp, err := a.Invoke(context.Background(), types.BackendRequest{ |
| 19 | AIRequest: types.AIRequest{Input: map[string]any{"text": "ping"}}, |
| 20 | }) |
| 21 | if err != nil { |
| 22 | t.Fatal(err) |
| 23 | } |
| 24 | txt, _ := resp.Output["text"].(string) |
| 25 | if txt == "" { |
| 26 | t.Fatal("empty text") |
| 27 | } |
| 28 | if err := a.Health(context.Background()); err != nil { |
| 29 | t.Fatal(err) |
| 30 | } |
| 31 | md := a.Metadata() |
| 32 | if md.Name != "m" || md.Type != "mock" { |
| 33 | t.Fatalf("%+v", md) |
| 34 | } |
| 35 | } |