Add reflections

This commit is contained in:
Jenit Jain 2025-08-24 00:38:46 -07:00
parent 4c7f636097
commit 341d81079f
2 changed files with 3 additions and 5 deletions

View File

@ -52,8 +52,9 @@ class FinancialSituationMemory:
def get_latest_situation(self):
"""Retrieve the latest entry from a situation_collection."""
latest_entry = self.situation_collection.query(sort_by="id:descending", limit=1)
return latest_entry
collections = self.situation_collection.get()
latest_recommendation = collections["metadatas"][-1]["recommendation"]
return latest_recommendation
def get_memories(self, current_situation, n_matches=1):
"""Find matching recommendations using OpenAI embeddings"""

View File

@ -402,9 +402,6 @@ async def reflect_on_analysis(symbol: str, date: str, request: dict):
if not matching_job:
raise HTTPException(status_code=404, detail=f"No active job found for {symbol} on {date}")
if not hasattr(matching_job.trading_agent, 'memory') or not matching_job.trading_agent.memory:
raise HTTPException(status_code=404, detail="No memory found for this analysis")
matching_job.trading_agent.reflect_and_remember(returns_losses)
try: