Skip to content

Commit

Permalink
Merge branch 'main' into text_classification
Browse files Browse the repository at this point in the history
  • Loading branch information
shilpakancharla authored Jun 11, 2024
2 parents 44ca151 + d21f205 commit e77e0a3
Show file tree
Hide file tree
Showing 39 changed files with 4,790 additions and 5,059 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,23 @@ The Gemini API gives you access to Gemini [models](https://ai.google.dev/models/
3. [Create](https://aistudio.google.com/app/apikey) an API key.
4. Use a [quickstart](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Prompting.ipynb) for Python, or call the REST API [using curl](https://github.com/google-gemini/cookbook/blob/main/quickstarts/rest/Prompting_REST.ipynb).

### Capabilities
Learn about the capabilities of the Gemini API by checking out the quickstarts for [safety](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Safety.ipynb), [embeddings](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Embeddings.ipynb), [function calling](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Function_calling.ipynb), [audio](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Audio.ipynb), and more.
## Table of contents
Learn about the capabilities of the Gemini API by checking out these quickstart tutorials.
* [Authentication](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Authentication.ipynb): Start here to learn how you can set up your API key so you can get access to the Gemini API.
* [Counting Tokens](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Counting_Tokens.ipynb) Tokens are the basic inputs to the Gemini models. Through this notebook, you will gain a better understanding of tokens through an interactive experience.
* [Files](https://github.com/google-gemini/cookbook/blob/main/quickstarts/File_API.ipynb): Use the Gemini API to upload files (text, code, images, audio, video) and write prompts using them.
* [Audio](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Audio.ipynb): Learn how to use the Gemini API with audio files.
* [JSON mode](https://github.com/google-gemini/cookbook/blob/main/quickstarts/JSON_mode.ipynb): Discover how to use JSON mode.
* [Function Calling](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Function_calling.ipynb): The Gemini API works great with code. Use this quickstart to learn how to write prompts to understand and call functions. Then check out the [function calling config](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Function_calling_config.ipynb) tutorial to learn more.
* [System Instructions](https://github.com/google-gemini/cookbook/blob/main/quickstarts/System_instructions.ipynb): Give models additional context on how to respond by setting system instructions.
* [Embeddings](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Embeddings.ipynb): Create high quality and task-specific embeddings.
* [Tuning](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Tuning.ipynb): Learn how to improve model performance on a specific task through tuning.

You can find lots more in the [quickstarts folder](https://github.com/google-gemini/cookbook/tree/main/quickstarts), and check out the [examples folder](https://github.com/google-gemini/cookbook/tree/main/examples) for fun examples.

## Official SDKs
The Gemini API is a REST API. You can call the API using a command line tool like `curl` , or by using one of our official SDKs:
* [Python](https://github.com/google/generative-ai-python)
The Gemini API is a REST API. You can call the API using a command line tool like `curl` (and you can find REST examples [here](https://github.com/google-gemini/cookbook/tree/main/quickstarts/rest)) , or by using one of our official SDKs:
* [Python](https://github.com/google/generative-ai-python) - Note: all the notebooks in this cookbook install the Python SDK for you.
* [Node.js](https://github.com/google/generative-ai-js)
* [Dart (Flutter)](https://github.com/google/generative-ai-dart)
* [Android](https://github.com/google/generative-ai-android)
Expand Down
91 changes: 66 additions & 25 deletions examples/Agents_Function_Calling_Barista_Bot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {
"id": "3IzLYKxmTHd5"
},
Expand All @@ -79,7 +79,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {
"id": "0gOuwcCUTNAO"
},
Expand Down Expand Up @@ -112,7 +112,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 2,
"metadata": {
"id": "wMltPyUpTu3h"
},
Expand Down Expand Up @@ -191,7 +191,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 3,
"metadata": {
"id": "jg1LjYNUWnsC"
},
Expand All @@ -204,8 +204,14 @@
" Latte\n",
" - Extra shot\n",
" Tea\n",
" - Earl Grey, hot\n",
"Is this correct? yes it is!\n"
" - Earl Grey, hot\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"Is this correct? yes\n"
]
}
],
Expand Down Expand Up @@ -237,7 +243,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 4,
"metadata": {
"id": "IoBvZ1JYXgn5"
},
Expand Down Expand Up @@ -296,7 +302,7 @@
"\"Regular milk\" is the same as 'whole milk'.\n",
"\"Sweetened\" means add some regular sugar, not a sweetener.\n",
"\n",
"We have run out of Soy milk today, so soy is not available.\n",
"Soy milk has run out of stock today, so soy is not available.\n",
"\"\"\""
]
},
Expand All @@ -317,7 +323,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 5,
"metadata": {
"id": "8vmtzAlPaQH-"
},
Expand All @@ -328,7 +334,7 @@
"# Toggle this to switch between Gemini 1.5 with a system instruction, or Gemini 1.0 Pro.\n",
"use_sys_inst = False\n",
"\n",
"model_name = 'gemini-1.5-pro-latest' if use_sys_inst else 'gemini-1.0-pro-latest'\n",
"model_name = 'gemini-1.5-flash' if use_sys_inst else 'gemini-1.0-pro'\n",
"\n",
"if use_sys_inst:\n",
" model = genai.GenerativeModel(\n",
Expand Down Expand Up @@ -371,7 +377,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 6,
"metadata": {
"id": "38SAyrNNVhvE"
},
Expand All @@ -382,14 +388,20 @@
"text": [
"Welcome to Barista bot!\n",
"\n",
"\n",
"> Tea, Earl Grey, Hot.\n"
"\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"> I would like a capuccino with almond milk\n"
]
},
{
"data": {
"text/markdown": [
"OK, I have added an Earl Grey tea, hot, to your order."
"I have added a Cappuccino with Almond Milk to your order."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
Expand All @@ -399,16 +411,16 @@
"output_type": "display_data"
},
{
"name": "stdout",
"name": "stdin",
"output_type": "stream",
"text": [
"> and a strong latte please\n"
"> do you have stone milk?\n"
]
},
{
"data": {
"text/markdown": [
"OK, and I have added a latte with double espresso to your order."
"I'm sorry, we do not have Stone Milk on the menu. Would you like any other type of milk with your cappuccino?"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
Expand All @@ -417,23 +429,52 @@
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"> no, that's all\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"> great, that's all thanks\n",
"Your order:\n",
" Earl Grey\n",
" - Hot\n",
" Latte\n",
" - Double\n",
"Is this correct? make it so!\n"
" Cappuccino\n",
" - Almond Milk\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"Is this correct? yes\n"
]
},
{
"data": {
"text/markdown": [
"Ok, I will place the order now."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"> thanks\n"
]
},
{
"data": {
"text/markdown": [
"Your order is confirmed, and it will be ready in about 4 minutes."
"Your order will be ready in about 10 minutes."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
Expand All @@ -452,7 +493,7 @@
"[barista bot session over]\n",
"\n",
"Your order:\n",
" [('Earl Grey', ['Hot']), ('Latte', ['Double'])]\n",
" [('Cappuccino', ['Almond Milk'])]\n",
"\n",
"- Thanks for using Barista Bot!\n"
]
Expand Down
Loading

0 comments on commit e77e0a3

Please sign in to comment.