Backup #682
| ID | 682 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/View/partials/form/model-select.php |
| Version | 1 |
| Typ |
modified |
| Größe | 2.9 KB |
| Hash | daa1f591b580fe6fc5ba0105badb348da92e3bdc97b86766e39e62b78abd2625 |
| Datum | 2025-12-23 07:44:39 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
/**
* Model Select Partial
*
* Einheitliches Dropdown für KI-Modell-Auswahl.
* Verwendet in: Chat, Content Studio, Pipeline
*
* @param array $models Array von Modell-IDs => Labels (default: ModelConfig::getAll())
* @param string $selected Ausgewähltes Modell (default: ModelConfig::DEFAULT_MODEL)
* @param string $name Form-Feldname (default: 'model')
* @param string $variant 'default', 'inline' oder 'compact'
* @param string $id Optional: HTML ID für das Select
* @param bool $saveToLocalStorage Speichert Änderungen in localStorage (default: true)
* @param string $localStorageKey Key für localStorage (default: 'pipeline_model')
*/
use Infrastructure\AI\ModelConfig;
$models ??= ModelConfig::getAll();
$selected ??= ModelConfig::DEFAULT_MODEL;
$name ??= 'model';
$variant ??= 'default';
$id ??= 'model-' . uniqid();
$saveToLocalStorage ??= true;
$localStorageKey ??= 'pipeline_model';
$class = match ($variant) {
'inline' => 'form-select form-select--inline model-select',
'compact' => 'form-select form-select--compact model-select',
default => 'form-select model-select',
};
// Gruppiere Modelle nach Provider
$anthropicModels = [];
$ollamaModels = [];
foreach ($models as $modelId => $label) {
if (str_starts_with($modelId, 'ollama:')) {
$ollamaModels[$modelId] = $label;
} else {
$anthropicModels[$modelId] = $label;
}
}
?>
<select name="<?= htmlspecialchars($name) ?>"
id="<?= htmlspecialchars($id) ?>"
class="<?= $class ?>"
<?= $saveToLocalStorage ? 'data-save-to="' . htmlspecialchars($localStorageKey) . '"' : '' ?>>
<?php if (!empty($ollamaModels)): ?>
<optgroup label="Ollama (lokal)">
<?php foreach ($ollamaModels as $modelId => $label): ?>
<option value="<?= htmlspecialchars($modelId) ?>" <?= $selected === $modelId ? 'selected' : '' ?>>
<?= htmlspecialchars($label) ?>
</option>
<?php endforeach; ?>
</optgroup>
<?php endif; ?>
<?php if (!empty($anthropicModels)): ?>
<optgroup label="Anthropic">
<?php foreach ($anthropicModels as $modelId => $label): ?>
<option value="<?= htmlspecialchars($modelId) ?>" <?= $selected === $modelId ? 'selected' : '' ?>>
<?= htmlspecialchars($label) ?>
</option>
<?php endforeach; ?>
</optgroup>
<?php endif; ?>
</select>
<?php if ($saveToLocalStorage): ?>
<script>
(function() {
const select = document.getElementById('<?= $id ?>');
const key = '<?= $localStorageKey ?>';
// Restore from localStorage
const saved = localStorage.getItem(key);
if (saved && select) {
const option = select.querySelector('option[value="' + saved + '"]');
if (option) select.value = saved;
}
// Save on change
select?.addEventListener('change', function() {
localStorage.setItem(key, this.value);
});
})();
</script>
<?php endif; ?>
Vollständig herunterladen
Aktionen
← Zurück zur Übersicht