Add system memory monitoring, Bedrock support, and Discord integrations
- Add CPU/GPU memory monitoring endpoint and frontend widget - Add Amazon Bedrock model support (API key / inference profiles) plus model selector entries - Add Discord weather/laundry notification job (JMA forecast + LLM-generated message) - Add Discord bot that replies to mentions via the configured LLM, with weather-aware context - Add scheduled "useless tips" job with separate webhook and quiet-hours skip - Switch FastAPI startup to lifespan handler, log viewer, markdown rendering, and toast UI additions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
from datetime import datetime
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy.orm import Session as DBSession
|
||||
from sqlalchemy import desc
|
||||
|
||||
from app.db.database import get_db
|
||||
from app.db.models import ApiLog
|
||||
|
||||
router = APIRouter(prefix="/logs", tags=["logs"])
|
||||
|
||||
|
||||
class LogResponse(BaseModel):
|
||||
id: int
|
||||
session_id: str | None
|
||||
model: str
|
||||
request_json: str
|
||||
response_text: str | None
|
||||
error: str | None
|
||||
latency_ms: float | None
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
@router.get("", response_model=list[LogResponse])
|
||||
def list_logs(
|
||||
session_id: str | None = Query(None),
|
||||
status: str | None = Query(None, description="'ok' または 'error'"),
|
||||
limit: int = Query(100, le=500),
|
||||
offset: int = Query(0),
|
||||
db: DBSession = Depends(get_db),
|
||||
):
|
||||
q = db.query(ApiLog)
|
||||
if session_id:
|
||||
q = q.filter(ApiLog.session_id == session_id)
|
||||
if status == "ok":
|
||||
q = q.filter(ApiLog.error.is_(None))
|
||||
elif status == "error":
|
||||
q = q.filter(ApiLog.error.isnot(None))
|
||||
return q.order_by(desc(ApiLog.created_at)).offset(offset).limit(limit).all()
|
||||
|
||||
|
||||
@router.delete("/{log_id}", status_code=204)
|
||||
def delete_log(log_id: int, db: DBSession = Depends(get_db)):
|
||||
log = db.get(ApiLog, log_id)
|
||||
if log:
|
||||
db.delete(log)
|
||||
db.commit()
|
||||
Reference in New Issue
Block a user