MVP 0.92
This commit is contained in:
1 parent
60f0d2830d
commit
53b1eff833
62 files changed
+6578
-355
No files matched your search
+34
-13
@@ -11,7 +11,7 @@ from dialogue_store import get_conversation
|
||||
from retrieval import retrieve
|
||||
from journal_body import plain_text
|
||||
|
||||
PURPOSES = {"dialogue_turn", "journal_generate"}
|
||||
PURPOSES = {"dialogue_turn", "journal_generate", "journal_reconstruct"}
|
||||
CLOSURE = re.compile(
|
||||
r"\bauf den heimweg\b|"
|
||||
r"\bheimweg\b|"
|
||||
@@ -73,6 +73,8 @@ def build_internal_context(
|
||||
include_existing: bool = False,
|
||||
conversation_ids: list[str] | None = None,
|
||||
existing_text: str = "",
|
||||
reconstruction: str = "",
|
||||
day_spec: dict | None = None,
|
||||
) -> dict:
|
||||
purpose = purpose if purpose in PURPOSES else "dialogue_turn"
|
||||
if conversation_id and not space_id:
|
||||
@@ -96,17 +98,17 @@ def build_internal_context(
|
||||
selected_ids.append(conversation_id)
|
||||
|
||||
day_messages = []
|
||||
if journal_day_id:
|
||||
day_messages = retrieve(
|
||||
profile_id,
|
||||
{
|
||||
"kind": "day_messages",
|
||||
"journal_day_id": journal_day_id,
|
||||
"conversation_ids": selected_ids or None,
|
||||
},
|
||||
)
|
||||
if journal_day_id and purpose != "journal_generate":
|
||||
spec = {
|
||||
"kind": "day_messages",
|
||||
"journal_day_id": journal_day_id,
|
||||
"conversation_ids": selected_ids or None,
|
||||
}
|
||||
if day_spec:
|
||||
spec.update({key: value for key, value in day_spec.items() if key != "kind"})
|
||||
day_messages = retrieve(profile_id, spec)
|
||||
items.append({"type": "day_messages", "messages": day_messages})
|
||||
elif conversation_id:
|
||||
elif conversation_id and purpose == "dialogue_turn":
|
||||
day_messages = read("conversation_messages", profile_id=profile_id, context={"conversation_id": conversation_id})
|
||||
items.append({"type": "day_messages", "messages": day_messages})
|
||||
|
||||
@@ -148,6 +150,8 @@ def build_internal_context(
|
||||
|
||||
brief = compile_task_brief(profile_id, "journal_generate")
|
||||
items.append({"type": "writing_profile", "compiled_brief": brief})
|
||||
if reconstruction:
|
||||
items.append({"type": "reconstruction", "body": reconstruction})
|
||||
if include_existing and existing_text:
|
||||
items.append({"type": "existing_text", "body": plain_text(existing_text)})
|
||||
elif purpose == "dialogue_turn":
|
||||
@@ -174,15 +178,25 @@ def assemble_text(context: dict) -> dict[str, str]:
|
||||
writing_profile = ""
|
||||
interaction_hint = ""
|
||||
existing_text = ""
|
||||
reconstruction = ""
|
||||
user_bodies: list[str] = []
|
||||
purpose = context.get("purpose") or ""
|
||||
for item in context.get("items") or []:
|
||||
kind = item.get("type")
|
||||
if kind == "day_messages":
|
||||
for message in item.get("messages") or []:
|
||||
day_messages = item.get("messages") or []
|
||||
if purpose == "journal_reconstruct":
|
||||
from journal_reconstruct import assign_source_ids
|
||||
|
||||
day_messages = assign_source_ids(day_messages)
|
||||
for message in day_messages:
|
||||
role = message.get("role") or "user"
|
||||
body = message.get("body") or ""
|
||||
dialogue_parts.append(f"{role}: {body}")
|
||||
source_id = message.get("source_id")
|
||||
if purpose == "journal_reconstruct" and source_id:
|
||||
dialogue_parts.append(f"[{source_id}] {role}: {body}")
|
||||
else:
|
||||
dialogue_parts.append(f"{role}: {body}")
|
||||
if role == "user":
|
||||
user_bodies.append(body)
|
||||
elif kind == "prior_entries":
|
||||
@@ -202,6 +216,11 @@ def assemble_text(context: dict) -> dict[str, str]:
|
||||
interaction_hint = item.get("text") or ""
|
||||
elif kind == "existing_text":
|
||||
existing_text = item.get("body") or ""
|
||||
elif kind == "reconstruction":
|
||||
reconstruction = item.get("body") or ""
|
||||
elif kind == "opening":
|
||||
pass
|
||||
opening_hint = ""
|
||||
if purpose == "dialogue_turn":
|
||||
from conversation_signals import infer_signals
|
||||
from interaction_profile_store import assemble_interaction_hint
|
||||
@@ -221,6 +240,8 @@ def assemble_text(context: dict) -> dict[str, str]:
|
||||
"writing_profile": writing_profile,
|
||||
"interaction_hint": interaction_hint,
|
||||
"existing_text": existing_text,
|
||||
"reconstruction": reconstruction,
|
||||
"space_title": context.get("space_title") or "",
|
||||
"register_hint": infer_register(user_bodies),
|
||||
"opening_hint": opening_hint,
|
||||
}
|
||||
Reference in new issue
Block a user