Spaces:
Sleeping
Sleeping
Download app.py from YADUUG/TechSirius: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/spaces/YADUUG/TechSirius/resolve/main/app.py
- Command line
-
hf download hf://spaces/YADUUG/TechSirius/app.py
-
curl -L -o app.py https://huggingface.co/spaces/YADUUG/TechSirius/resolve/main/app.py
1.05 kB
| import requests | |
| import streamlit as st | |
| # Load API key from Streamlit secrets | |
| API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B" | |
| global api_key | |
| headers = {"Authorization": f"Bearer {api_key}"} | |
| # Function to query the model | |
| def query_model(input_text): | |
| payload = {"inputs": input_text} | |
| response = requests.post(API_URL, headers=headers, json=payload) | |
| return response.json() | |
| # Streamlit interface | |
| st.title("Hugging Face Inference with Streamlit") | |
| # Input from the user | |
| user_input = st.text_area("Enter your prompt:", "") | |
| if st.button("Generate Response"): | |
| if user_input: | |
| with st.spinner('Generating response...'): | |
| result = query_model(user_input) | |
| # Display the result | |
| if "error" in result: | |
| st.error(f"Error: {result['error']}") | |
| else: | |
| st.success("Response generated successfully!") | |
| st.write(result[0]["generated_text"]) | |
| else: | |
| st.error("Please enter a prompt to generate a response.") | |