Add phase 4: AI cleanup and photo/text import via OpenAI
- recipes/ai.py: Chat Completions with strict JSON schema (Structured Outputs), Pydantic re-validation, plausibility clamping, prompt treats input as data only - "Mit KI aufbereiten" on create/edit form returns an editable draft - Import page: photo/screenshot (vision, downscaled JPEG, not stored) and pasted text; drafts pre-fill the recipe form with a preview - Clear UI messages for timeout, rate limit, quota, auth, model and connection errors; without OPENAI_API_KEY AI features show a notice - Optional per-user and global daily AI limits (default unlimited) - Tests for response parsing, schema strictness, error mapping, views Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9256e94286
commit
1bf8ef8b65
@@ -3,17 +3,19 @@
|
||||
{% block content %}
|
||||
<h1>{% if is_new %}Neues Rezept{% else %}Rezept bearbeiten{% endif %}</h1>
|
||||
|
||||
{% block before_form %}{% endblock %}
|
||||
{% if draft_notice or ai_draft %}{% include "recipes/_draft_preview.html" %}{% endif %}
|
||||
|
||||
<form method="post" enctype="multipart/form-data" class="card recipe-form" novalidate>
|
||||
<form method="post"{% if form_action %} action="{{ form_action }}"{% endif %} enctype="multipart/form-data" class="card recipe-form" novalidate>
|
||||
{% csrf_token %}
|
||||
{% include "form_fields.html" %}
|
||||
{% block form_buttons %}
|
||||
<div class="form-buttons">
|
||||
<button type="submit" class="button">Speichern</button>
|
||||
{% if ai_enabled %}
|
||||
<button type="submit" name="ai" value="1" class="button secondary" data-busy-text="KI arbeitet …">✨ Mit KI aufbereiten</button>
|
||||
{% endif %}
|
||||
<a class="button secondary" href="{% if recipe %}{% url 'recipes:detail' recipe.pk %}{% else %}{% url 'recipes:list' %}{% endif %}">Abbrechen</a>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% if ai_enabled %}<p class="muted small">„Mit KI aufbereiten“ strukturiert deine Eingaben (Zutaten, Schritte, Tags) als Entwurf. Fotos danach auswählen – sie werden dabei nicht übernommen.</p>{% endif %}
|
||||
</form>
|
||||
|
||||
{% if recipe and images %}
|
||||
|
||||
Reference in New Issue
Block a user