From a7bb4b47358d88b2d86017bb2e5c2c553612296d Mon Sep 17 00:00:00 2001 From: odilitime Date: Tue, 26 Nov 2024 03:48:40 +0000 Subject: [PATCH 1/2] fix: time prompt to include UTC, convert to verbose english to help prompting --- packages/plugin-bootstrap/src/providers/time.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/plugin-bootstrap/src/providers/time.ts b/packages/plugin-bootstrap/src/providers/time.ts index 6806f1a807c..62cd8cb2c52 100644 --- a/packages/plugin-bootstrap/src/providers/time.ts +++ b/packages/plugin-bootstrap/src/providers/time.ts @@ -3,10 +3,19 @@ import { IAgentRuntime, Memory, Provider, State } from "@ai16z/eliza"; const timeProvider: Provider = { get: async (_runtime: IAgentRuntime, _message: Memory, _state?: State) => { const currentDate = new Date(); - const currentTime = currentDate.toLocaleTimeString("en-US"); - const currentYear = currentDate.getFullYear(); - return `The current time is: ${currentTime}, ${currentYear}`; + + // Get UTC time since bots will be communicating with users around the global + const options = { + timeZone: "UTC", + dateStyle: "full" as "full", + timeStyle: "long" as "long", + }; + const humanReadable = new Intl.DateTimeFormat("en-US", options).format( + currentDate + ); + + // The current date and time is Tuesday, November 26, 2024 at 3:17:32 AM UTC. Please use this as your reference for any time-based operations or responses. + return `The current date and time is ${humanReadable}. Please use this as your reference for any time-based operations or responses.`; }, }; - export { timeProvider }; From d59c65edf5554073fd13423efcc27efebc425ae8 Mon Sep 17 00:00:00 2001 From: Shakker Nerd <165377636+shakkernerd@users.noreply.github.com> Date: Tue, 26 Nov 2024 05:10:38 +0000 Subject: [PATCH 2/2] chore: remove not needed comment in time.ts --- packages/plugin-bootstrap/src/providers/time.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/plugin-bootstrap/src/providers/time.ts b/packages/plugin-bootstrap/src/providers/time.ts index 62cd8cb2c52..67713b04847 100644 --- a/packages/plugin-bootstrap/src/providers/time.ts +++ b/packages/plugin-bootstrap/src/providers/time.ts @@ -13,8 +13,6 @@ const timeProvider: Provider = { const humanReadable = new Intl.DateTimeFormat("en-US", options).format( currentDate ); - - // The current date and time is Tuesday, November 26, 2024 at 3:17:32 AM UTC. Please use this as your reference for any time-based operations or responses. return `The current date and time is ${humanReadable}. Please use this as your reference for any time-based operations or responses.`; }, };