Agents: Custom tool creation: Adding dates

agent = initialize_agent(
tools + [time],
verbose = True)
Query for the agent above which has the custom tool : time from the course: “What will be the date a week from today”
Response: Threw an error : “ValueError: LLMMathChain._evaluate(”
2024-03-07 + 7
“) raised error: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers (, line 1). Please try again with a valid numerical expression”

What does this mean?

I’m not a mentor for that course, but based on the error message, I’d say the chat tool took the hyphens in the date 2024-03-07, and interpreted them as subtraction operators, but it threw an error because it did not like the combination 03 or 07. It seems to not handle leading zeros in number formats.

But how do I improve the custom function so it not only returns the date, but if asked can do date operations?

As I said, I’m not a mentor for that course.

Perhaps you will need to give it some additional prompts that teach it the date format.