UI um debug Modus
This commit is contained in:
parent
fd47a954bd
commit
54e38d58c3
|
|
@ -194,7 +194,7 @@ def analyze_draft_text(text: str, n_type: str):
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
INGEST_ANALYZE_ENDPOINT,
|
INGEST_ANALYZE_ENDPOINT,
|
||||||
json={"text": text, "type": n_type},
|
json={"text": text, "type": n_type},
|
||||||
timeout=10
|
timeout=15 # Erhöhtes Timeout für Suche
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
@ -207,7 +207,7 @@ def save_draft_to_vault(markdown_content: str, filename: str = None):
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
INGEST_SAVE_ENDPOINT,
|
INGEST_SAVE_ENDPOINT,
|
||||||
json={"markdown_content": markdown_content, "filename": filename},
|
json={"markdown_content": markdown_content, "filename": filename},
|
||||||
timeout=30 # Indizierung kann dauern
|
timeout=60 # Indizierung kann dauern
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
@ -225,7 +225,7 @@ def submit_feedback(query_id, node_id, score, comment=None):
|
||||||
def render_sidebar():
|
def render_sidebar():
|
||||||
with st.sidebar:
|
with st.sidebar:
|
||||||
st.title("🧠 mindnet")
|
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)
|
mode = st.radio("Modus", ["💬 Chat", "📝 Manueller Editor"], index=0)
|
||||||
st.divider()
|
st.divider()
|
||||||
st.subheader("⚙️ Settings")
|
st.subheader("⚙️ Settings")
|
||||||
|
|
@ -299,16 +299,21 @@ def render_draft_editor(msg):
|
||||||
with tab_intel:
|
with tab_intel:
|
||||||
st.info("Klicke auf 'Analysieren', um Verknüpfungen zu finden.")
|
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..."):
|
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:
|
if "error" in analysis:
|
||||||
st.error(f"Fehler: {analysis['error']}")
|
st.error(f"Fehler: {analysis['error']}")
|
||||||
else:
|
else:
|
||||||
st.session_state[f"{key_base}_suggestions"] = analysis.get("suggestions", [])
|
suggestions = analysis.get("suggestions", [])
|
||||||
if not analysis.get("suggestions"):
|
st.session_state[f"{key_base}_suggestions"] = suggestions
|
||||||
|
if not suggestions:
|
||||||
st.warning("Keine offensichtlichen Verknüpfungen gefunden.")
|
st.warning("Keine offensichtlichen Verknüpfungen gefunden.")
|
||||||
|
|
||||||
|
# Anzeige der Vorschläge
|
||||||
suggestions = st.session_state.get(f"{key_base}_suggestions", [])
|
suggestions = st.session_state.get(f"{key_base}_suggestions", [])
|
||||||
if suggestions:
|
if suggestions:
|
||||||
st.markdown(f"**{len(suggestions)} Vorschläge gefunden:**")
|
st.markdown(f"**{len(suggestions)} Vorschläge gefunden:**")
|
||||||
|
|
@ -316,18 +321,17 @@ def render_draft_editor(msg):
|
||||||
with st.container():
|
with st.container():
|
||||||
st.markdown(f"""
|
st.markdown(f"""
|
||||||
<div class="suggestion-card">
|
<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>
|
<i>Grund: {sugg.get('reason', 'N/A')}</i><br>
|
||||||
<code>{sugg['suggested_markdown']}</code>
|
<code>{sugg.get('suggested_markdown', '')}</code>
|
||||||
</div>
|
</div>
|
||||||
""", unsafe_allow_html=True)
|
""", unsafe_allow_html=True)
|
||||||
|
|
||||||
if st.button("➕ Einfügen", key=f"{key_base}_add_{idx}"):
|
if st.button("➕ Einfügen", key=f"{key_base}_add_{idx}"):
|
||||||
# Append to body
|
|
||||||
current_body = st.session_state[f"{key_base}_body"]
|
current_body = st.session_state[f"{key_base}_body"]
|
||||||
updated_body = f"{current_body}\n\n{sugg['suggested_markdown']}"
|
updated_body = f"{current_body}\n\n{sugg['suggested_markdown']}"
|
||||||
st.session_state[f"{key_base}_body"] = updated_body
|
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()
|
st.rerun()
|
||||||
|
|
||||||
# --- TAB 3: PREVIEW ---
|
# --- TAB 3: PREVIEW ---
|
||||||
|
|
@ -342,14 +346,18 @@ def render_draft_editor(msg):
|
||||||
# Actions (SAVE & EXPORT)
|
# Actions (SAVE & EXPORT)
|
||||||
b1, b2 = st.columns([1, 1])
|
b1, b2 = st.columns([1, 1])
|
||||||
with b1:
|
with b1:
|
||||||
# Echter Save Button
|
# Echter Save Button (Ruft API auf)
|
||||||
if st.button("💾 Speichern & Indizieren", type="primary", key=f"{key_base}_save"):
|
if st.button("💾 Speichern & Indizieren", type="primary", key=f"{key_base}_save"):
|
||||||
with st.spinner("Speichere im Vault..."):
|
with st.spinner("Speichere im Vault..."):
|
||||||
# Generiere Filename
|
# Generiere Filename
|
||||||
safe_title = re.sub(r'[^a-zA-Z0-9]', '-', new_title).lower()[:30]
|
safe_title = re.sub(r'[^a-zA-Z0-9]', '-', new_title).lower()[:30]
|
||||||
fname = f"{datetime.now().strftime('%Y%m%d')}-{safe_title}.md"
|
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:
|
if "error" in result:
|
||||||
st.error(f"Fehler beim Speichern: {result['error']}")
|
st.error(f"Fehler beim Speichern: {result['error']}")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user