Skip to content

Commit

Permalink
docs: Update introductory text and list of objectives in Intro to Fun…
Browse files Browse the repository at this point in the history
…ction Calling notebook (GoogleCloudPlatform#1010)

# Description

This PR updates the introductory text and list of objectives in the
Intro to Function Calling notebook.

- [X] Follow the [`CONTRIBUTING`
Guide](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/CONTRIBUTING.md).
- [X] You are listed as the author in your notebook or README file.
- [X] Your account is listed in
[`CODEOWNERS`](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/.github/CODEOWNERS)
for the file(s).
- [X] Make your Pull Request title in the
<https://www.conventionalcommits.org/> specification.
- [X] Ensure the tests and linter pass (Run `nox -s format` from the
repository root to format).
- [X] Appropriate docs were updated (if necessary)

Fixes GoogleCloudPlatform#1004.

Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com>
  • Loading branch information
koverholt and holtskinner authored Aug 30, 2024
1 parent 84ab588 commit b724be2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gemini/function-calling/intro_function_calling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@
"\n",
"### Why function calling?\n",
"\n",
"When working with generative text models, it can be difficult to coerce generative models to give consistent outputs in a structured format such as JSON. Function Calling in Gemini allows you to overcome this limitation by forcing the model to output structured data in the format and schema that you define.\n",
"Imagine asking someone to write down important information without giving them a form or any guidelines on the structure. You might get a beautifully crafted paragraph, but extracting specific details like names, dates, or numbers would be tedious! Similarly, trying to get consistent structured data from a generative text model without function calling can be frustrating. You're stuck explicitly prompting for things like JSON output, often with inconsistent and frustrating results.\n",
"\n",
"You can think of Function Calling as a way to get structured output from user prompts and function definitions, use that structured output to make an API request to an external system, then return the function response to the generative model so that it can generate a natural language summary. In other words, function calling in Gemini helps you go from unstructured text in prompt, to a structured data object, and back to natural language again."
"This is where Gemini Function Calling comes in. Instead of hoping for the best in a freeform text response from a generative model, you can define clear functions with specific parameters and data types. These function declarations act as structured guidelines, guiding the Gemini model to structure its output in a predictable and usable way. No more parsing text responses for important information!\n",
"\n",
"Think of it like teaching Gemini to speak the language of your applications. Need to retrieve information from a database? Define a `search_db` function with parameters for search terms. Want to integrate with a weather API? Create a `get_weather` function that takes a location as input. Function calling bridges the gap between human language and the structured data needed to interact with external systems."
]
},
{
Expand All @@ -102,9 +104,9 @@
"\n",
"- Install the Vertex AI SDK for Python\n",
"- Use the Vertex AI Gemini API to interact with the Gemini 1.5 Pro (`gemini-1.5-pro`) model:\n",
" - Generate function calls from a text prompt to get the weather for a given location\n",
" - Generate function calls from a text prompt and call an external API to geocode addresses\n",
" - Generate function calls from a chat prompt to help retail users"
"- Use Function Calling in a chat session to answer user's questions about products in the Google Store\n",
"- Use Function Calling to geocode addresses with a maps API\n",
"- Use Function Calling for entity extraction on raw logging data"
]
},
{
Expand Down

0 comments on commit b724be2

Please sign in to comment.