farukkr commited on
Commit
13e90d0
·
verified ·
1 Parent(s): 629b20b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -12
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
- # Text area to display chat history
7
- chat_history = st.text_area("Chat History", "")
8
 
9
- # Simple echo chatbot logic
10
- def chatbot_response(user_input):
11
- return "You said: " + user_input
 
 
 
 
 
 
12
 
13
- # Get response from chatbot
14
- if st.button("Send"):
15
- response = chatbot_response(user_input)
16
- chat_history += f"\nYou: {user_input}\nChatbot: {response}\n"
17
- user_input = ""
 
 
 
 
 
 
 
 
 
 
 
 
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)