File size: 710 Bytes
5cc30ef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import streamlit as st
import requests
import os
st.title("My Hugging Face Model Interface")
input_text = st.text_area("Enter your text:", "")
HF_TOKEN = os.getenv("HF_TOKEN") # Loaded from Hugging Face Secrets
if st.button("Get Prediction") and input_text:
headers = {"Authorization": f"Bearer {HF_TOKEN}"} if HF_TOKEN else {}
response = requests.post(
"https://api-inference.huggingface.co/models/rajan3208/uzmi-gpt",
headers=headers,
json={"inputs": input_text}
)
if response.status_code == 200:
st.success("Prediction:")
st.write(response.json()[0]['generated_text'])
else:
st.error(f"Error {response.status_code}: {response.text}")
|