Update to v0.9.1 #1

Merged
serversdown merged 44 commits from dev into main 2026-01-18 02:46:25 -05:00
15 changed files with 1 additions and 105 deletions
Showing only changes of commit 5492d9c0c5 - Show all commits

View File

@@ -1,61 +0,0 @@
import os, requests, datetime
from typing import Dict, Any, Tuple
INTAKE_API_URL = os.getenv("INTAKE_API_URL", "http://intake:7080")
DEFAULT_SESSION_ID = os.getenv("DEFAULT_SESSION_ID", "default")
LOCAL_TZ_LABEL = os.getenv("LOCAL_TZ_LABEL", "America/New_York")
def fetch_intake_context(session_id: str | None) -> Dict[str, Any]:
sid = session_id or DEFAULT_SESSION_ID
try:
r = requests.get(f"{INTAKE_API_URL}/summaries", params={"session_id": sid}, timeout=4)
r.raise_for_status()
data = r.json() or {}
except Exception:
data = {}
# Normalize expected fields
return {
"summary_text": data.get("summary_text", ""),
"last_message_ts": data.get("last_message_ts"), # ISO8601 or None
"session_id": sid,
"exchange_count": data.get("exchange_count", 0),
}
def build_temporal_snapshot(last_ts_iso: str | None) -> Dict[str, Any]:
now = datetime.datetime.now() # system local time
now_str = now.strftime("%A, %b %-d, %Y, %H:%M")
elapsed_str = "unknown"
if last_ts_iso:
try:
# parse ISO (with/without tz). If it has a timezone offset, fromisoformat handles it.
last = datetime.datetime.fromisoformat(last_ts_iso.replace("Z", "+00:00"))
delta = now - last.replace(tzinfo=None)
mins = int(delta.total_seconds() // 60)
if mins < 60:
elapsed_str = f"{mins} min"
else:
hrs = mins // 60
rem = mins % 60
elapsed_str = f"{hrs} hr {rem} min"
except Exception:
pass
return {
"local_time_label": LOCAL_TZ_LABEL,
"local_time_now": now_str,
"elapsed_since_last": elapsed_str,
}
def get_intake_block(session_id: str | None) -> Tuple[str, Dict[str, Any]]:
ctx = fetch_intake_context(session_id)
temporal = build_temporal_snapshot(ctx.get("last_message_ts"))
# A short, ready-to-inject block for prompts:
intake_block = (
f"[Intake]\n"
f"Session: {ctx['session_id']}\n"
f"Exchanges: {ctx['exchange_count']}\n"
f"Local time ({temporal['local_time_label']}): {temporal['local_time_now']}\n"
f"Elapsed since last: {temporal['elapsed_since_last']}\n"
f"Recent summary: {ctx['summary_text'] or '(none)'}\n"
)
# Also return raw dicts if you want to use fields programmatically
return intake_block, {"intake": ctx, "temporal": temporal}

View File

@@ -1,18 +0,0 @@
{
"name": "Lyra",
"version": "0.1",
"core_values": [
"assist Brian",
"maintain continuity",
"reason first, speak second"
],
"personality": {
"tone": "warm but analytical",
"style": "co-pilot, collaborator"
},
"rules": {
"never hallucinate data": true,
"reason_before_response": true,
"use_rag_when_uncertain": true
}
}

View File

@@ -1,24 +0,0 @@
# identity.py
import json
import os
IDENTITY_PATH = os.getenv("IDENTITY_PATH", "identity.json")
def load_identity():
"""
Load Lyra's identity/persona definition from identity.json.
Returns a dict or None if missing/invalid.
"""
if not os.path.exists(IDENTITY_PATH):
print(f"[Identity] identity.json not found at {IDENTITY_PATH}")
return None
try:
with open(IDENTITY_PATH, "r", encoding="utf-8") as f:
data = json.load(f)
print(f"[Identity] Loaded identity from {IDENTITY_PATH}")
return data
except Exception as e:
print(f"[Identity] Failed to load identity.json: {e}")
return None

View File

View File

@@ -1,6 +1,5 @@
from fastapi import FastAPI
from pydantic import BaseModel
from identity import load_identity
from reasoning import reason_check
from reflection import reflect_notes
from rag import query_rag
@@ -28,7 +27,7 @@ class IngestRequest(BaseModel):
# ---------------------------------------------------
# Load identity
# ---------------------------------------------------
IDENTITY = load_identity()
IDENTITY = None
# ---------------------------------------------------
# Routes MUST come after app = FastAPI()

0
cortex/persona/speak.py Normal file
View File

0
cortex/utils/config.py Normal file
View File

0
cortex/utils/schema.py Normal file
View File