Skip to content

Commit

Permalink
Sync notebooks with the site.
Browse files Browse the repository at this point in the history
Fix formatting.
Add licenses.
Fix buttons.
  • Loading branch information
MarkDaoust committed Dec 13, 2023
1 parent d27248c commit 33a1467
Show file tree
Hide file tree
Showing 20 changed files with 8,770 additions and 1,451 deletions.
998 changes: 998 additions & 0 deletions site/en/docs/semantic_retriever.ipynb

Large diffs are not rendered by default.

2,122 changes: 1,437 additions & 685 deletions site/en/examples/anomaly_detection.ipynb

Large diffs are not rendered by default.

24 changes: 7 additions & 17 deletions site/en/examples/chat_calculator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1,843 changes: 1,629 additions & 214 deletions site/en/examples/clustering_with_embeddings.ipynb

Large diffs are not rendered by default.

809 changes: 712 additions & 97 deletions site/en/examples/doc_search_emb.ipynb

Large diffs are not rendered by default.

26 changes: 8 additions & 18 deletions site/en/examples/text_calculator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
"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.generate_text` method to output the correct answer to a word problem.\n",
"This tutorial shows an example of using an external tool with the `genai.generate_text` 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",
Expand All @@ -93,17 +93,7 @@
"metadata": {
"id": "oq3EYtJYBXpG"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m122.2/122.2 kB\u001b[0m \u001b[31m1.8 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[31m4.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25h"
]
}
],
"outputs": [],
"source": [
"!pip install -q google.generativeai"
]
Expand All @@ -116,14 +106,14 @@
},
"outputs": [],
"source": [
"import google.generativeai as palm\n",
"palm.configure(api_key='YOUR API KEY')\n",
"import google.generativeai as genai\n",
"genai.configure(api_key='YOUR API KEY')\n",
"\n",
"from google.api_core import retry\n",
"\n",
"@retry.Retry()\n",
"def generate_text(*args, **kwargs):\n",
" return palm.generate_text(*args, **kwargs)\n"
" return genai.generate_text(*args, **kwargs)\n"
]
},
{
Expand All @@ -142,7 +132,7 @@
}
],
"source": [
"models = [m for m in palm.list_models() if 'generateText' in m.supported_generation_methods]\n",
"models = [m for m in genai.list_models() if 'generateText' in m.supported_generation_methods]\n",
"model = models[0].name\n",
"print(model)"
]
Expand Down Expand Up @@ -194,7 +184,7 @@
"\n",
"{question}\n",
"\n",
"Work throught it step by step, and show your work.\n",
"Work through it step by step, and show your work.\n",
"One step per line.\n",
"\n",
"Your solution:\n",
Expand Down Expand Up @@ -317,7 +307,7 @@
"\n",
"-------------------\n",
"\n",
"Work throught it step by step, and show your work.\n",
"Work through it step by step, and show your work.\n",
"One step per line.\n",
"\n",
"Your solution:\n",
Expand Down
Loading

0 comments on commit 33a1467

Please sign in to comment.