Spaces:
Configuration error
Configuration error
update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,43 @@
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
st.title('Chatbot')
|
5 |
|
6 |
-
user_input = st.text_input("Enter your question here:")
|
7 |
|
8 |
-
if st.button('Submit'):
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
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.')
|