feat(agent-office): /api/agent-office/tarot 5 endpoint (T6)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,9 +12,11 @@ from .agents import init_agents, get_agent, get_all_agent_states, AGENT_REGISTRY
|
||||
from .scheduler import init_scheduler
|
||||
from . import telegram_bot
|
||||
from .routers import notify as notify_router
|
||||
from .routers import tarot as tarot_router
|
||||
|
||||
app = FastAPI()
|
||||
app.include_router(notify_router.router)
|
||||
app.include_router(tarot_router.router)
|
||||
|
||||
_cors_origins = CORS_ALLOW_ORIGINS.split(",")
|
||||
app.add_middleware(
|
||||
|
||||
70
agent-office/app/routers/tarot.py
Normal file
70
agent-office/app/routers/tarot.py
Normal file
@@ -0,0 +1,70 @@
|
||||
"""Tarot Lab 엔드포인트 — interpret + readings CRUD."""
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from ..models import (
|
||||
TarotInterpretRequest,
|
||||
TarotInterpretResponse,
|
||||
TarotSaveRequest,
|
||||
TarotPatchRequest,
|
||||
)
|
||||
from ..tarot import pipeline
|
||||
from .. import db as db_module
|
||||
|
||||
|
||||
router = APIRouter(prefix="/api/agent-office/tarot")
|
||||
|
||||
|
||||
@router.post("/interpret", response_model=TarotInterpretResponse)
|
||||
async def interpret_endpoint(req: TarotInterpretRequest):
|
||||
try:
|
||||
result = await pipeline.interpret(req)
|
||||
except pipeline.TarotError as e:
|
||||
raise HTTPException(status_code=500, detail=str(e)) from e
|
||||
return result
|
||||
|
||||
|
||||
@router.post("/readings")
|
||||
async def save_reading(req: TarotSaveRequest):
|
||||
rid = db_module.save_tarot_reading(req.model_dump())
|
||||
row = db_module.get_tarot_reading(rid)
|
||||
return {"id": rid, "created_at": row["created_at"]}
|
||||
|
||||
|
||||
@router.get("/readings")
|
||||
async def list_readings(
|
||||
page: int = 1,
|
||||
size: int = 20,
|
||||
favorite: bool | None = None,
|
||||
spread_type: str | None = None,
|
||||
category: str | None = None,
|
||||
):
|
||||
return db_module.list_tarot_readings(
|
||||
page=page, size=size,
|
||||
favorite=favorite, spread_type=spread_type, category=category,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/readings/{reading_id}")
|
||||
async def get_reading(reading_id: int):
|
||||
row = db_module.get_tarot_reading(reading_id)
|
||||
if not row:
|
||||
raise HTTPException(status_code=404, detail="reading not found")
|
||||
return row
|
||||
|
||||
|
||||
@router.patch("/readings/{reading_id}")
|
||||
async def patch_reading(reading_id: int, req: TarotPatchRequest):
|
||||
row = db_module.get_tarot_reading(reading_id)
|
||||
if not row:
|
||||
raise HTTPException(status_code=404, detail="reading not found")
|
||||
db_module.update_tarot_reading(reading_id, **req.model_dump(exclude_none=True))
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@router.delete("/readings/{reading_id}")
|
||||
async def delete_reading(reading_id: int):
|
||||
row = db_module.get_tarot_reading(reading_id)
|
||||
if not row:
|
||||
raise HTTPException(status_code=404, detail="reading not found")
|
||||
db_module.delete_tarot_reading(reading_id)
|
||||
return {"ok": True}
|
||||
Reference in New Issue
Block a user