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}")