Skip to content

Commit

Permalink
Merge branch 'google:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kyolee415 authored Dec 13, 2023
2 parents 14b57cf + d560fa9 commit 6475319
Show file tree
Hide file tree
Showing 21 changed files with 8,445 additions and 1,493 deletions.
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
4 changes: 4 additions & 0 deletions demos/palm/python/docs-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,10 @@ To launch the Docs Agent chat app, do the following:
already running on port 5000 on your host machine, you can use the `-p` flag to specify
a different port (for example, `poetry run ./chatbot/launch.sh -p 5050`).

**Note**: If this `poetry run ./chatbot/launch.sh` command fails to run, check the `HOSTNAME` environment
variable on your host machine (for example, `echo $HOSTNAME`). If this variable is unset, try setting it to
`localhost` by running `export HOSTNAME=localhost`.

Once the app starts running, this command prints output similar to the following:

```
Expand Down
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\"><img src=\"https://ai.google.dev/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" />View on Generative AI</a>\n",
" </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

0 comments on commit 6475319

Please sign in to comment.