diff --git a/examples/gemini/python/langchain/Gemini_LangChain_QA_Chroma_WebLoad.ipynb b/examples/gemini/python/langchain/Gemini_LangChain_QA_Chroma_WebLoad.ipynb index 6d2342a40..93d146b34 100644 --- a/examples/gemini/python/langchain/Gemini_LangChain_QA_Chroma_WebLoad.ipynb +++ b/examples/gemini/python/langchain/Gemini_LangChain_QA_Chroma_WebLoad.ipynb @@ -109,7 +109,7 @@ } ], "source": [ - "!pip install --quiet langchain" + "!pip install --quiet langchain langchain-community" ] }, { @@ -221,10 +221,10 @@ ], "source": [ "# Run this cell and paste the API key in the prompt\n", - "import os\n", - "import getpass\n", + "from google.colab import userdata\n", + "GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n", "\n", - "os.environ['GOOGLE_API_KEY'] = getpass.getpass('Gemini API Key:')" + "genai.configure(api_key=GOOGLE_API_KEY)" ] }, { diff --git a/examples/gemini/python/langchain/Gemini_LangChain_QA_Pinecone_WebLoad.ipynb b/examples/gemini/python/langchain/Gemini_LangChain_QA_Pinecone_WebLoad.ipynb index f7ba368e5..2bbcaacf9 100644 --- a/examples/gemini/python/langchain/Gemini_LangChain_QA_Pinecone_WebLoad.ipynb +++ b/examples/gemini/python/langchain/Gemini_LangChain_QA_Pinecone_WebLoad.ipynb @@ -110,7 +110,7 @@ } ], "source": [ - "!pip install --quiet langchain" + "!pip install --quiet langchain langchain-community" ] }, { @@ -153,7 +153,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/211.0 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m\u001b[90m━━━\u001b[0m \u001b[32m194.6/211.0 kB\u001b[0m \u001b[31m5.7 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m211.0/211.0 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/211.0 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r", + "\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m\u001b[90m━━━\u001b[0m \u001b[32m194.6/211.0 kB\u001b[0m \u001b[31m5.7 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m211.0/211.0 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25h" ] } @@ -182,7 +184,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/201.4 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m\u001b[90m━\u001b[0m \u001b[32m194.6/201.4 kB\u001b[0m \u001b[31m5.7 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m201.4/201.4 kB\u001b[0m \u001b[31m4.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/201.4 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r", + "\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m\u001b[90m━\u001b[0m \u001b[32m194.6/201.4 kB\u001b[0m \u001b[31m5.7 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m201.4/201.4 kB\u001b[0m \u001b[31m4.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25h" ] } @@ -222,10 +226,9 @@ ], "source": [ "# Run this cell and paste the API key in the prompt\n", - "import os\n", - "import getpass\n", - "\n", - "os.environ['GOOGLE_API_KEY'] = getpass.getpass('Gemini API Key:')" + "from google.colab import userdata\n", + "GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n", + "genai.configure(api_key=GOOGLE_API_KEY)" ] }, { diff --git a/examples/gemini/python/langchain/Gemini_LangChain_Summarization_WebLoad.ipynb b/examples/gemini/python/langchain/Gemini_LangChain_Summarization_WebLoad.ipynb index 3e789669e..344f031b2 100644 --- a/examples/gemini/python/langchain/Gemini_LangChain_Summarization_WebLoad.ipynb +++ b/examples/gemini/python/langchain/Gemini_LangChain_Summarization_WebLoad.ipynb @@ -107,7 +107,7 @@ } ], "source": [ - "!pip install --quiet langchain" + "!pip install --quiet langchain langchain-community" ] }, { @@ -168,10 +168,10 @@ ], "source": [ "# Run this cell and paste the API key in the prompt\n", - "import os\n", - "import getpass\n", + "from google.colab import userdata\n", + "GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n", "\n", - "os.environ['GOOGLE_API_KEY'] = getpass.getpass('Gemini API Key:')" + "genai.configure(api_key=GOOGLE_API_KEY)" ] }, { diff --git a/examples/gemini/python/llamaindex/Gemini_LlamaIndex_QA_Chroma_WebPageReader.ipynb b/examples/gemini/python/llamaindex/Gemini_LlamaIndex_QA_Chroma_WebPageReader.ipynb index be01899a2..bd539393e 100644 --- a/examples/gemini/python/llamaindex/Gemini_LlamaIndex_QA_Chroma_WebPageReader.ipynb +++ b/examples/gemini/python/llamaindex/Gemini_LlamaIndex_QA_Chroma_WebPageReader.ipynb @@ -97,7 +97,7 @@ "outputs": [], "source": [ "# This guide was tested with 0.10.17, but feel free to try newer versions.\n", - "!pip install -q llama-index==0.10.17" + "!pip install -q llama-index==0.10.17 llama-index-vector-stores-chroma" ] }, { @@ -194,27 +194,39 @@ "In this tutorial, you will set the variable `gemini_api_key` to configure Gemini to use your API key." ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "d3316f4b3b5e" + }, + "outputs": [], + "source": [ + "import os" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "Wp3pYcnh60vt" }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Gemini API Key:··········\n" - ] - } - ], + "outputs": [], "source": [ "# Run this cell and paste the API key in the prompt\n", - "import os\n", - "import getpass\n", - "\n", - "gemini_api_key = getpass.getpass('Gemini API Key:')" + "from google.colab import userdata\n", + "os.environ['GOOGLE_API_KEY'] = userdata.get('GOOGLE_API_KEY')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "9f968d66b8cf" + }, + "outputs": [], + "source": [ + "gemini_api_key = os.environ['GOOGLE_API_KEY']" ] }, { diff --git a/examples/gemini/python/vectordb_with_chroma/vectordb_with_chroma.ipynb b/examples/gemini/python/vectordb_with_chroma/vectordb_with_chroma.ipynb index 8883c82c2..7ceee9dfc 100644 --- a/examples/gemini/python/vectordb_with_chroma/vectordb_with_chroma.ipynb +++ b/examples/gemini/python/vectordb_with_chroma/vectordb_with_chroma.ipynb @@ -140,9 +140,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 IPython.display import Markdown\n", "from chromadb import Documents, EmbeddingFunction, Embeddings" ] @@ -175,7 +172,9 @@ }, "outputs": [], "source": [ + "# Used to securely store your API key\n", "# Or use `os.getenv('API_KEY')` to fetch an environment variable.\n", + "from google.colab import userdata\n", "API_KEY=userdata.get('API_KEY')\n", "\n", "genai.configure(api_key=API_KEY)" diff --git a/site/en/examples/chat_calculator.ipynb b/site/en/examples/chat_calculator.ipynb index 7e154edd7..c1e0dc66e 100644 --- a/site/en/examples/chat_calculator.ipynb +++ b/site/en/examples/chat_calculator.ipynb @@ -127,8 +127,20 @@ }, "outputs": [], "source": [ - "import google.generativeai as genai\n", - "genai.configure(api_key=\"YOUR API KEY\")" + "import google.generativeai as genai" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "75c7d4b67511" + }, + "outputs": [], + "source": [ + "from google.colab import userdata\n", + "GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n", + "genai.configure(api_key=GOOGLE_API_KEY)" ] }, { @@ -139,9 +151,7 @@ }, "outputs": [], "source": [ - "models = [m for m in genai.list_models() if 'generateMessage' in m.supported_generation_methods]\n", - "model = models[0].name\n", - "print(model)" + "model = 'models/chat-bison-001'" ] }, { diff --git a/site/en/examples/text_calculator.ipynb b/site/en/examples/text_calculator.ipynb index 330efa5c0..b369a4893 100644 --- a/site/en/examples/text_calculator.ipynb +++ b/site/en/examples/text_calculator.ipynb @@ -107,7 +107,6 @@ "outputs": [], "source": [ "import google.generativeai as genai\n", - "genai.configure(api_key='YOUR API KEY')\n", "\n", "from google.api_core import retry\n", "\n", @@ -116,6 +115,19 @@ " return genai.generate_text(*args, **kwargs)\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "14c8b88a75ef" + }, + "outputs": [], + "source": [ + "from google.colab import userdata\n", + "GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n", + "genai.configure(api_key=GOOGLE_API_KEY)" + ] + }, { "cell_type": "code", "execution_count": 3, @@ -132,9 +144,7 @@ } ], "source": [ - "models = [m for m in genai.list_models() if 'generateText' in m.supported_generation_methods]\n", - "model = models[0].name\n", - "print(model)" + "model = 'models/text-bison-001'" ] }, { diff --git a/site/en/gemini-api/docs/model-tuning/python.ipynb b/site/en/gemini-api/docs/model-tuning/python.ipynb index 4c2b65ec1..43a23a37b 100644 --- a/site/en/gemini-api/docs/model-tuning/python.ipynb +++ b/site/en/gemini-api/docs/model-tuning/python.ipynb @@ -265,10 +265,7 @@ } ], "source": [ - "base_model = [\n", - " m for m in genai.list_models()\n", - " if \"createTunedModel\" in m.supported_generation_methods][0]\n", - "base_model" + "base_model = genai.get_model('models/gemini-1.0-pro-001')\n" ] }, { diff --git a/site/en/gemini-api/docs/model-tuning/rest.ipynb b/site/en/gemini-api/docs/model-tuning/rest.ipynb index e66ce0f83..e6537b010 100644 --- a/site/en/gemini-api/docs/model-tuning/rest.ipynb +++ b/site/en/gemini-api/docs/model-tuning/rest.ipynb @@ -287,7 +287,9 @@ "text": [ " % Total % Received % Xferd Average Speed Time Time Time Current\n", " Dload Upload Total Spent Left Speed\n", - "\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r100 2280 0 296 100 1984 611 4098 --:--:-- --:--:-- --:--:-- 4720\n" + "\r", + " 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r", + "100 2280 0 296 100 1984 611 4098 --:--:-- --:--:-- --:--:-- 4720\n" ] } ], @@ -437,7 +439,10 @@ "text": [ " % Total % Received % Xferd Average Speed Time Time Time Current\n", " Dload Upload Total Spent Left Speed\n", - "\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r100 5921 0 5921 0 0 13164 0 --:--:-- --:--:-- --:--:-- 13157\n" + "\r", + " 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r", + " 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r", + "100 5921 0 5921 0 0 13164 0 --:--:-- --:--:-- --:--:-- 13157\n" ] } ], diff --git a/site/en/gemini-api/tutorials/anomaly_detection.ipynb b/site/en/gemini-api/tutorials/anomaly_detection.ipynb index 3efaa7cff..5611ab0e0 100644 --- a/site/en/gemini-api/tutorials/anomaly_detection.ipynb +++ b/site/en/gemini-api/tutorials/anomaly_detection.ipynb @@ -113,9 +113,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" ] @@ -148,6 +145,9 @@ }, "outputs": [], "source": [ + "# Used to securely store your API key\n", + "from google.colab import userdata\n", + "\n", "# Or use `os.getenv('API_KEY')` to fetch an environment variable.\n", "API_KEY=userdata.get('API_KEY')\n", "\n", diff --git a/site/en/gemini-api/tutorials/clustering_with_embeddings.ipynb b/site/en/gemini-api/tutorials/clustering_with_embeddings.ipynb index 4df15b305..13a9460ed 100644 --- a/site/en/gemini-api/tutorials/clustering_with_embeddings.ipynb +++ b/site/en/gemini-api/tutorials/clustering_with_embeddings.ipynb @@ -114,9 +114,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\n", "from sklearn.cluster import KMeans\n", @@ -151,6 +148,9 @@ }, "outputs": [], "source": [ + "# Used to securely store your API key\n", + "from google.colab import userdata\n", + "\n", "# Or use `os.getenv('API_KEY')` to fetch an environment variable.\n", "API_KEY=userdata.get('API_KEY')\n", "\n", diff --git a/site/en/gemini-api/tutorials/document_search.ipynb b/site/en/gemini-api/tutorials/document_search.ipynb index c24ef9d98..00f87e3e1 100644 --- a/site/en/gemini-api/tutorials/document_search.ipynb +++ b/site/en/gemini-api/tutorials/document_search.ipynb @@ -111,9 +111,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 IPython.display import Markdown" ] }, @@ -145,6 +142,9 @@ }, "outputs": [], "source": [ + "# Used to securely store your API key\n", + "from google.colab import userdata\n", + "\n", "# Or use `os.getenv('API_KEY')` to fetch an environment variable.\n", "API_KEY=userdata.get('API_KEY')\n", "\n", diff --git a/site/en/gemini-api/tutorials/text_classifier_embeddings.ipynb b/site/en/gemini-api/tutorials/text_classifier_embeddings.ipynb index d1bcedc5a..fbbe32522 100644 --- a/site/en/gemini-api/tutorials/text_classifier_embeddings.ipynb +++ b/site/en/gemini-api/tutorials/text_classifier_embeddings.ipynb @@ -113,9 +113,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", "import seaborn as sns\n", "import matplotlib.pyplot as plt\n", "\n", @@ -153,6 +150,8 @@ }, "outputs": [], "source": [ + "# Used to securely store your API key\n", + "from google.colab import userdata\n", "# Or use `os.getenv('API_KEY')` to fetch an environment variable.\n", "API_KEY=userdata.get('API_KEY')\n", "\n", @@ -1226,7 +1225,7 @@ "embedding_size = len(df_train['Embeddings'].iloc[0])\n", "\n", "# Give your model a different name, as you have already used the variable name 'model'\n", - "classifier = build_classification_model(embedding_size, len(df_train['Class Name'].unique()))\n", + "classifier = build_classification_model([embedding_size], len(df_train['Class Name'].unique()))\n", "classifier.summary()\n", "\n", "classifier.compile(loss = keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n", diff --git a/site/en/gemma/docs/paligemma/fine-tuning-paligemma.ipynb b/site/en/gemma/docs/paligemma/fine-tuning-paligemma.ipynb index 98f6a00dd..174a27c14 100644 --- a/site/en/gemma/docs/paligemma/fine-tuning-paligemma.ipynb +++ b/site/en/gemma/docs/paligemma/fine-tuning-paligemma.ipynb @@ -13,6 +13,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "cellView": "form", "id": "_fEE8rM9BUfS" }, "outputs": [], @@ -38,17 +39,17 @@ "source": [ "# Fine-tune PaliGemma with JAX\n", "\n", - "\u003ctable class=\"tfo-notebook-buttons\" align=\"left\"\u003e\n", - "\u003ctd\u003e\n", - "\u003ca target=\"_blank\" href=\"https://ai.google.dev/gemma/docs/paligemma/fine-tuning-paligemma\"\u003e\u003cimg src=\"https://ai.google.dev/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" /\u003eView on ai.google.dev\u003c/a\u003e\n", - "\u003c/td\u003e\n", - "\u003ctd\u003e\n", - "\u003ca target=\"_blank\" href=\"https://colab.research.google.com/github/google/generative-ai-docs/blob/main/site/en/gemma/docs/paligemma/fine-tuning-paligemma.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" /\u003eRun in Google Colab\u003c/a\u003e\n", - "\u003c/td\u003e\n", - "\u003ctd\u003e\n", - "\u003ca target=\"_blank\" href=\"https://github.com/google/generative-ai-docs/blob/main/site/en/gemma/docs/paligemma/fine-tuning-paligemma.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" /\u003eView source on GitHub\u003c/a\u003e\n", - "\u003c/td\u003e\n", - "\u003c/table\u003e\n" + "
\n",
+ "![]() | \n",
+ "\n",
+ "![]() | \n",
+ "\n",
+ "![]() | \n",
+ "
{html.escape(caption)}
\n", + "