Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
def get_answer(message):
|
| 5 |
+
params = {"prompt": prompt}
|
| 6 |
+
response = requests.get(API_URL, params=params)
|
| 7 |
+
if response.status_code == 200:
|
| 8 |
+
response_body = response.json().get('body')
|
| 9 |
+
answer = response_body.get('answer')
|
| 10 |
+
return answer
|
| 11 |
+
else:
|
| 12 |
+
return "Sorry, something went wrong. Please try again."
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def upload_file(file):
|
| 16 |
+
# Hier kommt der Code für das Hochladen der Datei basierend auf Ihrer Funktionalität
|
| 17 |
+
pass
|
| 18 |
+
|
| 19 |
+
# Streamlit App
|
| 20 |
+
st.sidebar.title("Wissensguru - IDTA")
|
| 21 |
+
|
| 22 |
+
# Upload-Bereich
|
| 23 |
+
uploaded_file = st.sidebar.file_uploader("Upload PDF file")
|
| 24 |
+
|
| 25 |
+
if uploaded_file is not None:
|
| 26 |
+
upload_file(uploaded_file)
|
| 27 |
+
|
| 28 |
+
# Chatbot-Bereich
|
| 29 |
+
st.sidebar.subheader("Chatbot")
|
| 30 |
+
user_question = st.sidebar.text_input("Ask me a question")
|
| 31 |
+
if st.sidebar.button("Ask"):
|
| 32 |
+
if user_question:
|
| 33 |
+
answer = get_answer(user_question)
|
| 34 |
+
st.write("Answer:", answer)
|