Add dreaming toggle and trigger routes
This commit is contained in:
@@ -11,6 +11,7 @@ from fastapi import APIRouter, Request
|
||||
from fastapi.responses import HTMLResponse, JSONResponse
|
||||
|
||||
from dashboard.templating import templates
|
||||
from config import settings
|
||||
from timmy.thinking import thinking_engine
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -61,3 +62,30 @@ async def thought_chain_api(thought_id: str):
|
||||
}
|
||||
for t in chain
|
||||
]
|
||||
|
||||
@router.get("/dreaming/status", response_class=JSONResponse)
|
||||
async def dreaming_status():
|
||||
"""Return current dreaming status."""
|
||||
return {"dreaming_enabled": settings.dreaming_enabled}
|
||||
|
||||
|
||||
@router.post("/dreaming/toggle", response_class=JSONResponse)
|
||||
async def toggle_dreaming():
|
||||
"""Toggle dreaming mode."""
|
||||
settings.dreaming_enabled = not settings.dreaming_enabled
|
||||
logger.info("Dreaming mode toggled: %s", settings.dreaming_enabled)
|
||||
return {"dreaming_enabled": settings.dreaming_enabled}
|
||||
|
||||
|
||||
@router.post("/dream", response_class=JSONResponse)
|
||||
async def trigger_dream():
|
||||
"""Trigger a single dream thought."""
|
||||
thought = await thinking_engine.dream()
|
||||
if not thought:
|
||||
return JSONResponse({"error": "Failed to generate dream"}, status_code=500)
|
||||
return {
|
||||
"id": thought.id,
|
||||
"content": thought.content,
|
||||
"seed_type": thought.seed_type,
|
||||
"created_at": thought.created_at,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user