ruff format

This commit is contained in:
Manoj Aggarwal 2026-01-21 09:55:40 -08:00
parent d640802909
commit 6a8721bd17
2 changed files with 19 additions and 5 deletions

View file

@ -98,7 +98,9 @@ def format_memories_for_context(memories: list[dict[str, Any]]) -> str:
category = memory.get("category", "unknown")
text = memory.get("memory_text", "")
updated = memory.get("updated_at", "")
parts.append(f" <memory category='{category}' updated='{updated}'>{text}</memory>")
parts.append(
f" <memory category='{category}' updated='{updated}'>{text}</memory>"
)
parts.append("</user_memories>")
return "\n".join(parts)
@ -187,7 +189,7 @@ def create_save_memory_tool(
category=MemoryCategory(category), # Convert string to enum
embedding=embedding, # Pass embedding directly (list or numpy array)
)
db_session.add(new_memory)
await db_session.commit()
await db_session.refresh(new_memory)
@ -279,7 +281,12 @@ def create_recall_memory_tool(
)
# Add category filter if specified
if category and category in ["preference", "fact", "instruction", "context"]:
if category and category in [
"preference",
"fact",
"instruction",
"context",
]:
stmt = stmt.where(UserMemory.category == MemoryCategory(category))
# Order by vector similarity
@ -299,7 +306,12 @@ def create_recall_memory_tool(
)
# Add category filter if specified
if category and category in ["preference", "fact", "instruction", "context"]:
if category and category in [
"preference",
"fact",
"instruction",
"context",
]:
stmt = stmt.where(UserMemory.category == MemoryCategory(category))
stmt = stmt.order_by(UserMemory.updated_at.desc()).limit(top_k)

View file

@ -478,7 +478,9 @@ class MemoryCategory(str, Enum):
# Using lowercase keys to match PostgreSQL enum values
preference = "preference" # User preferences (e.g., "prefers dark mode")
fact = "fact" # Facts about the user (e.g., "is a Python developer")
instruction = "instruction" # Standing instructions (e.g., "always respond in bullet points")
instruction = (
"instruction" # Standing instructions (e.g., "always respond in bullet points")
)
context = "context" # Contextual information (e.g., "working on project X")