Challenge 2: What’s the date?

Previous Challenge Next Challenge

Introduction

Large Language Models (LLMs) are incredibly capable, but they are limited to the data they were trained on, meaning they don’t have access to real-time information or the ability to execute actions. To overcome this, agents use Tools.

Tools are basically external interfaces (functions, APIs, or scripts) that the agent can invoke dynamically when it needs real-time context. To see this in action, you will write a custom Python function to get the current date, allowing the agent to handle references such as last month, last quarter based on current date.

Description

At the moment if our users would ask our agent the current date, it would emit a date from the past. In order to make our agent aware of the current date, we’ll introduce a new function tool that dynamically calculates and returns the current date.

Create a new Python function get_current_date that returns the current date in YYYY-MM-DD format. Add a docstring to that function explaining what it returns and in which format. Make that function available as a tool to the agent.

Commit and push your changes to the Git repository when you’re done.

Success Criteria

  • When you ask the agent what the current date is, it returns today’s date (it’s okay if the UI shows it formatted differently, but the tool output should be the correct format).
  • All the changes are committed and pushed to the Git repository.

Tips

  • The ADK web UI lets you inspect every step, you can hover over the steps and see the details.

Learning Resources

Previous Challenge Next Challenge