Delete hf_inference.py
Browse files- hf_inference.py +0 -17
hf_inference.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import requests
|
| 3 |
-
|
| 4 |
-
HF_API_URL = "https://api-inference.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 5 |
-
HF_API_KEY = os.getenv("HF_API_TOKEN") # Set in your Space's Secrets tab
|
| 6 |
-
|
| 7 |
-
headers = {"Authorization": f"Bearer {HF_API_KEY}"}
|
| 8 |
-
|
| 9 |
-
def run_inference(prompt):
|
| 10 |
-
response = requests.post(HF_API_URL, headers=headers, json={"inputs": prompt})
|
| 11 |
-
if response.status_code == 200:
|
| 12 |
-
data = response.json()
|
| 13 |
-
if isinstance(data, list) and len(data) > 0 and "generated_text" in data[0]:
|
| 14 |
-
return data[0]["generated_text"]
|
| 15 |
-
return str(data)
|
| 16 |
-
else:
|
| 17 |
-
return f"Error: {response.status_code} - {response.text}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|