Enhance Planning Catalog Context and Prompt Slot Management
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 2s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m20s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 2s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m20s
- Introduced new catalog context handling in planning prompt functions, allowing for improved integration of planning variables. - Added optional catalog context parameters in various functions to streamline the merging of planning prompt variables. - Updated frontend components to include CatalogPromptSlotsEditor for managing prompt slots across different catalog types. - Enhanced API utilities to support fetching and updating catalog prompt slots, improving backend functionality for catalog management. - Incremented version numbers and updated changelog to reflect the new features and improvements.
This commit is contained in:
1 parent
9cee862c32
commit
53f2b027cc
20 files changed
+1922
-204
No files matched your search
@@ -0,0 +1,155 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { api } from '../../utils/api'
|
||||
|
||||
const KIND_LABELS = {
|
||||
focus_area: 'Fokusbereich',
|
||||
training_type: 'Trainingsstil',
|
||||
target_group: 'Zielgruppe',
|
||||
style_direction: 'Stilrichtung',
|
||||
}
|
||||
|
||||
/**
|
||||
* Pflege der Katalog-Prompt-Slots (Planungs-KI) an einem Stammdaten-Eintrag.
|
||||
*/
|
||||
export default function CatalogPromptSlotsEditor({ catalogKind, catalogId, entryName = '' }) {
|
||||
const [slotTypes, setSlotTypes] = useState([])
|
||||
const [slots, setSlots] = useState({})
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
const [loaded, setLoaded] = useState(false)
|
||||
|
||||
const applicableTypes = useMemo(() => {
|
||||
const kind = (catalogKind || '').trim()
|
||||
return (slotTypes || []).filter((t) => {
|
||||
const kinds = t.applicable_kinds || []
|
||||
return kinds.length === 0 || kinds.includes(kind)
|
||||
})
|
||||
}, [slotTypes, catalogKind])
|
||||
|
||||
const load = useCallback(async () => {
|
||||
if (!catalogId || !catalogKind) return
|
||||
setLoading(true)
|
||||
setError('')
|
||||
try {
|
||||
const [typesRes, slotsRes] = await Promise.all([
|
||||
api.listCatalogPromptSlotTypes(),
|
||||
api.getCatalogPromptSlots(catalogKind, catalogId),
|
||||
])
|
||||
setSlotTypes(Array.isArray(typesRes?.slot_types) ? typesRes.slot_types : [])
|
||||
setSlots(slotsRes?.slots && typeof slotsRes.slots === 'object' ? { ...slotsRes.slots } : {})
|
||||
setLoaded(true)
|
||||
} catch (e) {
|
||||
setError(e.message || String(e))
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [catalogKind, catalogId])
|
||||
|
||||
useEffect(() => {
|
||||
setLoaded(false)
|
||||
setSlots({})
|
||||
if (catalogId && catalogKind) {
|
||||
load()
|
||||
}
|
||||
}, [catalogId, catalogKind, load])
|
||||
|
||||
async function handleSave() {
|
||||
if (!catalogId || !catalogKind) return
|
||||
setSaving(true)
|
||||
setError('')
|
||||
try {
|
||||
const res = await api.updateCatalogPromptSlots(catalogKind, catalogId, { slots })
|
||||
setSlots(res?.slots && typeof res.slots === 'object' ? { ...res.slots } : {})
|
||||
} catch (e) {
|
||||
setError(e.message || String(e))
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (!catalogId || !catalogKind) {
|
||||
return null
|
||||
}
|
||||
|
||||
const kindLabel = KIND_LABELS[catalogKind] || catalogKind
|
||||
|
||||
return (
|
||||
<div
|
||||
className="catalog-prompt-slots"
|
||||
style={{
|
||||
marginTop: '20px',
|
||||
paddingTop: '16px',
|
||||
borderTop: '1px solid var(--border)',
|
||||
}}
|
||||
>
|
||||
<h4 style={{ margin: '0 0 8px' }}>Planungs-KI — Prompt-Texte</h4>
|
||||
<p style={{ margin: '0 0 12px', fontSize: '13px', color: 'var(--text2)' }}>
|
||||
Texte für KI-Prompts (Progressionsgraph, Pfad-QS). Platzhalter:{' '}
|
||||
<code>{'{{' + catalogKind + '_<slot_key>}}'}</code>
|
||||
{entryName ? (
|
||||
<>
|
||||
{' '}
|
||||
— Eintrag: <strong>{entryName}</strong>
|
||||
</>
|
||||
) : null}
|
||||
</p>
|
||||
|
||||
{error ? (
|
||||
<div className="admin-matrix-alert" style={{ marginBottom: '12px' }}>
|
||||
{error}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{loading && !loaded ? (
|
||||
<div className="spinner" style={{ minHeight: '48px' }} />
|
||||
) : (
|
||||
<>
|
||||
{applicableTypes.map((st) => {
|
||||
const key = st.slot_key
|
||||
const ph = `{{${catalogKind}_${key}}}`
|
||||
const isCodeOnly = st.for_code && !st.for_llm
|
||||
return (
|
||||
<div key={key} className="form-row">
|
||||
<label className="form-label">
|
||||
{st.display_name || key}
|
||||
{isCodeOnly ? (
|
||||
<span style={{ marginLeft: '6px', fontSize: '12px', color: 'var(--text3)' }}>
|
||||
(primär Code)
|
||||
</span>
|
||||
) : null}
|
||||
</label>
|
||||
{st.description ? (
|
||||
<p style={{ margin: '0 0 6px', fontSize: '12px', color: 'var(--text3)' }}>{st.description}</p>
|
||||
) : null}
|
||||
<textarea
|
||||
className="form-input"
|
||||
rows={key === 'description' ? 3 : 4}
|
||||
value={slots[key] || ''}
|
||||
onChange={(e) => setSlots((prev) => ({ ...prev, [key]: e.target.value }))}
|
||||
placeholder={
|
||||
key === 'description'
|
||||
? 'Leer = Stammdaten-Beschreibung als Fallback'
|
||||
: `Text für ${ph} …`
|
||||
}
|
||||
/>
|
||||
<p style={{ margin: '4px 0 0', fontSize: '11px', color: 'var(--text3)', fontFamily: 'monospace' }}>
|
||||
{ph}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
|
||||
<div style={{ display: 'flex', gap: '8px', flexWrap: 'wrap', marginTop: '8px' }}>
|
||||
<button type="button" className="btn btn-primary" onClick={handleSave} disabled={saving || loading}>
|
||||
{saving ? 'Speichert…' : 'KI-Texte speichern'}
|
||||
</button>
|
||||
<button type="button" className="btn btn-secondary" onClick={load} disabled={loading || saving}>
|
||||
Neu laden
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { useState } from 'react'
|
||||
import { api } from '../../utils/api'
|
||||
import CatalogPromptSlotsEditor from './CatalogPromptSlotsEditor'
|
||||
|
||||
function DetailPanel({ item, onUpdate, focusAreas }) {
|
||||
const type = item._type
|
||||
@@ -87,6 +88,7 @@ function FocusAreaDetail({ item, onUpdate }) {
|
||||
</button>
|
||||
<button type="button" className="btn btn-danger" onClick={handleDelete}>Löschen</button>
|
||||
</div>
|
||||
<CatalogPromptSlotsEditor catalogKind="focus_area" catalogId={item.id} entryName={form.name} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -169,6 +171,7 @@ function StyleDirectionDetail({ item, onUpdate, focusAreas }) {
|
||||
</button>
|
||||
<button type="button" className="btn btn-danger" onClick={handleDelete}>Löschen</button>
|
||||
</div>
|
||||
<CatalogPromptSlotsEditor catalogKind="style_direction" catalogId={item.id} entryName={form.name} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -251,6 +254,7 @@ function TrainingTypeDetail({ item, onUpdate, focusAreas }) {
|
||||
</button>
|
||||
<button type="button" className="btn btn-danger" onClick={handleDelete}>Löschen</button>
|
||||
</div>
|
||||
<CatalogPromptSlotsEditor catalogKind="training_type" catalogId={item.id} entryName={form.name} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user