backend: replace LAST_FULL_PROMPT/LAST_CAT_INTERACTION with unified PROMPT_HISTORY deque
- globals.py: add collections.deque(maxlen=10) PROMPT_HISTORY with _prompt_id_counter
- globals.py: add legacy accessor functions _get_last_fallback_prompt() and _get_last_cat_interaction()
- bot.py: append to PROMPT_HISTORY instead of setting LAST_CAT_INTERACTION, remove 500-char truncation, add guild/channel/model fields
- image_handling.py: same pattern for Cat media responses
- llm.py: append fallback prompts to PROMPT_HISTORY with response filled after LLM reply
- routes/core.py: new GET /prompts and GET /prompts/{id} endpoints, legacy /prompt and /prompt/cat use accessor functions
This commit is contained in:
17
bot/bot.py
17
bot/bot.py
@@ -360,15 +360,24 @@ async def on_message(message):
|
||||
if globals.EVIL_MODE:
|
||||
effective_mood = f"EVIL:{getattr(globals, 'EVIL_DM_MOOD', 'evil_neutral')}"
|
||||
logger.info(f"🐱 Cat response for {author_name} (mood: {effective_mood})")
|
||||
# Track Cat interaction for Web UI Last Prompt view
|
||||
# Track Cat interaction in unified prompt history
|
||||
import datetime
|
||||
globals.LAST_CAT_INTERACTION = {
|
||||
globals._prompt_id_counter += 1
|
||||
guild_name = message.guild.name if message.guild else "DM"
|
||||
channel_name = message.channel.name if message.guild else "DM"
|
||||
globals.PROMPT_HISTORY.append({
|
||||
"id": globals._prompt_id_counter,
|
||||
"source": "cat",
|
||||
"full_prompt": cat_full_prompt,
|
||||
"response": response[:500] if response else "",
|
||||
"response": response if response else "",
|
||||
"user": author_name,
|
||||
"mood": effective_mood,
|
||||
"guild": guild_name,
|
||||
"channel": channel_name,
|
||||
"timestamp": datetime.datetime.now().isoformat(),
|
||||
}
|
||||
"model": "Cat LLM",
|
||||
"response_type": response_type,
|
||||
})
|
||||
except Exception as e:
|
||||
logger.warning(f"🐱 Cat pipeline error, falling back to query_llama: {e}")
|
||||
response = None
|
||||
|
||||
Reference in New Issue
Block a user