Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync notebooks with the site. #184

Merged
merged 3 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
python3 -m tensorflow_docs.tools.nblint \
--styles=google,tensorflow \
--arg=repo:google/generative-ai-docs --arg=branch:main \
--arg=base_url:https://developers.generativeai.google/ \
--arg=base_url:https://ai.google.dev/ \
--exclude_lint=tensorflow::button_download \
"${changed_notebooks[@]}"
fi
998 changes: 998 additions & 0 deletions site/en/docs/semantic_retriever.ipynb

Large diffs are not rendered by default.

2,126 changes: 1,439 additions & 687 deletions site/en/examples/anomaly_detection.ipynb

Large diffs are not rendered by default.

26 changes: 8 additions & 18 deletions site/en/examples/chat_calculator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"source": [
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://developers.generativeai.google/examples/chat_calculator\"><img src=\"https://developers.generativeai.google/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" />View on Generative AI</a>\n",
" <a target=\"_blank\" href=\"https://ai.google.dev/examples/chat_calculator.ipynb\"><img src=\"https://developers.generativeai.google/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" />View on Generative AI</a>\n",
MarkDaoust marked this conversation as resolved.
Show resolved Hide resolved
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/google/generative-ai-docs/blob/main/site/en/examples/chat_calculator.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
Expand All @@ -66,15 +66,15 @@
},
"source": [
"For some use cases, you may want to stop the generation from a model to insert specific results. For example, language models may have trouble with complicated arithmetic problems like word problems.\n",
"This tutorial shows an example of using an external tool with the `palm.chat` method to output the correct answer to a word problem.\n",
"This tutorial shows an example of using an external tool with the `genai.chat` method to output the correct answer to a word problem.\n",
"\n",
"This particular example uses the [`numexpr`](https://github.com/pydata/numexpr) tool to perform the arithmetic but you can use this same procedure to integrate other tools specific to your use case. The following is an outline of the steps:\n",
"\n",
"1. Determine a `start` and `end` tag to demarcate the text to send the tool.\n",
"1. Create a prompt instructing the model how to use the tags in its response.\n",
"1. From the model response, take the text between the `start` and `end` tags as input to the tool.\n",
"1. Drop everything after the `end` tag.\n",
"1. Run the tool and add it's output as your reply.\n",
"1. Run the tool and add its output as your reply.\n",
"1. The model will take into account the tools's output in its reply."
]
},
Expand All @@ -84,17 +84,7 @@
"metadata": {
"id": "v8d0FtO2KJ3O"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m122.2/122.2 kB\u001b[0m \u001b[31m2.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m113.3/113.3 kB\u001b[0m \u001b[31m5.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25h"
]
}
],
"outputs": [],
"source": [
"pip install -q google.generativeai"
]
Expand Down Expand Up @@ -122,7 +112,7 @@
"\n",
"@retry.Retry()\n",
"def retry_chat(**kwargs):\n",
" return palm.chat(**kwargs)\n",
" return genai.chat(**kwargs)\n",
"\n",
"@retry.Retry()\n",
"def retry_reply(self, arg):\n",
Expand All @@ -137,8 +127,8 @@
},
"outputs": [],
"source": [
"import google.generativeai as palm\n",
"palm.configure(api_key=\"YOUR API KEY\")"
"import google.generativeai as genai\n",
"genai.configure(api_key=\"YOUR API KEY\")"
]
},
{
Expand All @@ -149,7 +139,7 @@
},
"outputs": [],
"source": [
"models = [m for m in palm.list_models() if 'generateMessage' in m.supported_generation_methods]\n",
"models = [m for m in genai.list_models() if 'generateMessage' in m.supported_generation_methods]\n",
"model = models[0].name\n",
"print(model)"
]
Expand Down
Loading
Loading