generative-ai-python icon indicating copy to clipboard operation
generative-ai-python copied to clipboard

Function calling agent rises 500 (internal server error) for some questions and working for some other question (slight difference only in text)

Open VijayKumarMaddu opened this issue 1 year ago • 1 comments

Description of the bug:

The only difference between 2 curl requests is: text part. i.e, for 1st curl request, the text is : what is the count of mi tanks in srikakulam,visakhapatnam . for 2nd curl request, the text is : what is the count of mi tanks in vizianagaram,srikakulam.

when i send a curl request like below, it is giving answer.

  1. `curl --location 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=AIzaSyCtHKOsVS1QiTVDFONbzW0sla7Qz1tMI5A%0A'
    --header 'Content-Type: application/json'
    --data '{ "contents": { "role": "user", "parts": { "text": "what is the count of mi tanks in srikakulam,visakhapatnam" } }, "tools": [ { "function_declarations": [ { "name": "fetch_reservoir_data", "description": "Fetch data for reservoirs, barrages, projects, or dams, including inflow, outflow, etc., for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." }, "unit": { "type": "string", "description": "Unit for data, e.g., tmc (thousand million cubic feet), meters, cusecs (cubic feet per second), cumecs (cubic meters per second)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } }, { "name": "fetch_wc_data", "description": "Fetch water structures data for farm ponds, percolation tanks, check dams, etc., for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } }, { "name": "fetch_soil_moisture_data", "description": "Fetch soil moisture data for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } }, { "name": "fetch_ground_water_data", "description": "Fetch groundwater data for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } }, { "name": "fetch_river_guage_data", "description": "Fetch river gauge data for a specified location.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." } }, "required": [ "location_name" ] } }, { "name": "fetch_mi_tanks_data", "description": "Fetch minor irrigation tanks data for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } }, { "name": "fetch_rainfall_data", "description": "Fetch rainfall data for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } } ] }

] }'`

The response is: { "candidates": [ { "content": { "parts": [ { "functionCall": { "name": "fetch_mi_tanks_data", "args": { "end_date": "20220331", "location_name": [ "srikakulam", "visakhapatnam" ], "format": "yearly", "start_date": "20190401" } } } ], "role": "model" }, "finishReason": "STOP", "index": 0, "safetyRatings": [ { "category": "HARM_CATEGORY_HATE_SPEECH", "probability": "NEGLIGIBLE" }, { "category": "HARM_CATEGORY_HARASSMENT", "probability": "NEGLIGIBLE" }, { "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "probability": "NEGLIGIBLE" }, { "category": "HARM_CATEGORY_DANGEROUS_CONTENT", "probability": "NEGLIGIBLE" } ] } ], "usageMetadata": { "promptTokenCount": 1207, "candidatesTokenCount": 63, "totalTokenCount": 1270 } }

when i send a curl request like below, it is not giving answer.(rising 500 error)

`curl --location 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=AIzaSyCtHKOsVS1QiTVDFONbzW0sla7Qz1tMI5A%0A'
--header 'Content-Type: application/json'
--data '{ "contents": { "role": "user", "parts": { "text": "what is the count of mi tanks in vizianagaram,srikakulam" } }, "tools": [ { "function_declarations": [ { "name": "fetch_reservoir_data", "description": "Fetch data for reservoirs, barrages, projects, or dams, including inflow, outflow, etc., for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." }, "unit": { "type": "string", "description": "Unit for data, e.g., tmc (thousand million cubic feet), meters, cusecs (cubic feet per second), cumecs (cubic meters per second)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } }, { "name": "fetch_wc_data", "description": "Fetch water structures data for farm ponds, percolation tanks, check dams, etc., for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } }, { "name": "fetch_soil_moisture_data", "description": "Fetch soil moisture data for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } }, { "name": "fetch_ground_water_data", "description": "Fetch groundwater data for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } }, { "name": "fetch_river_guage_data", "description": "Fetch river gauge data for a specified location.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." } }, "required": [ "location_name" ] } }, { "name": "fetch_mi_tanks_data", "description": "Fetch minor irrigation tanks data for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } }, { "name": "fetch_rainfall_data", "description": "Fetch rainfall data for a specified location and date range.", "parameters": { "type": "object", "properties": { "location_name": { "type": "array", "items": { "type": "string" }, "description": "Location names for each component, excluding mandal, village, and district words." }, "start_date": { "type": "string", "description": "Start date in YYYYMMDD format. Omit day for month queries and month for year queries." }, "end_date": { "type": "string", "description": "End date in YYYYMMDD format. Omit day for month queries and month for year queries. If not provided, start date is used." }, "format": { "type": "string", "description": "Date format: daily, monthly (month-wise data), or yearly (year-wise data)." } }, "required": [ "location_name", "start_date", "end_date", "format" ] } } ] }

] }'`

The Response is :

{ "error": { "code": 500, "message": "An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting", "status": "INTERNAL" } }

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

VijayKumarMaddu avatar Sep 04 '24 11:09 VijayKumarMaddu

@MarkDaoust I was able to reproduce the issue on Colab. I have tried changing the models, but the issue remains persistent. Combining these two city names, Vizianagaram and Srikakulam, always results in an internal server error. Please find the gist here for reference. Thanks!

Gunand3043 avatar Sep 10 '24 08:09 Gunand3043

Trying again, this seems to be fixed int he API.

MarkDaoust avatar Feb 19 '25 14:02 MarkDaoust