{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Use AutoGen with Gemini via VertexAI\n",
"\n",
"This notebook demonstrates how to use Autogen with Gemini via Vertex AI, which enables enhanced authentication method that also supports enterprise requirements using service accounts or even a personal Google cloud account.\n",
"\n",
"## Requirements\n",
"\n",
"Install AutoGen with Gemini features:\n",
"```bash\n",
"pip install pyautogen[gemini]\n",
"```\n",
"\n",
"### Install other Dependencies of this Notebook\n",
"```bash\n",
"pip install chromadb markdownify pypdf\n",
"```\n",
"\n",
"### Google Cloud Account\n",
"To use VertexAI a Google Cloud account is needed. If you do not have one yet, just sign up for a free trial [here](https://cloud.google.com).\n",
"\n",
"Login to your account at [console.cloud.google.com](https://console.cloud.google.com)\n",
"\n",
"In the next step we create a Google Cloud project, which is needed for VertexAI. The official guide for creating a project is available is [here](https://developers.google.com/workspace/guides/create-project). \n",
"\n",
"We will name our project Autogen-with-Gemini.\n",
"\n",
"### Enable Google Cloud APIs\n",
"\n",
"If you wish to use Gemini with your personal account, then creating a Google Cloud account is enough. However, if a service account is needed, then a few extra steps are needed.\n",
"\n",
"#### Enable API for Gemini\n",
" * For enabling Gemini for Google Cloud search for \"api\" and select Enabled APIs & services. \n",
" * Then click ENABLE APIS AND SERVICES. \n",
" * Search for Gemini, and select Gemini for Google Cloud.
A direct link will look like this for our autogen-with-gemini project:\n",
"https://console.cloud.google.com/apis/library/cloudaicompanion.googleapis.com?project=autogen-with-gemini&supportedpurview=project\n",
"* Click ENABLE for Gemini for Google Cloud.\n",
"\n",
"### Enable API for Vertex AI\n",
"* For enabling Vertex AI for Google Cloud search for \"api\" and select Enabled APIs & services. \n",
"* Then click ENABLE APIS AND SERVICES. \n",
"* Search for Vertex AI, and select Vertex AI API.
A direct link for our autogen-with-gemini will be: https://console.cloud.google.com/apis/library/aiplatform.googleapis.com?project=autogen-with-gemini\n",
"* Click ENABLE Vertex AI API for Google Cloud.\n",
"\n",
"### Create a Service Account\n",
"\n",
"You can find an overview of service accounts [can be found in the cloud console](https://console.cloud.google.com/iam-admin/serviceaccounts)\n",
"\n",
"Detailed guide: https://cloud.google.com/iam/docs/service-accounts-create\n",
"\n",
"A service account can be created within the scope of a project, so a project needs to be selected.\n",
"\n",
"