This app demonstrates the power of Gemini's Function Calling capabilities, enabling users to query and understand their BigQuery databases using natural language. Forget complex SQL syntax – interact with your data conversationally.
Function Calling in Gemini lets developers create a description of a function in their code, then pass that description to a language model in a request. The response from the model includes the name of a function that matches the description and the arguments to call it with.
- A Google Cloud project with billing enabled
- A BigQuery dataset (we used the
thelook_ecommerce
public dataset) - APIs for Vertex AI, BigQuery, and Cloud Run enabled
- Familiarity with Python and SQL concepts
After you've tried out the live demo app, you can also run your own version of the SQL Talk app and make changes to the live app using the Cloud Shell Editor in your own Google Cloud project.
Open this repository and the sample app in the Cloud Shell Editor, then follow the steps displayed in the tutorial in the sidebar.
You can learn more about Function Calling in Gemini with these guides and resources:
- Documentation on Function Calling in Gemini
- Codelab on How to Interact with APIs Using Function Calling in Gemini
- Sample notebook for Function Calling with the Gemini API
When deploying this app to Cloud Run, a best practice is to create a service account to attach the following roles to, which are the permissions required for the app to read data from BigQuery, run BigQuery jobs, and use resources in Vertex AI:
- BigQuery Data Viewer (
roles/bigquery.dataViewer
) - BigQuery Job User (
roles/bigquery.jobUser
) - Vertex AI User (
roles/aiplatform.user
)
To deploy this app to
Cloud Run, run the
following command to have the app built with Cloud Build and deployed to Cloud
Run, replacing the service-account
and project
values with your own values,
similar to:
gcloud run deploy sql-talk --allow-unauthenticated --region us-central1 --service-account SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com --source .
Congratulations, you've successfully deployed the SQL Talk demo app!