Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 🍻 add current date to TRUTH prompt #1042

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion duckbot/cogs/ai/truth.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import os

import anthropic
Expand All @@ -8,6 +9,8 @@

TRUTH_PROMPT = """Objective: Fact-check the following message from {user_name} on our Discord server and format the response for Discord.

For context, today's date is {date}.

Input: "{user_message}"

Instructions:
Expand Down Expand Up @@ -67,7 +70,7 @@ async def truth(self, ctx: commands.Context):
async def fact_check(self, message: discord.Message) -> str:
try:
content = message.content
prompt = TRUTH_PROMPT.format(user_name=message.author.display_name, user_message=content)
prompt = TRUTH_PROMPT.format(user_name=message.author.display_name, user_message=content, date=datetime.datetime.now().strftime("%B %d, %Y"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo it makes more sense to use the timestamp of the original message, or maybe the edited date if it exists.

https://discordpy.readthedocs.io/en/stable/api.html#discord.Message.created_at

This is likely close enough, but we have had situations already where the !truth message comes several hours after the original message.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👆

message = self.ai_client.messages.create(model="claude-3-5-sonnet-20240620", max_tokens=1000, temperature=0, messages=[{"role": "user", "content": [{"type": "text", "text": prompt}]}])
return message.content[0].text
except Exception as e:
Expand Down