File size: 757 Bytes
ccabf63 be50a26 929cdfc be50a26 929cdfc be50a26 929cdfc be50a26 929cdfc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import streamlit as st
import requests
# Set up the API endpoint and headers
API_URL = "https://api-inference.huggingface.co/models/tencent/Tencent-Hunyuan-Large"
HF_API_KEY = st.secrets["HF_API_KEY"] # Load the API key from secrets
def query(payload):
headers = {"Authorization": f"Bearer {HF_API_KEY}"}
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
# Create a text input field for the user
st.title("Tencent-Hunyuan-Large Model Demo")
user_input = st.text_input("Enter your text:", "")
# Create a button to trigger the API request
if st.button("Query Model"):
# Prepare the payload and send the request
payload = {"inputs": user_input}
response = query(payload)
st.write(response) |