MVP 0.95
This commit is contained in:
1 parent
4f37991ad1
commit
be11f82f84
39 files changed
+2490
-239
No files matched your search
@@ -9,6 +9,7 @@ from __future__ import annotations
|
||||
import re
|
||||
|
||||
from context_builder import assemble_text, build_internal_context
|
||||
from debug_store import persist_engine_error, persist_step
|
||||
from dialogue_store import StoreError, append_message, get_conversation, list_conversations_for_day, list_messages
|
||||
from dialogue_turn import OPERATIONS, needs_repair, parse_turn_payload, repair_note
|
||||
from engine import EngineError, execute_prompt, load_active_prompt
|
||||
@@ -162,12 +163,31 @@ def format_opening_hint(facts: dict) -> str:
|
||||
|
||||
def _store_opening(profile_id: str, conversation_id: str, impulse: str, extra: dict) -> dict:
|
||||
assistant = append_message(profile_id, conversation_id, impulse, role="assistant")
|
||||
return {
|
||||
payload = {
|
||||
"conversation": get_conversation(profile_id, conversation_id),
|
||||
"assistant": assistant,
|
||||
"messages": list_messages(profile_id, conversation_id),
|
||||
**extra,
|
||||
}
|
||||
persist_step(
|
||||
profile_id,
|
||||
purpose="dialogue_turn",
|
||||
status="ok",
|
||||
layer="dialogzug",
|
||||
subject_type="conversation",
|
||||
subject_id=conversation_id,
|
||||
conversation_id=conversation_id,
|
||||
message_id=assistant.get("id"),
|
||||
decision=extra.get("decision"),
|
||||
trace=extra.get("trace"),
|
||||
extra={
|
||||
"kind": extra.get("kind"),
|
||||
"calls": extra.get("calls"),
|
||||
"opened": extra.get("opened"),
|
||||
"assistant": {"id": assistant.get("id"), "body": assistant.get("body")},
|
||||
},
|
||||
)
|
||||
return payload
|
||||
|
||||
|
||||
def start_journal_opening(profile_id: str, conversation_id: str) -> dict:
|
||||
@@ -262,6 +282,15 @@ def start_journal_opening(profile_id: str, conversation_id: str) -> dict:
|
||||
}
|
||||
except EngineError as exc:
|
||||
if exc.code != "response_validation_failed" and exc.code not in DETECT_DIALOGUE_FALLBACK_CODES:
|
||||
persist_engine_error(
|
||||
profile_id,
|
||||
purpose="dialogue_turn",
|
||||
exc=exc,
|
||||
subject_type="conversation",
|
||||
subject_id=conversation_id,
|
||||
conversation_id=conversation_id,
|
||||
extra={"kind": "opening_failed", "calls": calls},
|
||||
)
|
||||
raise
|
||||
return _store_opening(
|
||||
profile_id,
|
||||
|
||||
Reference in new issue
Block a user