Daniel4343 commited on
Commit
ff1f92b
1 Parent(s): 32b6f57

Upload 8 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ files/Vorsorge[[:space:]]und[[:space:]]Verhalten[[:space:]]bei[[:space:]]Unwetter[[:space:]]-[[:space:]]Was[[:space:]]tun[[:space:]]bei[[:space:]]Unwetter_[[:space:]]-[[:space:]]BBK.pdf filter=lfs diff=lfs merge=lfs -text
files/Vorsorge und Verhalten bei Unwetter - Was tun bei Unwetter_ - BBK.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76356872fafaa2ae3d092837fd41e363a4adde4e66a572ce900e88f2c0ebf868
3
+ size 1447154
landing.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ import datetime
4
+ import pandas as pd
5
+ from pathlib import Path
6
+
7
+ st.set_page_config(
8
+ page_title="Startseite",
9
+ layout="wide",
10
+ initial_sidebar_state="expanded",
11
+ )
12
+
13
+ st.sidebar.markdown("# Startseite")
14
+
15
+
16
+ # HEADER
17
+ header = st.title("Dateiupload für Behörden und Organisationen mit Sicherheitsaufgaben")
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
pages/__pycache__/table.cpython-311.pyc ADDED
Binary file (4.09 kB). View file
 
pages/__pycache__/upload.cpython-311.pyc ADDED
Binary file (2.29 kB). View file
 
pages/about.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ import datetime
4
+ import pandas as pd
5
+ from pathlib import Path
6
+
7
+ st.set_page_config(
8
+ page_title="Impressum",
9
+ layout="wide",
10
+ initial_sidebar_state="expanded",
11
+ )
12
+
13
+ st.markdown("# Impressum")
14
+ st.sidebar.markdown("# Impressum")
pages/bot.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ import datetime
4
+ import pandas as pd
5
+ from pathlib import Path
6
+ # to-do import upload
7
+
8
+
9
+ st.markdown("# Chatbot")
10
+ st.sidebar.markdown("# Chatbot")
11
+
12
+ uploaded_file = '' # PLACEHOLDER
13
+
14
+ # Display file content
15
+ file_content = uploaded_file.read()
16
+ st.write("Dateiinhalt:")
17
+ st.code(file_content)
18
+
19
+ # User input for question
20
+ user_question = st.text_input("Stellen Sie eine Frage zum hochgeladenen PDF:")
21
+
22
+
23
+ # Perform Hugging Face task (e.g., question answering)
24
+ if user_question:
25
+ question_answering = pipeline(
26
+ "question-answering",
27
+ model="deepset/gelectra-base-germanquad-distilled",
28
+ tokenizer="deepset/gelectra-base-germanquad-distilled"
29
+ )
30
+
31
+ # Get answer to the user's question
32
+ answer = question_answering(question=user_question, context=file_content)
33
+
34
+ # Display the answer to the user's question
35
+ st.write(f"Antwort auf die Frage '{user_question}': {answer['answer']}")
36
+ st.write("Confidence Score:", answer['score'])
pages/table.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from datetime import datetime
4
+ import pandas as pd
5
+ from pathlib import Path
6
+ import csv
7
+ import os
8
+
9
+ st.set_page_config(
10
+ page_title="Hochgeladene Dokumente",
11
+ layout="wide",
12
+ initial_sidebar_state="expanded",
13
+ )
14
+
15
+ make_button_smaller = """
16
+ <style>
17
+ .stbutton {
18
+ width: 20px;
19
+ height: 19px;
20
+ }
21
+ </style>
22
+ """
23
+ st.markdown(make_button_smaller, unsafe_allow_html=True)
24
+ st.markdown("# Hochgeladene Dokumente")
25
+ st.sidebar.markdown("# Hochgeladene Dokumente")
26
+
27
+ field_names = ['Index', 'Titel', 'Hochladezeitpunkt']
28
+
29
+ FILES = []
30
+
31
+ def newIndex():
32
+ lastIndex = len(FILES)
33
+ newIndex = lastIndex + 1
34
+ return newIndex
35
+
36
+ def generate_files():
37
+ folder = 'C:/Users/keckm/Documents/GitHub/Streamlit/files'
38
+ files = os.listdir(folder)
39
+ for file in files:
40
+ file_path = Path(folder, file)
41
+ index = newIndex()
42
+ title = file
43
+ upload_time = os.path.getctime(Path(folder, file))
44
+ upload_time = datetime.fromtimestamp(upload_time).strftime("%d.%m.%Y - %H:%M:%S")
45
+ if os.path.isfile(file_path):
46
+ file_info = {
47
+ "Index": index,
48
+ "Titel": title,
49
+ "Hochladezeitpunkt": upload_time
50
+ }
51
+ FILES.append(file_info)
52
+ return FILES
53
+
54
+ def delete_entry(key):
55
+ folder = 'C:/Users/keckm/Documents/GitHub/Streamlit/files'
56
+ file = FILES[key]['Titel']
57
+ os.remove(Path(folder, file))
58
+ FILES.pop(key)
59
+ generate_files()
60
+
61
+
62
+ def display_table():
63
+ hide_table_row_index = """
64
+ <style>
65
+ thead tr th:first-child {display:none}
66
+ tbody th {display:none}
67
+ </style>
68
+ """
69
+
70
+
71
+ # Inject CSS with Markdown
72
+ st.markdown(hide_table_row_index, unsafe_allow_html=True)
73
+
74
+ # Display a static table
75
+ col1, col2 = st.columns([5, 1])
76
+ with col1:
77
+ table1 = pd.DataFrame.from_dict(generate_files())
78
+ st.table(table1.style.format(subset=['Titel']))
79
+ with col2:
80
+ key = 0
81
+ for entry in FILES:
82
+ st.button('Löschen', on_click = delete_entry(key), key = key, use_container_width = True)
83
+ key = key + 1
84
+
85
+ display_table()
86
+
87
+
88
+
pages/upload.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from pathlib import Path
3
+ from pages.table import generate_files
4
+
5
+ st.set_page_config(
6
+ page_title="Dokumentenupload",
7
+ layout="wide",
8
+ initial_sidebar_state="expanded",
9
+ )
10
+
11
+ st.markdown("# Dokumentenupload")
12
+ st.sidebar.markdown("# Dokumentenupload")
13
+
14
+ UPLOAD_FOLDER = 'C:/Users/keckm/Documents/GitHub/Streamlit/files' # Ordner für Dateiablage
15
+
16
+ def save_file(uploaded_file):
17
+ save_folder = UPLOAD_FOLDER
18
+ save_path = Path(save_folder, uploaded_file.name)
19
+ with open(save_path, mode = 'wb') as w:
20
+ w.write(uploaded_file.getvalue())
21
+ if save_path.exists():
22
+ st.success(f'Dokument {uploaded_file.name} wurde erfolgreich auf den Server hochgeladen.')
23
+
24
+ # file uploader
25
+ with st.form('upload_form'):
26
+ uploaded_file = st.file_uploader("Wählen Sie eine Datei aus.", type = [ ".pdf"])
27
+ submit = st.form_submit_button(label='Hochladen')
28
+
29
+ if uploaded_file:
30
+ filename = uploaded_file.name
31
+ save_file(uploaded_file)
32
+ generate_files()