mindnet/app/frontend/ui.py

50 lines
2.0 KiB
Python
Raw Normal View History

2025-12-09 18:44:26 +01:00
import streamlit as st
import uuid
2025-12-14 12:50:54 +01:00
# --- CONFIG & STYLING ---
2025-12-14 07:34:51 +01:00
st.set_page_config(page_title="mindnet v2.6", page_icon="🧠", layout="wide")
2025-12-09 18:44:26 +01:00
st.markdown("""
<style>
2025-12-14 07:34:51 +01:00
.block-container { padding-top: 2rem; max_width: 1200px; margin: auto; }
2025-12-14 12:50:54 +01:00
.intent-badge { background-color: #e8f0fe; color: #1a73e8; padding: 4px 10px; border-radius: 12px; font-size: 0.8rem; font-weight: 600; border: 1px solid #d2e3fc; display: inline-block; margin-bottom: 0.5rem; }
.draft-box { border: 1px solid #d0d7de; border-radius: 6px; padding: 16px; background-color: #f6f8fa; margin: 10px 0; }
.preview-box { border: 1px solid #e0e0e0; border-radius: 6px; padding: 24px; background-color: white; }
2025-12-09 18:44:26 +01:00
</style>
""", unsafe_allow_html=True)
2025-12-14 12:50:54 +01:00
# --- MODULE IMPORTS ---
try:
from ui_config import QDRANT_URL, QDRANT_KEY, COLLECTION_PREFIX
from ui_graph_service import GraphExplorerService
2025-12-14 14:57:34 +01:00
# Komponenten
2025-12-14 12:50:54 +01:00
from ui_sidebar import render_sidebar
from ui_chat import render_chat_interface
from ui_editor import render_manual_editor
2025-12-14 14:57:34 +01:00
# Die beiden Graph-Engines
from ui_graph import render_graph_explorer as render_graph_agraph
from ui_graph_cytoscape import render_graph_explorer_cytoscape # <-- Import
2025-12-14 12:50:54 +01:00
except ImportError as e:
2025-12-14 14:57:34 +01:00
st.error(f"Import Error: {e}. Bitte stelle sicher, dass alle UI-Dateien im Ordner liegen und 'streamlit-cytoscapejs' installiert ist.")
2025-12-14 12:50:54 +01:00
st.stop()
2025-12-09 22:27:56 +01:00
# --- SESSION STATE ---
2025-12-09 23:05:28 +01:00
if "messages" not in st.session_state: st.session_state.messages = []
if "user_id" not in st.session_state: st.session_state.user_id = str(uuid.uuid4())
2025-12-14 08:34:23 +01:00
# --- SERVICE INIT ---
2025-12-14 07:34:51 +01:00
graph_service = GraphExplorerService(QDRANT_URL, QDRANT_KEY, COLLECTION_PREFIX)
2025-12-14 08:34:23 +01:00
# --- MAIN ROUTING ---
2025-12-09 23:05:28 +01:00
mode, top_k, explain = render_sidebar()
2025-12-14 07:34:51 +01:00
2025-12-09 23:05:28 +01:00
if mode == "💬 Chat":
render_chat_interface(top_k, explain)
2025-12-14 07:34:51 +01:00
elif mode == "📝 Manueller Editor":
render_manual_editor()
2025-12-14 14:57:34 +01:00
elif mode == "🕸️ Graph (Agraph)":
render_graph_agraph(graph_service)
elif mode == "🕸️ Graph (Cytoscape)":
render_graph_explorer_cytoscape(graph_service)