From 9f20110f56f93c94ab10a0ca2c3a54bfea82fa68 Mon Sep 17 00:00:00 2001 From: Robert Helewka Date: Sun, 12 Jul 2026 08:03:28 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=BE=20feat(library):=20add=20'email'?= =?UTF-8?q?=20library=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kairos is about to provision per-user app-managed (workspace) libraries for synced mail, and none of the existing types fit correspondence. New entry in LIBRARY_TYPE_DEFAULTS mirrors journal's entry-level chunking (one message ≈ one entry) with instructions tuned for email: correspondents, dates, requests/commitments, and quoted-reply context. Registered in the Library node choices and the API serializer choice list; forms and load_library_types derive from the registry, and the compose init sidecar re-runs the seeder on deploy. Co-Authored-By: Claude Fable 5 --- mnemosyne/library/api/serializers.py | 1 + mnemosyne/library/content_types.py | 34 ++++++++++++++++++- mnemosyne/library/models.py | 1 + mnemosyne/library/tests/test_content_types.py | 1 + 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/mnemosyne/library/api/serializers.py b/mnemosyne/library/api/serializers.py index c4cb03c..b28ce9c 100644 --- a/mnemosyne/library/api/serializers.py +++ b/mnemosyne/library/api/serializers.py @@ -15,6 +15,7 @@ LIBRARY_TYPE_CHOICES = [ "film", "art", "journal", + "email", "business", "finance", ] diff --git a/mnemosyne/library/content_types.py b/mnemosyne/library/content_types.py index 215df02..40369d4 100644 --- a/mnemosyne/library/content_types.py +++ b/mnemosyne/library/content_types.py @@ -241,6 +241,38 @@ LIBRARY_TYPE_DEFAULTS = { "4) The commercial purpose — positioning, pricing, capability demonstration." ), }, + "email": { + "chunking_config": { + "strategy": "entry_level", + "chunk_size": 512, + "chunk_overlap": 32, + "respect_boundaries": ["message", "quote", "paragraph"], + }, + "embedding_instruction": ( + "Represent this email message for retrieval. " + "Focus on the sender, recipients, subject, dates, requests and " + "commitments made, and the people, organizations, and events discussed." + ), + "reranker_instruction": ( + "Re-rank email messages based on relevance to the query. " + "Prioritize messages matching the correspondents, subject matter, " + "time period, and any specific commitments or requests mentioned." + ), + "llm_context_prompt": ( + "The following excerpts are from personal email correspondence. " + "This is private content — answer with discretion. Attribute " + "statements to their senders, note dates, and distinguish what was " + "asked from what was agreed. Quoted text below a reply is earlier " + "context, not the sender's own words." + ), + "vision_prompt": ( + "Analyze this image from an email message. Identify:\n" + "1) Image type (photograph, screenshot, scanned document, chart, signature graphic).\n" + "2) What it depicts — people, places, documents, data.\n" + "3) Any visible text, dates, or figures.\n" + "4) Its role in the message — attachment content, inline illustration, or boilerplate." + ), + }, "finance": { "chunking_config": { "strategy": "section_aware", @@ -282,7 +314,7 @@ def get_library_type_config(library_type): Args: library_type: One of 'fiction', 'nonfiction', 'technical', 'music', - 'film', 'art', 'journal', 'business', 'finance' + 'film', 'art', 'journal', 'email', 'business', 'finance' Returns: dict with keys: chunking_config, embedding_instruction, diff --git a/mnemosyne/library/models.py b/mnemosyne/library/models.py index 69fe482..2594d35 100644 --- a/mnemosyne/library/models.py +++ b/mnemosyne/library/models.py @@ -77,6 +77,7 @@ class Library(StructuredNode): "film": "Film", "art": "Art", "journal": "Journal", + "email": "Email", "business": "Business", "finance": "Finance", }, diff --git a/mnemosyne/library/tests/test_content_types.py b/mnemosyne/library/tests/test_content_types.py index 8725c55..4e5c3f1 100644 --- a/mnemosyne/library/tests/test_content_types.py +++ b/mnemosyne/library/tests/test_content_types.py @@ -21,6 +21,7 @@ class LibraryTypeDefaultsTests(TestCase): "film", "art", "journal", + "email", "business", "finance", }