forked from stainless-sdks/py-ai-comparison
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmistral_forward_compat.py
More file actions
51 lines (43 loc) · 1.53 KB
/
mistral_forward_compat.py
File metadata and controls
51 lines (43 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import asyncio
import httpx
import respx
from mistralai import Mistral
async def main():
api_key = "<example api key>"
with respx.mock:
respx.mock.get("/v1/batch/jobs/test-job-id").mock(
return_value=httpx.Response(
200,
json={
"status": "UNKNOWN_STATUS", # Unknown enum value
"unexpected_property": True, # Field not in the OpenAPI spec
# mismatched type
"id": {"value": "..."},
# base response
"object": "batch",
"completed_requests": 1,
"input_files": ["file-1"],
"metadata": {},
"endpoint": "",
"errors": [],
"created_at": 1000000,
"started_at": 1000001,
"completed_at": 1000002,
"succeeded_requests": 10,
"failed_requests": 0,
"total_requests": 10,
"model": "mistral-test",
"output_file": "output-file-1",
"error_file": None,
},
)
)
client = Mistral(api_key=api_key)
# crashes
await client.batch.jobs.get_async(
job_id="test-job-id",
http_headers={"x-my-header": "value"},
# note mistral sdk does not support custom query / body params
)
if __name__ == "__main__":
asyncio.run(main())