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

fix: time prompt to include UTC, convert to verbose english to help prompting #603

Merged
merged 2 commits into from
Nov 26, 2024
Merged
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
15 changes: 11 additions & 4 deletions packages/plugin-bootstrap/src/providers/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ 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
);
return `The current date and time is ${humanReadable}. Please use this as your reference for any time-based operations or responses.`;
},
};

export { timeProvider };