fix ki modell

This commit is contained in:
nadja
2026-08-26 21:09:14 +02:00
parent ade2a46a4a
commit fdb03daeb3

View File

@@ -7,6 +7,21 @@ import StepList from '../components/StepList';
const CATEGORIES = ['Frühstück', 'Hauptgericht', 'Dessert', 'Snack', 'Getränk', 'Sonstiges']; const CATEGORIES = ['Frühstück', 'Hauptgericht', 'Dessert', 'Snack', 'Getränk', 'Sonstiges'];
function parseIngredient(raw) {
if (typeof raw !== 'string') return raw;
const m = raw.match(/^([\d½¼¾⅓⅔.,\-]+\s*(?:g|kg|ml|l|EL|TL|Stück|Packung|Prise|Bund|Dose|Scheibe|cm|dick)?)\s*(.*)/i);
if (m) {
const amount = m[1].trim();
const rest = m[2].trim();
const unitMatch = rest.match(/^((?:g|kg|ml|l|EL|TL|Stück|Packung|Prise|Bund|Dose|Scheibe|dick)s?)\s+(.*)/i);
if (unitMatch) {
return { amount, unit: unitMatch[1], name: unitMatch[2] };
}
return { amount, unit: '', name: rest };
}
return { amount: '', unit: '', name: raw };
}
function detectSource(url) { function detectSource(url) {
if (/tiktok\.com\//.test(url)) return 'tiktok'; if (/tiktok\.com\//.test(url)) return 'tiktok';
return null; return null;
@@ -55,7 +70,7 @@ export default function AddRecipe() {
setName(data.extracted.name || ''); setName(data.extracted.name || '');
setDescription(data.extracted.description || ''); setDescription(data.extracted.description || '');
setCategory(data.extracted.category || 'Sonstiges'); setCategory(data.extracted.category || 'Sonstiges');
setIngredients(data.extracted.ingredients || []); setIngredients((data.extracted.ingredients || []).map(parseIngredient));
setSteps(data.extracted.steps || []); setSteps(data.extracted.steps || []);
} else { } else {
setName(data.tiktok?.title || ''); setName(data.tiktok?.title || '');
@@ -157,8 +172,8 @@ export default function AddRecipe() {
<path fillRule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clipRule="evenodd" /> <path fillRule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clipRule="evenodd" />
</svg> </svg>
<span> <span>
KI (Ollama) nicht erreichbar.{' '} KI nicht erreichbar.{' '}
<span className="text-gray-400">Starte Ollama oder füll die Felder manuell aus.</span> <span className="text-gray-400">Prüfe den API-Key oder füll die Felder manuell aus.</span>
</span> </span>
</> </>
)} )}