3434
3535
3636def lookup_weather (city_name = None , zip_code = None ):
37- """Lookup the weather for a given city name or zip code ."""
38- print (f"Looking up weather for { city_name or zip_code } ..." )
39- return "It's sunny !"
37+ """Buscar el clima para un nombre de ciudad o código postal dado ."""
38+ print (f"Buscando el clima para { city_name or zip_code } ..." )
39+ return "¡Está soleado !"
4040
4141
4242tools = [
4343 {
4444 "type" : "function" ,
4545 "function" : {
4646 "name" : "lookup_weather" ,
47- "description" : "Lookup the weather for a given city name or zip code ." ,
47+ "description" : "Buscar el clima para un nombre de ciudad o código postal dado ." ,
4848 "parameters" : {
4949 "type" : "object" ,
5050 "properties" : {
5151 "city_name" : {
5252 "type" : "string" ,
53- "description" : "The city name " ,
53+ "description" : "El nombre de la ciudad " ,
5454 },
5555 "zip_code" : {
5656 "type" : "string" ,
57- "description" : "The zip code " ,
57+ "description" : "El código postal " ,
5858 },
5959 },
6060 "strict" : True ,
@@ -67,18 +67,18 @@ def lookup_weather(city_name=None, zip_code=None):
6767response = client .chat .completions .create (
6868 model = MODEL_NAME ,
6969 messages = [
70- {"role" : "system" , "content" : "You are a weather chatbot ." },
71- {"role" : "user" , "content" : "is it sunny in that small city near sydney where anthony lives ?" },
70+ {"role" : "system" , "content" : "Eres un chatbot del clima ." },
71+ {"role" : "user" , "content" : "¿está soleado en esa pequeña ciudad cerca de Sydney donde vive Anthony ?" },
7272 ],
7373 tools = tools ,
7474 tool_choice = "auto" ,
7575)
7676
77- print (f"Response from { API_HOST } : \n " )
77+ print (f"Respuesta de { API_HOST } : \n " )
7878print (response .choices [0 ].message .tool_calls [0 ].function .name )
7979print (response .choices [0 ].message .tool_calls [0 ].function .arguments )
8080
81- # Now actually call the function as indicated
81+
8282if response .choices [0 ].message .tool_calls :
8383 function_name = response .choices [0 ].message .tool_calls [0 ].function .name
8484 arguments = json .loads (response .choices [0 ].message .tool_calls [0 ].function .arguments )
0 commit comments