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
+11 -1
View File
@@ -12,8 +12,10 @@ from app.core.config import (
)
from app.core.llm import complete
from app.core.scheduler import send_useless_tip
from app.core.tagging import find_related_tag, generate_tags
from app.core.weather import fetch_tomorrow_weather, judge_laundry
from app.core.weather_cache import set_latest
from app.core.word_memory import record_message
logger = logging.getLogger(__name__)
@@ -61,12 +63,18 @@ async def on_message(message: discord.Message):
if not content:
content = "こんにちは"
record_message(content)
async with message.channel.typing():
try:
if any(keyword in content for keyword in USELESS_TALK_KEYWORDS):
redirect = await _generate_useless_talk_redirect(content)
await message.reply(redirect)
await send_useless_tip()
# 振られた話題のタグを生成し、それに近しい話題からTipsのネタを作る
seed_tags = await generate_tags(content)
related_tag = find_related_tag(seed_tags)
await send_useless_tip(topic_override=related_tag)
return
messages = [{"role": "system", "content": DISCORD_BOT_SYSTEM_PROMPT}]
@@ -78,6 +86,8 @@ async def on_message(message: discord.Message):
messages.append({"role": "user", "content": content})
reply = await complete(messages, model=WEATHER_NOTIFY_MODEL)
if reply:
record_message(reply)
await message.reply(reply or "(応答が空でした)")
except Exception:
logger.exception("Failed to generate reply for Discord mention")