Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,31 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
-
# Text input for user to type messages
|
| 4 |
-
user_input = st.text_input("User Input")
|
| 5 |
|
| 6 |
-
|
| 7 |
-
chat_history = st.text_area("Chat History", "")
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
API_URL = "https://jj78yliqd7.execute-api.eu-central-1.amazonaws.com/dev/chatbot"
|
|
|
|
| 5 |
|
| 6 |
+
def get_answer(prompt, message):
|
| 7 |
+
params = {"prompt": prompt}
|
| 8 |
+
response = requests.get(API_URL, params=params)
|
| 9 |
+
if response.status_code == 200:
|
| 10 |
+
response_body = response.json().get('body')
|
| 11 |
+
answer = response_body.get('answer')
|
| 12 |
+
return answer
|
| 13 |
+
else:
|
| 14 |
+
return "Sorry, something went wrong. Please try again."
|
| 15 |
|
| 16 |
+
# Streamlit App
|
| 17 |
+
st.sidebar.title("Wissensguru - IDTA")
|
| 18 |
+
|
| 19 |
+
# Upload-Bereich
|
| 20 |
+
uploaded_file = st.file_uploader("Upload PDF file")
|
| 21 |
+
|
| 22 |
+
if uploaded_file is not None:
|
| 23 |
+
upload_file(uploaded_file)
|
| 24 |
+
|
| 25 |
+
# Chatbot-Bereich
|
| 26 |
+
st.subheader("Chatbot")
|
| 27 |
+
user_question = st.text_input("Ask me a question")
|
| 28 |
+
if st.button("Ask"):
|
| 29 |
+
if user_question:
|
| 30 |
+
answer = get_answer(user_question)
|
| 31 |
+
st.write("Answer:", answer)
|