You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This error appears when the BigQuery dataset contains multiple tables, basically because there is one part response for each table, leading to having more function parts in the response that in the function call definition.
I tested replacing the get_table function for a get_tables that handles several tables. I think I had a different code base, but Im sharing what I did as a sample
get_table_func=FunctionDeclaration(
name="get_tables",
description="Obtiene información sobre las tablas, incluida la descripción, el esquema y la cantidad de filas que ayudarán a responder la pregunta del usuario. Utilice siempre el nombre completo del conjunto de datos y de las tablas.",
parameters={
"type": "object",
"properties": {
"tables": {
"type": "array",
"description": "List of tables with informatioin in BQ",
"items": {
"type": "object",
"properties": {
"table_id": {
"type": "string",
"description": "ID del Dataset del que se recuperarán las tablas",
},
"description": {
"type": "string",
"description": "Description of the table",
}
},
"required": [
"table_id",
],
}
}
}
},
)
And the function implementation
ifresponse.function_call.name=="get_tables":
api_responses= []
processed_tables=None#Handles all tables in an arrayfortableinparams["tables"]: # repeat for each tabletable_id=table["table_id"]
ftable_id=f"{BIGQUERY_PROJECT_ID}.{BIGQUERY_DATASET_ID}.{table_id}"api_response=client.get_table(ftable_id)
api_response=api_response.to_api_repr()
api_responses.append(api_response)
ifprocessed_tablesisNone:
processed_tables= [
str([
str(api_response.get("description", "")),
str(
[
column["name"] +":"+column.get("description", "No description")
forcolumninapi_response["schema"]["fields"]
if"description"incolumn
]
)
])
]
else:
try:
processed_tables.append(
str([
str(api_response.get("description", "")),
str(
[
column["name"] +":"+column.get("description", "No description")
forcolumninapi_response["schema"]["fields"]
if"description"incolumn
]
)
])
)
exceptExceptionase:
print(e)
# Return all tables in the function responseapi_requests_and_responses.append(
[
response.function_call.name,
params,
str( processed_tables )
]
)
api_response=api_responsesapi_response=str( api_response)
Relevant log output
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Do you have an example of a input prompt that causes the sample app to error out like this with parallel function calls? Since the sample app uses the thelook_ecommerce sample data with multiple tables, I'd like to see if this is something we can fix with function calling modes or simpler logic so that we can keep this tutorial app as simple as possible.
File Name
gemini/function-calling/sql-talk-app/app.py
What happened?
This error appears when the BigQuery dataset contains multiple tables, basically because there is one part response for each table, leading to having more function parts in the response that in the function call definition.
I tested replacing the get_table function for a get_tables that handles several tables. I think I had a different code base, but Im sharing what I did as a sample
And the function implementation
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: