| 921 | ) |
| 922 | |
| 923 | def handler(request: httpx.Request) -> httpx.Response: |
| 924 | body = json.loads(request.content.decode("utf-8")) |
| 925 | calls.append(str(body.get("model"))) |
| 926 | if len(calls) == 1: |
| 927 | raise httpx.RemoteProtocolError("server disconnected") |
| 928 | return httpx.Response( |
| 929 | 200, |
| 930 | json={ |
| 931 | "id": "chatcmpl-test", |
| 932 | "object": "chat.completion", |
| 933 | "model": body.get("model"), |
| 934 | "choices": [{"index": 0, "message": {"role": "assistant", "content": "ok"}}], |
| 935 | }, |
| 936 | ) |
| 937 | |
| 938 | traces = TraceStore(storage=InMemoryTraceStorage()) |
| 939 | async_client = httpx.AsyncClient(transport=httpx.MockTransport(handler)) |