Add datetime tool to gptbot

Introduced a new 'datetime' tool to the gptbot, which provides the current date and time in UTC. This enhancement caters to the need for time-related queries within the bot's functionality, expanding its utility for users dealing with time-sensitive information.
This commit is contained in:
Kumi 2023-11-29 12:06:58 +01:00
parent e1782d1034
commit eba650188b
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 17 additions and 0 deletions

View file

@ -13,6 +13,7 @@ for tool in [
"imagine", "imagine",
"imagedescription", "imagedescription",
"wikipedia", "wikipedia",
"datetime",
]: ]:
tool_class = getattr(import_module( tool_class = getattr(import_module(
"." + tool, "gptbot.tools"), tool.capitalize()) "." + tool, "gptbot.tools"), tool.capitalize())

View file

@ -0,0 +1,16 @@
from .base import BaseTool
from datetime import datetime
class Datetime(BaseTool):
DESCRIPTION = "Get the current date and time."
PARAMETERS = {
"type": "object",
"properties": {
},
}
async def run(self):
"""Get the current date and time."""
return f"""**Current date and time (UTC)**
{datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")}"""