๐งชTDD Challengeยทintermediateยทโฑ๏ธ 35โ55mยทโญ 250 XP
M-018Function Calling Weather Bot
Description
Nebula Corp is building a weather assistant that needs to call external APIs based on user queries. When a user asks 'What's the weather in Seattle?', the system should extract the location and call get_weather(location). When they ask 'Will it rain tomorrow in Portland?', it should call get_forecast(location, days=1). The current implementation doesn't structure the function calls properly โ it returns free text instead of structured function call requests. Build a prompt that instructs the model to respond with valid function call JSON when weather information is requested.
Test Cases (7)
Lists available functions
Must list the available functions so the model knows what tools exist
Input:buildFunctionCallingPrompt("What's the weather in Boston?", [{name: 'get_weather', params: ['location'], description: 'Current weather'}])
Expected:CONTAINS:get_weather
Specifies JSON response format
Must specify that the response should be JSON with function and parameters
Input:buildFunctionCallingPrompt("Weather in NYC?", [{name: 'get_weather', params: ['location'], description: 'Current weather'}])
Expected:CONTAINS_ALL:function,parameters,JSON
Includes function descriptions
Should include function descriptions to help the model choose correctly
Input:buildFunctionCallingPrompt("Forecast for Seattle?", [{name: 'get_forecast', params: ['location', 'days'], description: 'Get forecast'}])
Expected:CONTAINS:Get forecast
Instructs parameter extraction
Must instruct the model to extract parameters from the user query
Input:buildFunctionCallingPrompt("Will it rain tomorrow in Portland?", [{name: 'get_forecast', params: ['location', 'days'], description: 'Forecast'}])
Expected:CONTAINS_ANY:extract,location,parameters
Includes the user query
The prompt must include the actual user query to analyze
Input:buildFunctionCallingPrompt("What's the temperature in Miami?", [{name: 'get_weather', params: ['location'], description: 'Current weather'}])
Expected:CONTAINS:What's the temperature in Miami?
Constrains output to JSON only
Should explicitly constrain output to JSON only, no extra text
Input:buildFunctionCallingPrompt("Chicago weather?", [{name: 'get_weather', params: ['location'], description: 'Current weather'}])
Expected:CONTAINS_ANY:ONLY with,only the JSON,no other text,no explanation,no markdown
Provides function selection logic
Should provide logic for choosing between functions based on query content
Input:buildFunctionCallingPrompt("Tomorrow's weather?", [{name: 'get_weather', params: ['location'], description: 'Current'}, {name: 'get_forecast', params: ['location', 'days'], description: 'Forecast'}])
Expected:CONTAINS_ANY:get_forecast if,Use get_forecast,forecast for future,tomorrow
Related Lessons
Click Run / Check to validate your solution