Mishal23 commited on
Commit
b775857
1 Parent(s): d2b74c9

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -36
app.py DELETED
@@ -1,36 +0,0 @@
1
- import streamlit as st
2
- import requests
3
-
4
- # Set the model ID of your fine-tuned model on Hugging Face
5
- MODEL_ID = "Mishal23/fine-tuned-dialoGPT-crm-chatbot" # Your model ID
6
-
7
- # Function to generate a response from the chatbot using the Hugging Face API
8
- def generate_response(prompt):
9
- # Use the secret token safely
10
- headers = {"Authorization": f"Bearer {st.secrets['project01']['hf_token']}"}
11
- payload = {"inputs": prompt}
12
-
13
- try:
14
- # Correctly formatted API URL
15
- response = requests.post(f"https://api-inference.huggingface.co/models/{MODEL_ID}", headers=headers, json=payload)
16
- response.raise_for_status() # Raise an error for bad responses
17
- return response.json()[0]['generated_text']
18
- except Exception as e:
19
- st.error(f"Error generating response: {e}")
20
- return "Sorry, I couldn't generate a response."
21
-
22
- # Streamlit UI setup
23
- st.title("Chatbot Powered by Hugging Face")
24
- st.subheader("Talk to the Chatbot")
25
-
26
- # User input
27
- user_input = st.text_input("You: ", "")
28
-
29
- # Button to submit the input
30
- if st.button("Send"):
31
- if user_input:
32
- with st.spinner("Generating response..."):
33
- bot_response = generate_response(user_input)
34
- st.text_area("Chatbot:", value=bot_response, height=200)
35
- else:
36
- st.warning("Please enter a message before sending.")