WP11 #8

Merged
Lars merged 30 commits from WP11 into main 2025-12-11 17:00:38 +01:00
Showing only changes of commit 54e38d58c3 - Show all commits

View File

@ -194,7 +194,7 @@ def analyze_draft_text(text: str, n_type: str):
response = requests.post(
INGEST_ANALYZE_ENDPOINT,
json={"text": text, "type": n_type},
timeout=10
timeout=15 # Erhöhtes Timeout für Suche
)
response.raise_for_status()
return response.json()
@ -207,7 +207,7 @@ def save_draft_to_vault(markdown_content: str, filename: str = None):
response = requests.post(
INGEST_SAVE_ENDPOINT,
json={"markdown_content": markdown_content, "filename": filename},
timeout=30 # Indizierung kann dauern
timeout=60 # Indizierung kann dauern
)
response.raise_for_status()
return response.json()
@ -225,7 +225,7 @@ def submit_feedback(query_id, node_id, score, comment=None):
def render_sidebar():
with st.sidebar:
st.title("🧠 mindnet")
st.caption("v2.3.2 | WP-10 UI")
st.caption("v2.3.3 | WP-10b (Intelligence)")
mode = st.radio("Modus", ["💬 Chat", "📝 Manueller Editor"], index=0)
st.divider()
st.subheader("⚙️ Settings")
@ -299,16 +299,21 @@ def render_draft_editor(msg):
with tab_intel:
st.info("Klicke auf 'Analysieren', um Verknüpfungen zu finden.")
if st.button("🔍 Draft Analysieren", key=f"{key_base}_analyze"):
if st.button("🔍 Analyse starten", key=f"{key_base}_analyze"):
with st.spinner("Analysiere Text und suche Verknüpfungen..."):
analysis = analyze_draft_text(new_body, new_type)
current_text = st.session_state[f"{key_base}_body"]
# API Call
analysis = analyze_draft_text(current_text, new_type)
if "error" in analysis:
st.error(f"Fehler: {analysis['error']}")
else:
st.session_state[f"{key_base}_suggestions"] = analysis.get("suggestions", [])
if not analysis.get("suggestions"):
suggestions = analysis.get("suggestions", [])
st.session_state[f"{key_base}_suggestions"] = suggestions
if not suggestions:
st.warning("Keine offensichtlichen Verknüpfungen gefunden.")
# Anzeige der Vorschläge
suggestions = st.session_state.get(f"{key_base}_suggestions", [])
if suggestions:
st.markdown(f"**{len(suggestions)} Vorschläge gefunden:**")
@ -316,18 +321,17 @@ def render_draft_editor(msg):
with st.container():
st.markdown(f"""
<div class="suggestion-card">
<b>{sugg['target_title']}</b> <small>({sugg['type']})</small><br>
<b>{sugg.get('target_title', 'Unbekannt')}</b> <small>({sugg.get('type', 'semantic')})</small><br>
<i>Grund: {sugg.get('reason', 'N/A')}</i><br>
<code>{sugg['suggested_markdown']}</code>
<code>{sugg.get('suggested_markdown', '')}</code>
</div>
""", unsafe_allow_html=True)
if st.button(" Einfügen", key=f"{key_base}_add_{idx}"):
# Append to body
current_body = st.session_state[f"{key_base}_body"]
updated_body = f"{current_body}\n\n{sugg['suggested_markdown']}"
st.session_state[f"{key_base}_body"] = updated_body
st.toast(f"Link zu '{sugg['target_title']}' eingefügt!")
st.toast(f"Link zu '{sugg.get('target_title', '?')}' eingefügt!")
st.rerun()
# --- TAB 3: PREVIEW ---
@ -342,14 +346,18 @@ def render_draft_editor(msg):
# Actions (SAVE & EXPORT)
b1, b2 = st.columns([1, 1])
with b1:
# Echter Save Button
# Echter Save Button (Ruft API auf)
if st.button("💾 Speichern & Indizieren", type="primary", key=f"{key_base}_save"):
with st.spinner("Speichere im Vault..."):
# Generiere Filename
safe_title = re.sub(r'[^a-zA-Z0-9]', '-', new_title).lower()[:30]
fname = f"{datetime.now().strftime('%Y%m%d')}-{safe_title}.md"
result = save_draft_to_vault(final_doc, filename=fname)
# Wir holen den aktuellsten Stand aus dem State (inklusive eingefügter Links)
latest_body = st.session_state.get(f"{key_base}_body", "")
latest_doc = build_markdown_doc(final_meta, latest_body)
result = save_draft_to_vault(latest_doc, filename=fname)
if "error" in result:
st.error(f"Fehler beim Speichern: {result['error']}")