Spaces:
Runtime error
Runtime error
Commit
•
a16dd24
1
Parent(s):
db01e77
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import os
|
3 |
+
import requests
|
4 |
+
|
5 |
+
# Set your model and project details
|
6 |
+
project_name = 'my_autotrain_llm'
|
7 |
+
model_name = 'abhishek/llama-2-7b-hf-small-shards'
|
8 |
+
hf_token = 'YOUR_HUGGING_FACE_TOKEN' # Replace with your Hugging Face token
|
9 |
+
|
10 |
+
# Set Hugging Face API endpoint
|
11 |
+
hf_api_endpoint = 'https://huggingface.co/am-nandeesh/jql'
|
12 |
+
|
13 |
+
st.title("Streamlit App for Hugging Face Spaces")
|
14 |
+
|
15 |
+
user_input = st.text_area("Enter Text:", "Type your text here...")
|
16 |
+
|
17 |
+
|
18 |
+
if st.button("Run Model"):
|
19 |
+
headers = {"Authorization": f"Bearer {hf_token}"}
|
20 |
+
data = {"inputs": user_input}
|
21 |
+
|
22 |
+
response = requests.post(
|
23 |
+
f"{hf_api_endpoint}{model_name}/tasks/text-generation",
|
24 |
+
headers=headers,
|
25 |
+
json=data
|
26 |
+
)
|
27 |
+
|
28 |
+
if response.status_code == 200:
|
29 |
+
output_text = response.json()['predictions'][0]
|
30 |
+
st.success(f"Model Output: {output_text}")
|
31 |
+
else:
|
32 |
+
st.error(f"Error running the model. Status code: {response.status_code}")
|