| import streamlit as st |
| from transformers import pipeline |
|
|
| |
| st.markdown(""" |
| <style> |
| .stSidebar { |
| background-color: #f2f2f2; |
| } |
| .stText { |
| color: #333333; |
| } |
| .stButton>button { |
| background-color: #4CAF50; |
| color: white; |
| } |
| .stTitle { |
| color: #ffbf00; |
| } |
| </style> |
| """, unsafe_allow_html=True) |
|
|
| |
| st.sidebar.title('⭐️EinfachChat⭐️') |
|
|
| |
| st.sidebar.markdown(''' |
| ## Über die App |
| Diese ist eine LLM-powered chatbot app und wurde erstellt mit : |
| - [Streamlit](https://streamlit.io/) |
| - [LangChain](https://python.langchain.com/) |
| - [Huggingface](https://huggingface.com/) |
| ''') |
|
|
| |
| st.sidebar.markdown('<img src="https://einfachalex.net/wp-content/uploads/2023/05/4-5.png" alt="Beschreibung des Bildes" width="200" style="float:left;">', unsafe_allow_html=True) |
|
|
| |
| st.sidebar.write('Made with ❤️💬 by [EinfachAlex](https://github.com/alfcodex)') |
|
|
| |
| classifier = pipeline('text-classification', model='bert-base-uncased', tokenizer='bert-base-uncased') |
|
|
| |
|
|
| |
| def classify_text(text): |
| result = classifier(text) |
| return result |
|
|
| |
|
|
| |
| if st.button("Verarbeiten"): |
| if file is not None: |
| if file.type.split('/')[1] == 'pdf': |
| pdf_text = extract_text_from_pdf(file) |
| st.write("Text aus PDF extrahiert:") |
| st.write(pdf_text) |
| elif file.type.split('/')[1] == 'plain': |
| text_content = file.read().decode('utf-8') |
| st.write("Textdokumentinhalt:") |
| st.write(text_content) |
| |
| classification_result = classify_text(text_content) |
| st.write("Klassifikationsergebnis:") |
| st.write(classification_result) |
| else: |
| st.warning("Keine Datei ausgewählt.") |
|
|