Spaces:
Sleeping
Sleeping
Create mistral_inference.py
Browse files- mistral_inference.py +10 -0
mistral_inference.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
def query_mistral(api_url, headers, system_prompt, user_prompt):
|
| 4 |
+
payload = {
|
| 5 |
+
"inputs": f"<s>[INST] {system_prompt}\n\n{user_prompt} [/INST]",
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
response = requests.post(api_url, headers=headers, json=payload)
|
| 9 |
+
response.raise_for_status()
|
| 10 |
+
return response.json()["generated_text"]
|