You're building an app that answers population-related questions. The goal is for the LLM to answer questions like:
What is the current population of Canada?You'd like the LLM to reason step-by-step, fetch real-time population data, and present a concise, well-formatted answer. The user should only see the final result, but your task is to write a prompt that guides the LLM to go through the ReAct process internally. The prompt should instruct the LLM to:
Follow the ReAct approach.
Use only one tool, named
GET_POPULATION, which performs a REST call to:https://api.worldpop.io/v1/population?country=CAThe LLM should figure out the standard ISO Alpha-2 country code, like
"US","IN", or"BR"based on the country name. But in this case, we're only interested in Canada. It returns a JSON response containing the population.Require strict output formatting:
Thought: ... Action: ... Observation: ... Thought: ... Final Answer: The current population of Canada is X.Ensure the final answer:
Uses the country name explicitly (not just the country code).
Formats the number using commas (e.g., 785,000).
Does not include unnecessary information (like source URLs or tool names).
Specify that if an error or unexpected output occurs, the agent should gracefully end with:
Final Answer: Sorry, I couldn't retrieve population data for Canada at the moment.