File size: 932 Bytes
475cab6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import requests

# Hugging Face API URL
API_URL = "https://api-inference.huggingface.co/models/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"

# Function to query the Hugging Face API
def query(payload):
    headers = {"Authorization": f"Bearer {st.secrets['HF_TOKEN']}"}
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.json()

# Streamlit app
st.title("DeepSeek-R1-Distill-Qwen-32B Chatbot")

# Input text box
user_input = st.text_input("Enter your message:")

if user_input:
    # Query the Hugging Face API with the user input
    payload = {"inputs": user_input}
    output = query(payload)
    
    # Display the output
    if isinstance(output, list) and len(output) > 0 and 'generated_text' in output[0]:
        st.write("Response:")
        st.write(output[0]['generated_text'])
    else:
        st.write("Error: Unable to generate a response. Please try again.")