Update to v0.9.1 #1

Merged
serversdown merged 44 commits from dev into main 2026-01-18 02:46:25 -05:00
8 changed files with 537 additions and 87 deletions
Showing only changes of commit cb00474ab3 - Show all commits

View File

@@ -8,7 +8,7 @@ class IntakeClient:
"""Handles short-term / episodic summaries from Intake service."""
def __init__(self):
self.base_url = os.getenv("INTAKE_API", "http://intake:7080")
self.base_url = os.getenv("INTAKE_API", "http://intake:7083")
async def summarize_turn(self, session_id: str, user_msg: str, assistant_msg: Optional[str] = None) -> Dict[str, Any]:
payload = {

View File

@@ -1,86 +1,6 @@
from fastapi import FastAPI
from pydantic import BaseModel
from reasoning import reason_check
from reflection import reflect_notes
from rag import query_rag
from ingest_handler import handle_ingest
from refine import refine_answer
from router import router
# ---------------------------------------------------
# Create the app BEFORE using it
# ---------------------------------------------------
app = FastAPI()
# ---------------------------------------------------
# Models
# ---------------------------------------------------
class ReasonRequest(BaseModel):
prompt: str
session_id: str | None = None
class IngestRequest(BaseModel):
user: str
assistant: str | None = None
session_id: str | None = None
# ---------------------------------------------------
# Load identity
# ---------------------------------------------------
IDENTITY = None
# ---------------------------------------------------
# Routes MUST come after app = FastAPI()
# ---------------------------------------------------
@app.get("/health")
def health():
return {
"status": "ok",
"identity_loaded": IDENTITY is not None
}
@app.post("/ingest")
async def ingest(data: IngestRequest):
await handle_ingest(data)
return {"status": "ok"}
@app.post("/reason")
async def reason(data: ReasonRequest):
user_prompt = data.prompt
intake_summary = "recent summary"
identity_block = IDENTITY
rag_block = query_rag(user_prompt)
reflection_data = await reflect_notes(intake_summary, identity_block)
notes = reflection_data.get("notes", [])
draft = await reason_check(
user_prompt,
identity_block,
rag_block,
notes
)
# --- REFINE STEP ----------------------------------------------------
refine_result = refine_answer(
draft_output=draft,
reflection_notes=notes,
identity_block=identity_block,
rag_block=rag_block,
)
final_output = refine_result["final_output"]
return {
"draft_output": draft,
"reflection_notes": notes,
"refined_output": final_output,
"refine_meta": {
"used_primary_backend": refine_result.get("used_primary_backend"),
"fallback_used": refine_result.get("fallback_used")
},
"identity_used": identity_block is not None,
"rag_used": rag_block is not None
}
app.include_router(router)

View File

@@ -0,0 +1,7 @@
def apply_persona(text: str) -> str:
"""
Persona layer.
Right now it passes text unchanged.
Later we will add Lyra-voice transformation here.
"""
return text or ""

View File

@@ -1,5 +1,5 @@
# reasoning.py
from llm_router import call_llm
from llm.llm_router import call_llm
async def reason_check(user_prompt: str,
identity_block: dict | None,

View File

@@ -1,5 +1,5 @@
# reflection.py
from llm_router import call_llm
from llm.llm_router import call_llm
import json
@@ -30,7 +30,7 @@ async def reflect_notes(intake_summary: str, identity_block: dict | None) -> dic
)
raw = await call_llm(prompt, backend="cloud")
raw = await call_llm(prompt, backend="primary")
print("[Reflection-Raw]:", raw)

63
cortex/router.py Normal file
View File

@@ -0,0 +1,63 @@
from fastapi import APIRouter
from pydantic import BaseModel
from typing import Optional, List, Any
from reasoning.reasoning import reason_check
from reasoning.reflection import reflect_notes
from reasoning.refine import refine_answer
from persona.speak import apply_persona
from ingest.intake_client import IntakeClient
router = APIRouter()
# ------------------------------------------------------
# Request schema
# ------------------------------------------------------
class ReasonRequest(BaseModel):
session_id: Optional[str]
user_prompt: str
temperature: float = 0.7
# ------------------------------------------------------
# /reason endpoint
# ------------------------------------------------------
@router.post("/reason")
async def run_reason(req: ReasonRequest):
# 1. Summaries from Intake (context memory)
intake = IntakeClient()
intake_summary = await intake.get_context(req.session_id)
# 2. Internal reflection notes
reflection = await reflect_notes(intake_summary, identity_block=None)
reflection_notes: List[str] = reflection.get("notes", [])
# 3. Draft answer (weak, unfiltered)
draft = await reason_check(
user_prompt=req.user_prompt,
identity_block=None,
rag_block=None,
reflection_notes=reflection_notes,
)
# 4. Refine the answer (structured self-correction)
refined_packet: dict[str, Any] = refine_answer(
draft_output=draft,
reflection_notes=reflection_notes,
identity_block=None,
rag_block=None,
)
refined_text = refined_packet.get("final_output", draft)
# 5. Persona styling (Lyra voice)
final_output = apply_persona(refined_text)
return {
"draft": draft,
"refined": refined_text,
"final": final_output,
"reflection_notes": reflection_notes,
"session_id": req.session_id,
}

View File

@@ -108,7 +108,7 @@ services:
ports:
- "7081:7081"
environment:
LLM_PRIMARY_URL: http://10.0.0.43:7081/v1/completions
LLM_PRIMARY_URL: http://10.0.0.43:8000/
NEOMEM_URL: http://neomem-api:7077
RAG_URL: http://rag:7090
RELAY_URL: http://relay:7078

460
lyra_tree.txt Normal file
View File

@@ -0,0 +1,460 @@
/home/serversdown/project-lyra
├── CHANGELOG.md
├── core
│   ├── backups
│   │   ├── mem0_20250927_221040.sql
│   │   └── mem0_history_20250927_220925.tgz
│   ├── docker-compose.yml
│   ├── .env
│   ├── env experiments
│   │   ├── .env
│   │   ├── .env.local
│   │   └── .env.openai
│   ├── persona-sidecar
│   │   ├── Dockerfile
│   │   ├── package.json
│   │   ├── persona-server.js
│   │   └── personas.json
│   ├── PROJECT_SUMMARY.md
│   ├── relay
│   │   ├── Dockerfile
│   │   ├── .dockerignore
│   │   ├── lib
│   │   │   ├── cortex.js
│   │   │   └── llm.js
│   │   ├── package.json
│   │   ├── package-lock.json
│   │   ├── server.js
│   │   ├── sessions
│   │   │   ├── sess-6rxu7eia.json
│   │   │   ├── sess-6rxu7eia.jsonl
│   │   │   ├── sess-l08ndm60.json
│   │   │   └── sess-l08ndm60.jsonl
│   │   └── test-llm.js
│   └── ui
│   ├── index.html
│   ├── manifest.json
│   └── style.css
├── cortex
│   ├── Dockerfile
│   ├── .env
│   ├── ingest
│   │   ├── ingest_handler.py
│   │   └── intake_client.py
│   ├── llm
│   │   ├── llm_router.py
│   │   └── resolve_llm_url.py
│   ├── logs
│   │   └── reflections.log
│   ├── main.py
│   ├── neomem_client.py
│   ├── persona
│   │   └── speak.py
│   ├── rag.py
│   ├── reasoning
│   │   ├── reasoning.py
│   │   ├── refine.py
│   │   └── reflection.py
│   ├── requirements.txt
│   ├── router.py
│   ├── tests
│   └── utils
│   ├── config.py
│   ├── log_utils.py
│   └── schema.py
├── deprecated.env.txt
├── docker-compose.yml
├── .env
├── .gitignore
├── intake
│   ├── Dockerfile
│   ├── .env
│   ├── intake.py
│   ├── logs
│   ├── requirements.txt
│   └── venv
│   ├── bin
│   │   ├── python -> python3
│   │   ├── python3 -> /usr/bin/python3
│   │   └── python3.10 -> python3
│   ├── include
│   ├── lib
│   │   └── python3.10
│   │   └── site-packages
│   ├── lib64 -> lib
│   └── pyvenv.cfg
├── intake-logs
│   └── summaries.log
├── lyra_tree.txt
├── neomem
│   ├── _archive
│   │   └── old_servers
│   │   ├── main_backup.py
│   │   └── main_dev.py
│   ├── docker-compose.yml
│   ├── Dockerfile
│   ├── .env
│   ├── .gitignore
│   ├── neomem
│   │   ├── api
│   │   ├── client
│   │   │   ├── __init__.py
│   │   │   ├── main.py
│   │   │   ├── project.py
│   │   │   └── utils.py
│   │   ├── configs
│   │   │   ├── base.py
│   │   │   ├── embeddings
│   │   │   │   ├── base.py
│   │   │   │   └── __init__.py
│   │   │   ├── enums.py
│   │   │   ├── __init__.py
│   │   │   ├── llms
│   │   │   │   ├── anthropic.py
│   │   │   │   ├── aws_bedrock.py
│   │   │   │   ├── azure.py
│   │   │   │   ├── base.py
│   │   │   │   ├── deepseek.py
│   │   │   │   ├── __init__.py
│   │   │   │   ├── lmstudio.py
│   │   │   │   ├── ollama.py
│   │   │   │   ├── openai.py
│   │   │   │   └── vllm.py
│   │   │   ├── prompts.py
│   │   │   └── vector_stores
│   │   │   ├── azure_ai_search.py
│   │   │   ├── azure_mysql.py
│   │   │   ├── baidu.py
│   │   │   ├── chroma.py
│   │   │   ├── databricks.py
│   │   │   ├── elasticsearch.py
│   │   │   ├── faiss.py
│   │   │   ├── __init__.py
│   │   │   ├── langchain.py
│   │   │   ├── milvus.py
│   │   │   ├── mongodb.py
│   │   │   ├── neptune.py
│   │   │   ├── opensearch.py
│   │   │   ├── pgvector.py
│   │   │   ├── pinecone.py
│   │   │   ├── qdrant.py
│   │   │   ├── redis.py
│   │   │   ├── s3_vectors.py
│   │   │   ├── supabase.py
│   │   │   ├── upstash_vector.py
│   │   │   ├── valkey.py
│   │   │   ├── vertex_ai_vector_search.py
│   │   │   └── weaviate.py
│   │   ├── core
│   │   ├── embeddings
│   │   │   ├── aws_bedrock.py
│   │   │   ├── azure_openai.py
│   │   │   ├── base.py
│   │   │   ├── configs.py
│   │   │   ├── gemini.py
│   │   │   ├── huggingface.py
│   │   │   ├── __init__.py
│   │   │   ├── langchain.py
│   │   │   ├── lmstudio.py
│   │   │   ├── mock.py
│   │   │   ├── ollama.py
│   │   │   ├── openai.py
│   │   │   ├── together.py
│   │   │   └── vertexai.py
│   │   ├── exceptions.py
│   │   ├── graphs
│   │   │   ├── configs.py
│   │   │   ├── __init__.py
│   │   │   ├── neptune
│   │   │   │   ├── base.py
│   │   │   │   ├── __init__.py
│   │   │   │   ├── neptunedb.py
│   │   │   │   └── neptunegraph.py
│   │   │   ├── tools.py
│   │   │   └── utils.py
│   │   ├── __init__.py
│   │   ├── LICENSE
│   │   ├── llms
│   │   │   ├── anthropic.py
│   │   │   ├── aws_bedrock.py
│   │   │   ├── azure_openai.py
│   │   │   ├── azure_openai_structured.py
│   │   │   ├── base.py
│   │   │   ├── configs.py
│   │   │   ├── deepseek.py
│   │   │   ├── gemini.py
│   │   │   ├── groq.py
│   │   │   ├── __init__.py
│   │   │   ├── langchain.py
│   │   │   ├── litellm.py
│   │   │   ├── lmstudio.py
│   │   │   ├── ollama.py
│   │   │   ├── openai.py
│   │   │   ├── openai_structured.py
│   │   │   ├── sarvam.py
│   │   │   ├── together.py
│   │   │   ├── vllm.py
│   │   │   └── xai.py
│   │   ├── memory
│   │   │   ├── base.py
│   │   │   ├── graph_memory.py
│   │   │   ├── __init__.py
│   │   │   ├── kuzu_memory.py
│   │   │   ├── main.py
│   │   │   ├── memgraph_memory.py
│   │   │   ├── setup.py
│   │   │   ├── storage.py
│   │   │   ├── telemetry.py
│   │   │   └── utils.py
│   │   ├── proxy
│   │   │   ├── __init__.py
│   │   │   └── main.py
│   │   ├── server
│   │   │   ├── dev.Dockerfile
│   │   │   ├── docker-compose.yaml
│   │   │   ├── Dockerfile
│   │   │   ├── main_old.py
│   │   │   ├── main.py
│   │   │   ├── Makefile
│   │   │   ├── README.md
│   │   │   └── requirements.txt
│   │   ├── storage
│   │   ├── utils
│   │   │   └── factory.py
│   │   └── vector_stores
│   │   ├── azure_ai_search.py
│   │   ├── azure_mysql.py
│   │   ├── baidu.py
│   │   ├── base.py
│   │   ├── chroma.py
│   │   ├── configs.py
│   │   ├── databricks.py
│   │   ├── elasticsearch.py
│   │   ├── faiss.py
│   │   ├── __init__.py
│   │   ├── langchain.py
│   │   ├── milvus.py
│   │   ├── mongodb.py
│   │   ├── neptune_analytics.py
│   │   ├── opensearch.py
│   │   ├── pgvector.py
│   │   ├── pinecone.py
│   │   ├── qdrant.py
│   │   ├── redis.py
│   │   ├── s3_vectors.py
│   │   ├── supabase.py
│   │   ├── upstash_vector.py
│   │   ├── valkey.py
│   │   ├── vertex_ai_vector_search.py
│   │   └── weaviate.py
│   ├── neomem_history
│   │   └── history.db
│   ├── pyproject.toml
│   ├── README.md
│   └── requirements.txt
├── neomem_history
│   └── history.db
├── rag
│   ├── chatlogs
│   │   └── lyra
│   │   ├── 0000_Wire_ROCm_to_Cortex.json
│   │   ├── 0001_Branch___10_22_ct201branch-ssh_tut.json
│   │   ├── 0002_cortex_LLMs_11-1-25.json
│   │   ├── 0003_RAG_beta.json
│   │   ├── 0005_Cortex_v0_4_0_planning.json
│   │   ├── 0006_Cortex_v0_4_0_Refinement.json
│   │   ├── 0009_Branch___Cortex_v0_4_0_planning.json
│   │   ├── 0012_Cortex_4_-_neomem_11-1-25.json
│   │   ├── 0016_Memory_consolidation_concept.json
│   │   ├── 0017_Model_inventory_review.json
│   │   ├── 0018_Branch___Memory_consolidation_concept.json
│   │   ├── 0022_Branch___Intake_conversation_summaries.json
│   │   ├── 0026_Intake_conversation_summaries.json
│   │   ├── 0027_Trilium_AI_LLM_setup.json
│   │   ├── 0028_LLMs_and_sycophancy_levels.json
│   │   ├── 0031_UI_improvement_plan.json
│   │   ├── 0035_10_27-neomem_update.json
│   │   ├── 0044_Install_llama_cpp_on_ct201.json
│   │   ├── 0045_AI_task_assistant.json
│   │   ├── 0047_Project_scope_creation.json
│   │   ├── 0052_View_docker_container_logs.json
│   │   ├── 0053_10_21-Proxmox_fan_control.json
│   │   ├── 0054_10_21-pytorch_branch_Quant_experiments.json
│   │   ├── 0055_10_22_ct201branch-ssh_tut.json
│   │   ├── 0060_Lyra_project_folder_issue.json
│   │   ├── 0062_Build_pytorch_API.json
│   │   ├── 0063_PokerBrain_dataset_structure.json
│   │   ├── 0065_Install_PyTorch_setup.json
│   │   ├── 0066_ROCm_PyTorch_setup_quirks.json
│   │   ├── 0067_VM_model_setup_steps.json
│   │   ├── 0070_Proxmox_disk_error_fix.json
│   │   ├── 0072_Docker_Compose_vs_Portainer.json
│   │   ├── 0073_Check_system_temps_Proxmox.json
│   │   ├── 0075_Cortex_gpu_progress.json
│   │   ├── 0076_Backup_Proxmox_before_upgrade.json
│   │   ├── 0077_Storage_cleanup_advice.json
│   │   ├── 0082_Install_ROCm_on_Proxmox.json
│   │   ├── 0088_Thalamus_program_summary.json
│   │   ├── 0094_Cortex_blueprint_development.json
│   │   ├── 0095_mem0_advancments.json
│   │   ├── 0096_Embedding_provider_swap.json
│   │   ├── 0097_Update_git_commit_steps.json
│   │   ├── 0098_AI_software_description.json
│   │   ├── 0099_Seed_memory_process.json
│   │   ├── 0100_Set_up_Git_repo.json
│   │   ├── 0101_Customize_embedder_setup.json
│   │   ├── 0102_Seeding_Local_Lyra_memory.json
│   │   ├── 0103_Mem0_seeding_part_3.json
│   │   ├── 0104_Memory_build_prompt.json
│   │   ├── 0105_Git_submodule_setup_guide.json
│   │   ├── 0106_Serve_UI_on_LAN.json
│   │   ├── 0107_AI_name_suggestion.json
│   │   ├── 0108_Room_X_planning_update.json
│   │   ├── 0109_Salience_filtering_design.json
│   │   ├── 0110_RoomX_Cortex_build.json
│   │   ├── 0119_Explain_Lyra_cortex_idea.json
│   │   ├── 0120_Git_submodule_organization.json
│   │   ├── 0121_Web_UI_fix_guide.json
│   │   ├── 0122_UI_development_planning.json
│   │   ├── 0123_NVGRAM_debugging_steps.json
│   │   ├── 0124_NVGRAM_setup_troubleshooting.json
│   │   ├── 0125_NVGRAM_development_update.json
│   │   ├── 0126_RX_-_NeVGRAM_New_Features.json
│   │   ├── 0127_Error_troubleshooting_steps.json
│   │   ├── 0135_Proxmox_backup_with_ABB.json
│   │   ├── 0151_Auto-start_Lyra-Core_VM.json
│   │   ├── 0156_AI_GPU_benchmarks_comparison.json
│   │   └── 0251_Lyra_project_handoff.json
│   ├── chromadb
│   │   ├── c4f701ee-1978-44a1-9df4-3e865b5d33c1
│   │   │   ├── data_level0.bin
│   │   │   ├── header.bin
│   │   │   ├── index_metadata.pickle
│   │   │   ├── length.bin
│   │   │   └── link_lists.bin
│   │   └── chroma.sqlite3
│   ├── .env
│   ├── import.log
│   ├── lyra-chatlogs
│   │   ├── 0000_Wire_ROCm_to_Cortex.json
│   │   ├── 0001_Branch___10_22_ct201branch-ssh_tut.json
│   │   ├── 0002_cortex_LLMs_11-1-25.json
│   │   └── 0003_RAG_beta.json
│   ├── rag_api.py
│   ├── rag_build.py
│   ├── rag_chat_import.py
│   └── rag_query.py
├── README.md
├── vllm-mi50.md
└── volumes
├── neo4j_data
│   ├── databases
│   │   ├── neo4j
│   │   │   ├── database_lock
│   │   │   ├── id-buffer.tmp.0
│   │   │   ├── neostore
│   │   │   ├── neostore.counts.db
│   │   │   ├── neostore.indexstats.db
│   │   │   ├── neostore.labeltokenstore.db
│   │   │   ├── neostore.labeltokenstore.db.id
│   │   │   ├── neostore.labeltokenstore.db.names
│   │   │   ├── neostore.labeltokenstore.db.names.id
│   │   │   ├── neostore.nodestore.db
│   │   │   ├── neostore.nodestore.db.id
│   │   │   ├── neostore.nodestore.db.labels
│   │   │   ├── neostore.nodestore.db.labels.id
│   │   │   ├── neostore.propertystore.db
│   │   │   ├── neostore.propertystore.db.arrays
│   │   │   ├── neostore.propertystore.db.arrays.id
│   │   │   ├── neostore.propertystore.db.id
│   │   │   ├── neostore.propertystore.db.index
│   │   │   ├── neostore.propertystore.db.index.id
│   │   │   ├── neostore.propertystore.db.index.keys
│   │   │   ├── neostore.propertystore.db.index.keys.id
│   │   │   ├── neostore.propertystore.db.strings
│   │   │   ├── neostore.propertystore.db.strings.id
│   │   │   ├── neostore.relationshipgroupstore.db
│   │   │   ├── neostore.relationshipgroupstore.db.id
│   │   │   ├── neostore.relationshipgroupstore.degrees.db
│   │   │   ├── neostore.relationshipstore.db
│   │   │   ├── neostore.relationshipstore.db.id
│   │   │   ├── neostore.relationshiptypestore.db
│   │   │   ├── neostore.relationshiptypestore.db.id
│   │   │   ├── neostore.relationshiptypestore.db.names
│   │   │   ├── neostore.relationshiptypestore.db.names.id
│   │   │   ├── neostore.schemastore.db
│   │   │   ├── neostore.schemastore.db.id
│   │   │   └── schema
│   │   │   └── index
│   │   │   └── token-lookup-1.0
│   │   │   ├── 1
│   │   │   │   └── index-1
│   │   │   └── 2
│   │   │   └── index-2
│   │   ├── store_lock
│   │   └── system
│   │   ├── database_lock
│   │   ├── id-buffer.tmp.0
│   │   ├── neostore
│   │   ├── neostore.counts.db
│   │   ├── neostore.indexstats.db
│   │   ├── neostore.labeltokenstore.db
│   │   ├── neostore.labeltokenstore.db.id
│   │   ├── neostore.labeltokenstore.db.names
│   │   ├── neostore.labeltokenstore.db.names.id
│   │   ├── neostore.nodestore.db
│   │   ├── neostore.nodestore.db.id
│   │   ├── neostore.nodestore.db.labels
│   │   ├── neostore.nodestore.db.labels.id
│   │   ├── neostore.propertystore.db
│   │   ├── neostore.propertystore.db.arrays
│   │   ├── neostore.propertystore.db.arrays.id
│   │   ├── neostore.propertystore.db.id
│   │   ├── neostore.propertystore.db.index
│   │   ├── neostore.propertystore.db.index.id
│   │   ├── neostore.propertystore.db.index.keys
│   │   ├── neostore.propertystore.db.index.keys.id
│   │   ├── neostore.propertystore.db.strings
│   │   ├── neostore.propertystore.db.strings.id
│   │   ├── neostore.relationshipgroupstore.db
│   │   ├── neostore.relationshipgroupstore.db.id
│   │   ├── neostore.relationshipgroupstore.degrees.db
│   │   ├── neostore.relationshipstore.db
│   │   ├── neostore.relationshipstore.db.id
│   │   ├── neostore.relationshiptypestore.db
│   │   ├── neostore.relationshiptypestore.db.id
│   │   ├── neostore.relationshiptypestore.db.names
│   │   ├── neostore.relationshiptypestore.db.names.id
│   │   ├── neostore.schemastore.db
│   │   ├── neostore.schemastore.db.id
│   │   └── schema
│   │   └── index
│   │   ├── range-1.0
│   │   │   ├── 3
│   │   │   │   └── index-3
│   │   │   ├── 4
│   │   │   │   └── index-4
│   │   │   ├── 7
│   │   │   │   └── index-7
│   │   │   ├── 8
│   │   │   │   └── index-8
│   │   │   └── 9
│   │   │   └── index-9
│   │   └── token-lookup-1.0
│   │   ├── 1
│   │   │   └── index-1
│   │   └── 2
│   │   └── index-2
│   ├── dbms
│   │   └── auth.ini
│   ├── server_id
│   └── transactions
│   ├── neo4j
│   │   ├── checkpoint.0
│   │   └── neostore.transaction.db.0
│   └── system
│   ├── checkpoint.0
│   └── neostore.transaction.db.0
└── postgres_data [error opening dir]
81 directories, 376 files