anderson-ufrj
commited on
Commit
·
11a4d19
1
Parent(s):
316a293
fix(settings): replace settings.get() with getattr() for Pydantic models
Browse files- Fixed AttributeError: 'Settings' object has no attribute 'get'
- Replaced all settings.get() calls with getattr() in app.py and memory_startup.py
- Pydantic models use getattr() for attribute access with defaults
- Allows app to start properly with configuration defaults
- src/api/app.py +1 -1
- src/services/memory_startup.py +8 -8
src/api/app.py
CHANGED
|
@@ -83,7 +83,7 @@ async def lifespan(app: FastAPI):
|
|
| 83 |
|
| 84 |
# Start periodic memory optimization if enabled
|
| 85 |
memory_task = None
|
| 86 |
-
if settings
|
| 87 |
memory_task = asyncio.create_task(periodic_memory_optimization())
|
| 88 |
|
| 89 |
yield
|
|
|
|
| 83 |
|
| 84 |
# Start periodic memory optimization if enabled
|
| 85 |
memory_task = None
|
| 86 |
+
if getattr(settings, "ENABLE_MEMORY_OPTIMIZATION", True):
|
| 87 |
memory_task = asyncio.create_task(periodic_memory_optimization())
|
| 88 |
|
| 89 |
yield
|
src/services/memory_startup.py
CHANGED
|
@@ -41,9 +41,9 @@ async def initialize_memory_system() -> Optional[ContextMemoryAgent]:
|
|
| 41 |
memory_agent = ContextMemoryAgent(
|
| 42 |
redis_client=redis_client,
|
| 43 |
vector_store=vector_store,
|
| 44 |
-
max_episodic_memories=settings
|
| 45 |
-
max_conversation_turns=settings
|
| 46 |
-
memory_decay_days=settings
|
| 47 |
)
|
| 48 |
|
| 49 |
# Initialize the memory agent
|
|
@@ -53,9 +53,9 @@ async def initialize_memory_system() -> Optional[ContextMemoryAgent]:
|
|
| 53 |
memory_integration = await initialize_memory_integration(memory_agent)
|
| 54 |
|
| 55 |
# Configure memory integration settings
|
| 56 |
-
memory_integration.auto_store = settings
|
| 57 |
-
memory_integration.auto_retrieve = settings
|
| 58 |
-
memory_integration.cache_ttl = settings
|
| 59 |
|
| 60 |
logger.info("Memory system initialized successfully")
|
| 61 |
logger.info(f"Auto-store: {memory_integration.auto_store}")
|
|
@@ -197,7 +197,7 @@ async def setup_memory_on_startup():
|
|
| 197 |
if memory_agent:
|
| 198 |
await integrate_existing_agents()
|
| 199 |
# Optionally demonstrate memory sharing
|
| 200 |
-
if settings
|
| 201 |
await demonstrate_memory_sharing()
|
| 202 |
return memory_agent
|
| 203 |
|
|
@@ -226,7 +226,7 @@ async def periodic_memory_optimization():
|
|
| 226 |
while True:
|
| 227 |
try:
|
| 228 |
# Wait for configured interval (default: 24 hours)
|
| 229 |
-
interval = settings
|
| 230 |
await asyncio.sleep(interval)
|
| 231 |
|
| 232 |
# Run optimization
|
|
|
|
| 41 |
memory_agent = ContextMemoryAgent(
|
| 42 |
redis_client=redis_client,
|
| 43 |
vector_store=vector_store,
|
| 44 |
+
max_episodic_memories=getattr(settings, "MAX_EPISODIC_MEMORIES", 10000),
|
| 45 |
+
max_conversation_turns=getattr(settings, "MAX_CONVERSATION_TURNS", 100),
|
| 46 |
+
memory_decay_days=getattr(settings, "MEMORY_DECAY_DAYS", 90)
|
| 47 |
)
|
| 48 |
|
| 49 |
# Initialize the memory agent
|
|
|
|
| 53 |
memory_integration = await initialize_memory_integration(memory_agent)
|
| 54 |
|
| 55 |
# Configure memory integration settings
|
| 56 |
+
memory_integration.auto_store = getattr(settings, "AUTO_STORE_MEMORIES", True)
|
| 57 |
+
memory_integration.auto_retrieve = getattr(settings, "AUTO_RETRIEVE_MEMORIES", True)
|
| 58 |
+
memory_integration.cache_ttl = getattr(settings, "MEMORY_CACHE_TTL", 300)
|
| 59 |
|
| 60 |
logger.info("Memory system initialized successfully")
|
| 61 |
logger.info(f"Auto-store: {memory_integration.auto_store}")
|
|
|
|
| 197 |
if memory_agent:
|
| 198 |
await integrate_existing_agents()
|
| 199 |
# Optionally demonstrate memory sharing
|
| 200 |
+
if getattr(settings, "DEMO_MEMORY_SHARING", False):
|
| 201 |
await demonstrate_memory_sharing()
|
| 202 |
return memory_agent
|
| 203 |
|
|
|
|
| 226 |
while True:
|
| 227 |
try:
|
| 228 |
# Wait for configured interval (default: 24 hours)
|
| 229 |
+
interval = getattr(settings, "MEMORY_OPTIMIZATION_INTERVAL", 86400)
|
| 230 |
await asyncio.sleep(interval)
|
| 231 |
|
| 232 |
# Run optimization
|