fix: increase maxOutputTokens to 8192 in chatToRecipe; add 'Apri la ricetta' button after transfer
Fixes parse_error on complex recipes (JSON was truncated at 2048 tokens). After successful transfer, shows 'Apri la ricetta' button inline in chat alongside the '✅ Aggiunta alle Ricette!' button. Closes #27
This commit is contained in:
+2
-2
@@ -3645,10 +3645,10 @@ PROMPT;
|
|||||||
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'contents' => [['role' => 'user', 'parts' => [['text' => $prompt]]]],
|
'contents' => [['role' => 'user', 'parts' => [['text' => $prompt]]]],
|
||||||
'generationConfig' => ['temperature' => 0.1, 'maxOutputTokens' => 2048]
|
'generationConfig' => ['temperature' => 0.1, 'maxOutputTokens' => 8192]
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = callGeminiWithFallback($apiKey, $payload, 30);
|
$result = callGeminiWithFallback($apiKey, $payload, 45);
|
||||||
|
|
||||||
if ($result['http_code'] !== 200) {
|
if ($result['http_code'] !== 200) {
|
||||||
echo json_encode(['success' => false, 'error' => $result['data']['error']['message'] ?? 'gemini_error']);
|
echo json_encode(['success' => false, 'error' => $result['data']['error']['message'] ?? 'gemini_error']);
|
||||||
|
|||||||
+13
-4
@@ -12449,11 +12449,20 @@ async function chatTransferToRecipes(btn, replyText) {
|
|||||||
await saveRecipeToArchive(recipe);
|
await saveRecipeToArchive(recipe);
|
||||||
_cachedRecipe = { meal: recipe.meal || 'pranzo', recipe };
|
_cachedRecipe = { meal: recipe.meal || 'pranzo', recipe };
|
||||||
renderRecipe(recipe);
|
renderRecipe(recipe);
|
||||||
document.getElementById('recipe-overlay').style.display = 'flex';
|
|
||||||
document.getElementById('recipe-ask').style.display = 'none';
|
|
||||||
document.getElementById('recipe-loading').style.display = 'none';
|
|
||||||
document.getElementById('recipe-result').style.display = '';
|
|
||||||
btn.textContent = '✅ ' + (t('chat.transferred') || 'Aggiunta alle Ricette!');
|
btn.textContent = '✅ ' + (t('chat.transferred') || 'Aggiunta alle Ricette!');
|
||||||
|
btn.disabled = true;
|
||||||
|
// Add "Apri la ricetta" button next to the transfer button
|
||||||
|
const openBtn = document.createElement('button');
|
||||||
|
openBtn.className = 'btn-chat-use-recipe';
|
||||||
|
openBtn.style.marginLeft = '8px';
|
||||||
|
openBtn.textContent = '📖 ' + (t('chat.open_recipe') || 'Apri la ricetta');
|
||||||
|
openBtn.onclick = () => {
|
||||||
|
document.getElementById('recipe-overlay').style.display = 'flex';
|
||||||
|
document.getElementById('recipe-ask').style.display = 'none';
|
||||||
|
document.getElementById('recipe-loading').style.display = 'none';
|
||||||
|
document.getElementById('recipe-result').style.display = '';
|
||||||
|
};
|
||||||
|
btn.parentNode.insertBefore(openBtn, btn.nextSibling);
|
||||||
showToast('✅ ' + (t('chat.transferred') || 'Aggiunta alle Ricette!'), 'success');
|
showToast('✅ ' + (t('chat.transferred') || 'Aggiunta alle Ricette!'), 'success');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[chatTransferToRecipes]', err);
|
console.error('[chatTransferToRecipes]', err);
|
||||||
|
|||||||
+1
-1
@@ -1462,6 +1462,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="assets/js/app.js?v=20260510h"></script>
|
<script src="assets/js/app.js?v=20260510i"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -474,7 +474,8 @@
|
|||||||
"suggestion_expiry_text": "Was läuft bald ab und wie kann ich es verwenden?",
|
"suggestion_expiry_text": "Was läuft bald ab und wie kann ich es verwenden?",
|
||||||
"transfer_to_recipes": "Zu Rezepten hinzufügen",
|
"transfer_to_recipes": "Zu Rezepten hinzufügen",
|
||||||
"transferring": "Übertrage...",
|
"transferring": "Übertrage...",
|
||||||
"transferred": "Zu Rezepten hinzugefügt!"
|
"transferred": "Zu Rezepten hinzugefügt!",
|
||||||
|
"open_recipe": "Rezept öffnen"
|
||||||
},
|
},
|
||||||
"cooking": {
|
"cooking": {
|
||||||
"close": "Schließen",
|
"close": "Schließen",
|
||||||
|
|||||||
@@ -474,7 +474,8 @@
|
|||||||
"suggestion_expiry_text": "What's about to expire and how can I use it?",
|
"suggestion_expiry_text": "What's about to expire and how can I use it?",
|
||||||
"transfer_to_recipes": "Transfer to Recipes",
|
"transfer_to_recipes": "Transfer to Recipes",
|
||||||
"transferring": "Transferring...",
|
"transferring": "Transferring...",
|
||||||
"transferred": "Added to Recipes!"
|
"transferred": "Added to Recipes!",
|
||||||
|
"open_recipe": "Open recipe"
|
||||||
},
|
},
|
||||||
"cooking": {
|
"cooking": {
|
||||||
"close": "Close",
|
"close": "Close",
|
||||||
|
|||||||
@@ -474,7 +474,8 @@
|
|||||||
"suggestion_expiry_text": "Cosa sta per scadere e come posso usarlo?",
|
"suggestion_expiry_text": "Cosa sta per scadere e come posso usarlo?",
|
||||||
"transfer_to_recipes": "Trasferisci a Ricette",
|
"transfer_to_recipes": "Trasferisci a Ricette",
|
||||||
"transferring": "Trasferimento in corso...",
|
"transferring": "Trasferimento in corso...",
|
||||||
"transferred": "Aggiunta alle Ricette!"
|
"transferred": "Aggiunta alle Ricette!",
|
||||||
|
"open_recipe": "Apri la ricetta"
|
||||||
},
|
},
|
||||||
"cooking": {
|
"cooking": {
|
||||||
"close": "Chiudi",
|
"close": "Chiudi",
|
||||||
|
|||||||
Reference in New Issue
Block a user