fix: Enhance author identification logic to utilize cached author strings for improved efficiency

This commit is contained in:
Slipstream 2025-05-30 17:52:30 -06:00
parent c7e15f5581
commit 28960c4c0c
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD

View File

@ -920,6 +920,15 @@ async def get_ai_response(cog: 'GurtCog', message: discord.Message, model_name:
full_text = "\n".join(text_parts).strip()
if full_text: # Only add if there's some text content
author_string_from_cache = msg.get("author_string")
if author_string_from_cache and str(author_string_from_cache).strip():
# If author_string is available and valid from the cache, use it directly.
# This string is expected to be pre-formatted by the context gathering logic.
author_identifier_string = str(author_string_from_cache)
parts.append(types.Part(text=f"{author_identifier_string}: {full_text}"))
else:
# Fallback to reconstructing the author identifier if author_string is not available/valid
author_details = msg.get("author", {})
raw_display_name = author_details.get("display_name")
raw_name = author_details.get("name") # Discord username