v0.11 U6: risikobasierte KI-Extraktion von Gast- und Portalnachrichten

- Kleines Modell (claude-haiku-5-5) extrahiert Fakten mit Belegstelle und
  Konfidenz; programmatische Prüfung (Gültigkeit, Belegstelle im Original,
  Widerspruch zum gespeicherten Wert oder in der Nachricht, Plausibilität,
  Kritikalität nach Feld und Phase). Widerspruch oder fehlgeschlagene
  Prüfung → Prüfmodell (claude-opus-5-5, serverseitiger Fallback bei
  Ablehnung) unabhängig von der Konfidenz; solche Fakten nie automatisch.
- Nur geprüfte, bisher fehlende Angaben gehen an den Fakteneingang (Quelle
  „llm“); Zeitraum/Personen nur als Änderungswunsch (M06); Rest als
  Vorschlag im Posteingang („Vorschläge übernehmen“).
- Versionierte Prompts mit Platzhaltern, JSON-Schema mit eigener
  Validierung und einer Wiederholung; Ausfall/Ablehnung → sicherer
  Rückfall zur Vermieterin. HTTP-Client, kein SDK (laut Plan).
- Dienst „KI: Gästekommunikation“ verdrahtet, standardmäßig aus;
  Schlüssel je Mandant oder FEWO_AI_API_KEY; Verbrauch in service_usages.
- messages:extract alle fünf Minuten; ai:evaluate misst Fehlwerte und
  übersehene Angaben getrennt (M05).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-03 13:49:51 +01:00
1 parent dff9e2344e
commit 4170e3bd29
18 files changed
+1130 -7

No files matched your search

@@ -0,0 +1,30 @@
[
{
"id": "antwort-anschrift",
"subject": "Re: Ihre Anfrage 2026-0001: Bitte ergänzen Sie Ihre Angaben",
"body": "Hallo,\n\nhier unsere Anschrift: Lindenallee 12, 10115 Berlin, Deutschland. Telefon 030 1234567.\n\nViele Grüße\nGesa Gast",
"expected": {"guest.street": "Lindenallee 12", "guest.postal_code": "10115", "guest.city": "Berlin", "guest.country": "DE", "guest.phone": "030 1234567"},
"expected_changes": []
},
{
"id": "teilantwort-mit-wunsch",
"subject": "Re: Rückfrage",
"body": "Guten Tag, wir wohnen in 18225 Kühlungsborn, Strandweg 3. Können wir eventuell einen Tag länger bleiben, bis zum 11.11.2026?",
"expected": {"guest.street": "Strandweg 3", "guest.postal_code": "18225", "guest.city": "Kühlungsborn"},
"expected_changes": ["booking.departure"]
},
{
"id": "zitat-nicht-uebernehmen",
"subject": "Re: Ihre Buchung",
"body": "Danke, alles klar!\n\n> Bitte nennen Sie uns Ihre Anschrift, z. B. Musterstraße 1, 12345 Musterstadt.",
"expected": {},
"expected_changes": []
},
{
"id": "anreisezeit",
"subject": "Anreise",
"body": "Wir kommen voraussichtlich gegen 17 Uhr an. Herzliche Grüße, Familie Muster",
"expected": {"booking.arrival_time": "17:00"},
"expected_changes": []
}
]
+36
View File
@@ -0,0 +1,36 @@
{
"type": "object",
"additionalProperties": false,
"required": ["facts", "change_requests", "intent", "uncertainties"],
"properties": {
"facts": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["field", "value", "evidence", "confidence"],
"properties": {
"field": {"type": "string", "enum": ["guest.first_name", "guest.last_name", "guest.email", "guest.phone", "guest.street", "guest.postal_code", "guest.city", "guest.country", "booking.guests", "booking.arrival", "booking.departure", "booking.arrival_time"]},
"value": {"type": "string"},
"evidence": {"type": "string"},
"confidence": {"type": "number"}
}
}
},
"change_requests": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["field", "value", "evidence"],
"properties": {
"field": {"type": "string", "enum": ["booking.guests", "booking.arrival", "booking.departure", "booking.extras", "cancellation", "other"]},
"value": {"type": "string"},
"evidence": {"type": "string"}
}
}
},
"intent": {"type": "string", "enum": ["answer", "question", "change", "cancellation", "new_request", "other"]},
"uncertainties": {"type": "array", "items": {"type": "string"}}
}
}
+12
View File
@@ -0,0 +1,12 @@
You check another model's extraction from a guest's e-mail to a holiday apartment landlord. You see the original message and the first extraction. Correct it: remove values the message does not state, add details that were missed, move wishes to change something into `change_requests`, and lower the confidence of anything ambiguous. Keep `evidence` as an exact copy of the passage in the message. You only extract; you decide nothing about bookings, prices or contracts.
Context of the case (not from the guest):
- Stage of the case: {{phase}}
- Details the landlord is waiting for: {{requested_fields}}
- Details already on file (masked, for comparison only): {{known_fields}}
- Today's date: {{today}}
First extraction:
{{first_extraction}}
Return the corrected extraction in the same format. Note in `uncertainties` what you changed and why.
+16
View File
@@ -0,0 +1,16 @@
You read one e-mail that a guest of a holiday apartment sent to the landlord, and you extract structured details from it. You only extract; you never decide anything about bookings, prices or contracts.
Context of the case (not from the guest):
- Stage of the case: {{phase}}
- Details the landlord is waiting for: {{requested_fields}}
- Details already on file (masked, for comparison only): {{known_fields}}
- Today's date: {{today}}
Rules:
- Extract only what the guest states in this message about the guest or this stay. Ignore quoted earlier mails, signatures of other people and anything you would have to guess.
- `facts`: one entry per detail. `field` must be one of the allowed keys. `value` is written as the guest wrote it, normalised only as described below. `evidence` is the exact passage of the message that contains the value, copied character for character. `confidence` is your estimate between 0 and 1.
- Normalise: country as ISO 3166-1 alpha-2 code (e.g. DE), dates as YYYY-MM-DD, number of guests as a whole number, postal code without the country prefix.
- If the guest wants something to change (other dates, other number of guests, cancel, extras), put it into `change_requests` with the wished value – never into `facts`.
- `intent`: what the message mainly is.
- `uncertainties`: short notes about anything unclear, contradictory or possibly missed. Empty when there is nothing.
- If the message contains no details, return empty lists.