Add web search knowledge base, message tagging, and word-memory tip topics

Introduces websearch.py (Tavily) + knowledge.py to ground chat responses
in search results, tagging.py to tag user and assistant messages via LLM
and pick related topics for the Discord useless-tips job, and
word_memory.py to track recent conversation nouns (surfaced in the new
WordPool.vue sidebar) used to pick tip topics close to a related tag.
This commit is contained in:
2026-06-20 18:06:06 +09:00
parent 4e837d1419
commit 234ebba103
23 changed files with 946 additions and 39 deletions
+18 -1
View File
@@ -1,9 +1,13 @@
from fastapi import APIRouter
from fastapi import APIRouter, Depends
import psutil
from pydantic import BaseModel
from sqlalchemy.orm import Session as DBSession
from app.core.scheduler import send_useless_tip, send_weather_laundry_notification
from app.core.tagging import backfill_tags
from app.core.weather_cache import get_latest as get_latest_weather
from app.core.word_memory import get_word_pool_with_counts
from app.db.database import get_db
router = APIRouter(prefix="/api/system", tags=["system"])
@@ -68,3 +72,16 @@ async def test_useless_tip():
async def get_latest_weather_data():
"""直近で取得した明日の天気データを返す(未取得ならnull)"""
return get_latest_weather()
@router.get("/word-pool")
async def get_word_pool():
"""どうでもいいtips生成に使われているワードプールを出現回数順で返す"""
return get_word_pool_with_counts()
@router.post("/tags/backfill")
async def run_tags_backfill(limit: int | None = None, db: DBSession = Depends(get_db)):
"""過去のユーザーメッセージのうち、タグが未生成のものにまとめてタグを付ける"""
count = await backfill_tags(db, limit=limit)
return {"tagged_count": count}