Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,17 +14,19 @@ hf_token = os.getenv("HF_Token")
|
|
14 |
|
15 |
if not hf_token:
|
16 |
raise ValueError("HF_Token is not set. Please check your Hugging Face Secrets.")
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
)
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
print(
|
28 |
|
29 |
|
30 |
'''
|
|
|
14 |
|
15 |
if not hf_token:
|
16 |
raise ValueError("HF_Token is not set. Please check your Hugging Face Secrets.")
|
17 |
+
import requests
|
18 |
|
19 |
+
API_URL = "https://api-inference.huggingface.co/models/meta-llama/Llama-2-7b-chat-hf"
|
20 |
+
headers = {"Authorization": f"Bearer hf_token"}
|
21 |
+
|
22 |
+
def query_llama(prompt):
|
23 |
+
payload = {"inputs": prompt}
|
24 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
25 |
+
return response.json()
|
26 |
|
27 |
+
prompt = "Explain machine learning in simple terms."
|
28 |
+
response = query_llama(prompt)
|
29 |
+
print(response)
|
30 |
|
31 |
|
32 |
'''
|