mery22 commited on
Commit
ab55f29
1 Parent(s): 77bd906

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -12
app.py CHANGED
@@ -122,15 +122,24 @@ qa = RetrievalQA.from_chain_type(
122
  chain_type_kwargs={"prompt": prompt},
123
  )
124
 
125
- import gradio as gr
126
- def qna_chatbot(message, history):
127
-
128
- res = qa(message)
129
- answer = res["result"]
130
- return answer
131
-
132
-
133
- chat_interface = gr.ChatInterface(qna_chatbot)
134
-
135
- if __name__ == "__main__":
136
- chat_interface.launch(debug=True)
 
 
 
 
 
 
 
 
 
 
122
  chain_type_kwargs={"prompt": prompt},
123
  )
124
 
125
+ import streamlit as st
126
+
127
+ # Streamlit interface
128
+ st.title("Chatbot Interface")
129
+
130
+ # Define function to handle user input and display chatbot response
131
+ def chatbot_response(user_input):
132
+ response = qa.get_answer(user_input)
133
+ return response
134
+
135
+ # Streamlit components
136
+ user_input = st.text_input("You:", "")
137
+ submit_button = st.button("Send")
138
+
139
+ # Handle user input
140
+ if submit_button:
141
+ if user_input.strip() != "":
142
+ bot_response = chatbot_response(user_input)
143
+ st.text_area("Bot:", value=bot_response, height=200)
144
+ else:
145
+ st.warning("Please enter a message.")