Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,22 +3,20 @@ import streamlit as st
|
|
3 |
|
4 |
import os
|
5 |
HUGGINGFACEHUB_API_TOKEN = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
else:
|
11 |
-
st.write('Goodbye')
|
12 |
|
13 |
-
|
14 |
|
15 |
-
# API_URL = "https://api-inference.huggingface.co/models/meta-llama/LlamaGuard-7b"
|
16 |
-
# headers = {"Authorization": "Bearer {HUGGINGFACEHUB_API_TOKEN}"}
|
17 |
|
18 |
-
# def query(payload):
|
19 |
-
# response = requests.post(API_URL, headers=headers, json=payload)
|
20 |
-
# return response.json()
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
import os
|
5 |
HUGGINGFACEHUB_API_TOKEN = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
6 |
+
API_URL = "https://api-inference.huggingface.co/models/meta-llama/LlamaGuard-7b"
|
7 |
+
headers = {"Authorization": f"Bearer {HUGGINGFACEHUB_API_TOKEN}" }
|
8 |
|
9 |
+
def query(payload):
|
10 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
11 |
+
return response.json()
|
|
|
|
|
12 |
|
|
|
13 |
|
|
|
|
|
14 |
|
|
|
|
|
|
|
15 |
|
16 |
+
st.button("Reset", type="primary")
|
17 |
+
if st.button('Say hello'):
|
18 |
+
output = query({
|
19 |
+
"inputs": "Can you please let us know more details about your ",})
|
20 |
+
st.write(output)
|
21 |
+
else:
|
22 |
+
st.write('Goodbye')
|