Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,11 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
import requests
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
HF_API_TOKEN = os.getenv("HF_API_TOKEN")
|
| 6 |
API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B-Instruct"
|
| 7 |
headers = {"Authorization": f"Bearer {HF_API_TOKEN}"}
|
| 8 |
|
| 9 |
-
|
| 10 |
-
response = requests.post(API_URL, headers=headers, json={"inputs": prompt})
|
| 11 |
-
if response.status_code == 200:
|
| 12 |
-
return response.json()[0]['generated_text']
|
| 13 |
-
else:
|
| 14 |
-
return f"Error: {response.status_code} - {response.text}"
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 1 |
import requests
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
HF_API_TOKEN = os.getenv("HF_API_TOKEN") # or paste explicitly for quick test
|
| 5 |
API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B-Instruct"
|
| 6 |
headers = {"Authorization": f"Bearer {HF_API_TOKEN}"}
|
| 7 |
|
| 8 |
+
response = requests.post(API_URL, headers=headers, json={"inputs": "Test LLaMA-3 endpoint."})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
print("Status code:", response.status_code)
|
| 11 |
+
print("Response:", response.text)
|