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

Add a notebook test script. #187

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@
**/.ipynb_checkpoints
**/venv
**/.python-version
**/*.json
**/*.jpg
**/*.mp3
**/*.mp4
**/*.pdf
**/*.txt
**/*.cpp
**/*.m4a
**/*.png
**/*.md
13 changes: 11 additions & 2 deletions examples/Agents_Function_Calling_Barista_Bot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,17 @@
"from typing import Iterable\n",
"\n",
"import google.generativeai as genai\n",
"from google.api_core import retry\n",
"\n",
"from google.api_core import retry"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "b3eb439fb7a2"
},
"outputs": [],
"source": [
"from google.colab import userdata\n",
"genai.configure(api_key=userdata.get('GOOGLE_API_KEY'))"
]
Expand Down
5 changes: 2 additions & 3 deletions examples/Anomaly_detection_with_embeddings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@
"import google.generativeai as genai\n",
"import google.ai.generativelanguage as glm\n",
"\n",
"# Used to securely store your API key\n",
"from google.colab import userdata\n",
"\n",
"from sklearn.datasets import fetch_20newsgroups\n",
"from sklearn.manifold import TSNE"
]
Expand All @@ -116,6 +113,8 @@
},
"outputs": [],
"source": [
"# Used to securely store your API key\n",
"from google.colab import userdata\n",
"API_KEY=userdata.get('GOOGLE_API_KEY')\n",
"genai.configure(api_key=API_KEY)"
]
Expand Down
2 changes: 1 addition & 1 deletion examples/Apollo_11.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
}
],
"source": [
"!wget https://storage.googleapis.com/generativeai-downloads/data/a11.txt"
"!curl -O https://storage.googleapis.com/generativeai-downloads/data/a11.txt"
]
},
{
Expand Down
5 changes: 2 additions & 3 deletions examples/Classify_text_with_embeddings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@
"import google.generativeai as genai\n",
"import google.ai.generativelanguage as glm\n",
"\n",
"from google.colab import userdata\n",
"\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"\n",
Expand All @@ -120,6 +118,7 @@
},
"outputs": [],
"source": [
"from google.colab import userdata\n",
"API_KEY=userdata.get('GOOGLE_API_KEY')\n",
"genai.configure(api_key=API_KEY)"
]
Expand Down Expand Up @@ -689,7 +688,7 @@
"outputs": [],
"source": [
"def build_classification_model(input_size: int, num_classes: int) -> keras.Model:\n",
" inputs = x = keras.Input(input_size)\n",
" inputs = x = keras.Input([input_size])\n",
" x = layers.Dense(input_size, activation='relu')(x)\n",
" x = layers.Dense(num_classes, activation='sigmoid')(x)\n",
" return keras.Model(inputs=[inputs], outputs=x)"
Expand Down
82 changes: 77 additions & 5 deletions examples/Market_a_Jet_Backpack.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
},
"outputs": [],
"source": [
"from google.colab import userdata\n",
"import google.generativeai as genai\n",
"import PIL.Image\n",
"from IPython.display import display, Image\n",
Expand All @@ -98,8 +97,21 @@
"metadata": {
"id": "mIUxhHbFyZlf"
},
"outputs": [],
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'google.colab'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[35], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mgoogle\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcolab\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m userdata\n\u001b[1;32m 2\u001b[0m GOOGLE_API_KEY\u001b[38;5;241m=\u001b[39muserdata\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mGOOGLE_API_KEY\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 3\u001b[0m genai\u001b[38;5;241m.\u001b[39mconfigure(api_key\u001b[38;5;241m=\u001b[39mGOOGLE_API_KEY)\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'google.colab'"
]
}
],
"source": [
"from google.colab import userdata\n",
"GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n",
"genai.configure(api_key=GOOGLE_API_KEY)"
]
Expand Down Expand Up @@ -245,7 +257,8 @@
},
"outputs": [],
"source": [
"response = model.generate_content([analyzePrompt, img])"
"json_config=genai.GenerationConfig(response_mime_type=\"application/json\")\n",
"response = model.generate_content([analyzePrompt, img], generation_config=json_config)"
]
},
{
Expand Down Expand Up @@ -308,7 +321,7 @@
"to return a valid array in the format described above, and no other text.\n",
"The most important thing is that you stick to the array format.\"\"\"\n",
"\n",
"response = model.generate_content([namePrompt, img])\n",
"response = model.generate_content([namePrompt, img], generation_config=json_config)\n",
"\n",
"names = eval(response.text)\n",
"# Create a Dropdown widget to choose a name from the\n",
Expand Down Expand Up @@ -379,7 +392,7 @@
},
"outputs": [],
"source": [
"copyResponse = model.generate_content([websiteCopyPrompt, img])"
"copyResponse = model.generate_content([websiteCopyPrompt, img], generation_config=json_config)"
]
},
{
Expand Down Expand Up @@ -518,6 +531,65 @@
"response = model.generate_content([htmlPrompt])\n",
"print(response.text)"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {
"id": "4bd0452be139"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"<!DOCTYPE html>\n",
"<html>\n",
"<head>\n",
" <meta charset=\"utf-8\">\n",
" <title>Nimbus</title>\n",
" <style>\n",
" body {\n",
" margin: 0;\n",
" padding: 0;\n",
" font-family: sans-serif;\n",
" background-color: #000;\n",
" color: #fff;\n",
" text-align: center;\n",
" }\n",
"\n",
" h1 {\n",
" font-size: 3em;\n",
" margin-top: 0;\n",
" padding-top: 20vh;\n",
" }\n",
"\n",
" h2 {\n",
" font-size: 1.5em;\n",
" margin-bottom: 30vh;\n",
" }\n",
" </style>\n",
"</head>\n",
"<body>\n",
" <h1>Reach new heights</h1>\n",
" <h2>With Nimbus, the sky's the limit. Explore new heights and see the world from a whole new perspective.</h2>\n",
"</body>\n",
"</html>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from IPython.display import HTML\n",
"\n",
"HTML(response.text.removeprefix('```html').strip('`'))"
]
}
],
"metadata": {
Expand Down
Loading
Loading