1. Learn
  2. /
  3. Courses
  4. /
  5. Designing Agentic Systems with LangChain

Connected

Exercise

Build a tool that invokes the LLM

The school administration loves your work on the education app with the Wikipedia search agent. They would love you to expand the app even further with some additional tools. Here, you'll build a tool called historical_events() that's able to invoke the LLM within the body of the tool to answer questions about famous dates in history. The Wikipedia tool has already been set up for you and the llm is available in your environment.

Instructions

100 XP
  • Add a decorator to label the tool and set the input format to string.
  • Within the try block, use the .invoke() method with the llm to query the LLM with the date_input to generate historical events.
  • Return the content of the LLM's response using .content.
  • Add an Exception block as e to catch errors and format the error message to include the error details.