From eba650188b60c6f1740c5ab11a34122927a99f2f Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 29 Nov 2023 12:06:58 +0100 Subject: [PATCH] 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. --- src/gptbot/tools/__init__.py | 1 + src/gptbot/tools/datetime.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/gptbot/tools/datetime.py diff --git a/src/gptbot/tools/__init__.py b/src/gptbot/tools/__init__.py index 8ade706..747e502 100644 --- a/src/gptbot/tools/__init__.py +++ b/src/gptbot/tools/__init__.py @@ -13,6 +13,7 @@ for tool in [ "imagine", "imagedescription", "wikipedia", + "datetime", ]: tool_class = getattr(import_module( "." + tool, "gptbot.tools"), tool.capitalize()) diff --git a/src/gptbot/tools/datetime.py b/src/gptbot/tools/datetime.py new file mode 100644 index 0000000..5d00305 --- /dev/null +++ b/src/gptbot/tools/datetime.py @@ -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")}""" \ No newline at end of file