Initial clean commit - unified Lyra stack
This commit is contained in:
33
cortex/ingest_handler.py
Normal file
33
cortex/ingest_handler.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# ingest_handler.py
|
||||
import os
|
||||
import httpx
|
||||
|
||||
NEOMEM_URL = os.getenv("NEOMEM_API", "http://nvgram-api:7077")
|
||||
|
||||
async def handle_ingest(payload):
|
||||
"""
|
||||
Pass user+assistant turns to NeoMem.
|
||||
Minimal version. Does not process or annotate.
|
||||
"""
|
||||
data = {
|
||||
"messages": [],
|
||||
"user_id": "brian" # default for now
|
||||
}
|
||||
|
||||
if payload.user:
|
||||
data["messages"].append({"role": "user", "content": payload.user})
|
||||
|
||||
if payload.assistant:
|
||||
data["messages"].append({"role": "assistant", "content": payload.assistant})
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
r = await client.post(
|
||||
f"{NEOMEM_URL}/memories",
|
||||
json=data,
|
||||
timeout=5
|
||||
)
|
||||
if r.status_code != 200:
|
||||
print(f"[Ingest] NeoMem returned {r.status_code}: {r.text}")
|
||||
except Exception as e:
|
||||
print(f"[Ingest] Failed to send to NeoMem: {e}")
|
||||
Reference in New Issue
Block a user