ruslanmv commited on
Commit
475cab6
·
verified ·
1 Parent(s): c9a4507

Create app_base.py

Browse files
Files changed (1) hide show
  1. app_base.py +29 -0
app_base.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+
4
+ # Hugging Face API URL
5
+ API_URL = "https://api-inference.huggingface.co/models/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"
6
+
7
+ # Function to query the Hugging Face API
8
+ def query(payload):
9
+ headers = {"Authorization": f"Bearer {st.secrets['HF_TOKEN']}"}
10
+ response = requests.post(API_URL, headers=headers, json=payload)
11
+ return response.json()
12
+
13
+ # Streamlit app
14
+ st.title("DeepSeek-R1-Distill-Qwen-32B Chatbot")
15
+
16
+ # Input text box
17
+ user_input = st.text_input("Enter your message:")
18
+
19
+ if user_input:
20
+ # Query the Hugging Face API with the user input
21
+ payload = {"inputs": user_input}
22
+ output = query(payload)
23
+
24
+ # Display the output
25
+ if isinstance(output, list) and len(output) > 0 and 'generated_text' in output[0]:
26
+ st.write("Response:")
27
+ st.write(output[0]['generated_text'])
28
+ else:
29
+ st.write("Error: Unable to generate a response. Please try again.")