Files
Kochbuch/templates/recipes/import.html
T
Kyle DammannandClaude Opus 5.5 1bf8ef8b65 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]>
2026-10-30 21:43:30 +01:00

38 lines
1.4 KiB
HTML

{% extends "base.html" %}
{% block title %}Rezept importieren{% endblock %}
{% block content %}
<h1>Rezept importieren</h1>
<p class="muted">Das Ergebnis ist immer ein Entwurf, den du prüfst und erst dann speicherst.</p>
{% block link_import %}{% endblock %}
<section class="card">
<h2>📷 Foto oder Screenshot</h2>
{% if ai_enabled %}
<form method="post" action="{% url 'recipes:import_photo' %}" enctype="multipart/form-data" novalidate>
{% csrf_token %}
{% with form=photo_form %}{% include "form_fields.html" %}{% endwith %}
<p class="muted small">Die Bilder werden zur Auswertung an OpenAI geschickt und nicht gespeichert.</p>
<button type="submit" class="button" data-busy-text="KI liest das Rezept …">Rezept erkennen</button>
</form>
{% else %}
{% include "recipes/_ai_disabled.html" %}
{% endif %}
</section>
<section class="card">
<h2>📝 Text einfügen</h2>
{% if ai_enabled %}
<form method="post" action="{% url 'recipes:import_text' %}" novalidate>
{% csrf_token %}
{% with form=text_form %}{% include "form_fields.html" %}{% endwith %}
<button type="submit" class="button" data-busy-text="KI bereitet auf …">Mit KI aufbereiten</button>
</form>
{% else %}
{% include "recipes/_ai_disabled.html" %}
{% endif %}
</section>
<p><a href="{% url 'recipes:create' %}">Oder ganz von Hand eintragen →</a></p>
{% endblock %}