Asiya057 commited on
Commit
218ee66
·
verified ·
1 Parent(s): 891be82

update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -9
app.py CHANGED
@@ -1,13 +1,43 @@
 
 
1
  import streamlit as st
2
- from main import qa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- st.title('Chatbot')
5
 
6
- user_input = st.text_input("Enter your question here:")
7
 
8
- if st.button('Submit'):
9
- if user_input:
10
- response = qa({"question": user_input})
11
- st.write('Chatbot:', response.get('answer', ''))
12
- else:
13
- st.write('Please enter a question.')
 
1
+ # streamlit_app.py
2
+
3
  import streamlit as st
4
+ import requests
5
+
6
+ # FastAPI server URL
7
+ api_url = "http://localhost:8000/chat/"
8
+
9
+ st.title("Conversational QA Chain")
10
+
11
+ # Streamlit input elements
12
+ question = st.text_input("Ask a question:")
13
+ if st.button("Submit"):
14
+ if question:
15
+ response = requests.get(api_url, params={"str1": question})
16
+ if response.ok:
17
+ answer = response.json().get('message', 'No answer received')
18
+ st.write(f"Answer: {answer}")
19
+ else:
20
+ st.write("Error: Unable to get a response from the server")
21
+
22
+ # Example of providing some information about the app
23
+ st.markdown("""
24
+ ### Instructions
25
+ 1. Enter your question in the text box.
26
+ 2. Click on 'Submit' to get the answer.
27
+ """)
28
+
29
+
30
+
31
+ # import streamlit as st
32
+ # from main import qa
33
 
34
+ # st.title('Chatbot')
35
 
36
+ # user_input = st.text_input("Enter your question here:")
37
 
38
+ # if st.button('Submit'):
39
+ # if user_input:
40
+ # response = qa({"question": user_input})
41
+ # st.write('Chatbot:', response.get('answer', ''))
42
+ # else:
43
+ # st.write('Please enter a question.')