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