|
| 1 | +# OpenChat Playground with Google Vertex AI |
| 2 | + |
| 3 | +This page describes how to run OpenChat Playground (OCP) with Google Vertex AI integration. |
| 4 | + |
| 5 | +## Get the repository root |
| 6 | + |
| 7 | +1. Get the repository root. |
| 8 | + |
| 9 | + ```bash |
| 10 | + # bash/zsh |
| 11 | + REPOSITORY_ROOT=$(git rev-parse --show-toplevel) |
| 12 | + ``` |
| 13 | + |
| 14 | + ```powershell |
| 15 | + # PowerShell |
| 16 | + $REPOSITORY_ROOT = git rev-parse --show-toplevel |
| 17 | + ``` |
| 18 | + |
| 19 | +## Run on local machine |
| 20 | + |
| 21 | +1. Make sure you are at the repository root. |
| 22 | + |
| 23 | + ```bash |
| 24 | + cd $REPOSITORY_ROOT |
| 25 | + ``` |
| 26 | + |
| 27 | +1. Add Google Vertex AI API Key. Replace `{{GOOGLE_VERTEX_AI_API_KEY}}` with your key. |
| 28 | + |
| 29 | + ```bash |
| 30 | + # bash/zsh |
| 31 | + dotnet user-secrets --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp \ |
| 32 | + set GoogleVertexAI:ApiKey "{{GOOGLE_VERTEX_AI_API_KEY}}" |
| 33 | + ``` |
| 34 | + |
| 35 | + ```powershell |
| 36 | + # PowerShell |
| 37 | + dotnet user-secrets --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp ` |
| 38 | + set GoogleVertexAI:ApiKey "{{GOOGLE_VERTEX_AI_API_KEY}}" |
| 39 | + ``` |
| 40 | + |
| 41 | + > To get an API Key, refer to the doc [Using Gemini API keys](https://ai.google.dev/gemini-api/docs/api-key#api-keys). |
| 42 | + |
| 43 | +1. Run the app. The default model OCP uses is [Gemini 2.5 Flash Lite](https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-lite). |
| 44 | + |
| 45 | + ```bash |
| 46 | + # bash/zsh |
| 47 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- \ |
| 48 | + --connector-type GoogleVertexAI |
| 49 | + ``` |
| 50 | + |
| 51 | + ```powershell |
| 52 | + # PowerShell |
| 53 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- ` |
| 54 | + --connector-type GoogleVertexAI |
| 55 | + ``` |
| 56 | + |
| 57 | + Alternatively, if you want to run with a different deployment, say [`gemini-2.5-pro`](https://ai.google.dev/gemini-api/docs/models#gemini-2.5-pro), other than the default one, you can specify it as an argument. |
| 58 | + |
| 59 | + ```bash |
| 60 | + # bash/zsh |
| 61 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- \ |
| 62 | + --connector-type GoogleVertexAI \ |
| 63 | + --model gemini-2.5-pro |
| 64 | + ``` |
| 65 | + |
| 66 | + ```powershell |
| 67 | + # PowerShell |
| 68 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- ` |
| 69 | + --connector-type GoogleVertexAI ` |
| 70 | + --model gemini-2.5-pro |
| 71 | + ``` |
| 72 | + |
| 73 | +1. Open your web browser at `http://localhost:5280` and start entering prompts. |
| 74 | + |
| 75 | +## Run in local container |
| 76 | + |
| 77 | +1. Make sure you are at the repository root. |
| 78 | + |
| 79 | + ```bash |
| 80 | + cd $REPOSITORY_ROOT |
| 81 | + ``` |
| 82 | + |
| 83 | +1. Build a container. |
| 84 | + |
| 85 | + ```bash |
| 86 | + docker build -f Dockerfile -t openchat-playground:latest . |
| 87 | + ``` |
| 88 | + |
| 89 | +1. Get the Google Vertex AI key. |
| 90 | + |
| 91 | + ```bash |
| 92 | + API_KEY=$(dotnet user-secrets --project ./src/OpenChat.PlaygroundApp list --json | \ |
| 93 | + sed -n '/^\/\//d; p' | jq -r '."GoogleVertexAI:ApiKey"') |
| 94 | + ``` |
| 95 | + |
| 96 | + ```powershell |
| 97 | + # PowerShell |
| 98 | + $API_KEY = (dotnet user-secrets --project ./src/OpenChat.PlaygroundApp list --json | ` |
| 99 | + Select-String -NotMatch '^//(BEGIN|END)' | ConvertFrom-Json).'GoogleVertexAI:ApiKey' |
| 100 | + ``` |
| 101 | +
|
| 102 | +1. Run the app. The default model OCP uses is [Gemini 2.5 Flash Lite](https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-lite). |
| 103 | +
|
| 104 | + ```bash |
| 105 | + # bash/zsh - from locally built container |
| 106 | + docker run -i --rm -p 8080:8080 openchat-playground:latest \ |
| 107 | + --connector-type GoogleVertexAI \ |
| 108 | + --api-key $API_KEY |
| 109 | + ``` |
| 110 | +
|
| 111 | + ```powershell |
| 112 | + # PowerShell - from locally built container |
| 113 | + docker run -i --rm -p 8080:8080 openchat-playground:latest --connector-type GoogleVertexAI ` |
| 114 | + --api-key $API_KEY |
| 115 | + ``` |
| 116 | +
|
| 117 | + ```bash |
| 118 | + # bash/zsh - from GitHub Container Registry |
| 119 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest \ |
| 120 | + --connector-type GoogleVertexAI \ |
| 121 | + --api-key $API_KEY |
| 122 | + ``` |
| 123 | +
|
| 124 | + ```powershell |
| 125 | + # PowerShell - from GitHub Container Registry |
| 126 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest ` |
| 127 | + --connector-type GoogleVertexAI ` |
| 128 | + --api-key $API_KEY ` |
| 129 | + ``` |
| 130 | +
|
| 131 | + Alternatively, if you want to run with a different deployment, say [`gemini-2.5-pro`](https://ai.google.dev/gemini-api/docs/models#gemini-2.5-pro), other than the default one, you can specify it as an argument. |
| 132 | +
|
| 133 | + ```bash |
| 134 | + # bash/zsh - from locally built container |
| 135 | + docker run -i --rm -p 8080:8080 openchat-playground:latest \ |
| 136 | + --connector-type GoogleVertexAI \ |
| 137 | + --api-key $API_KEY \ |
| 138 | + --model gemini-2.5-pro |
| 139 | + ``` |
| 140 | +
|
| 141 | + ```powershell |
| 142 | + # PowerShell - from locally built container |
| 143 | + docker run -i --rm -p 8080:8080 openchat-playground:latest --connector-type GoogleVertexAI ` |
| 144 | + --api-key $API_KEY ` |
| 145 | + --model gemini-2.5-pro |
| 146 | + ``` |
| 147 | +
|
| 148 | + ```bash |
| 149 | + # bash/zsh - from GitHub Container Registry |
| 150 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest \ |
| 151 | + --connector-type GoogleVertexAI \ |
| 152 | + --api-key $API_KEY \ |
| 153 | + --model gemini-2.5-pro |
| 154 | + ``` |
| 155 | +
|
| 156 | + ```powershell |
| 157 | + # PowerShell - from GitHub Container Registry |
| 158 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest ` |
| 159 | + --connector-type GoogleVertexAI ` |
| 160 | + --api-key $API_KEY ` |
| 161 | + --model gemini-2.5-pro |
| 162 | + ``` |
| 163 | +
|
| 164 | +1. Open your web browser, navigate to `http://localhost:8080`, and enter prompts. |
| 165 | +
|
| 166 | +## Run on Azure |
| 167 | +
|
| 168 | +1. Make sure you are at the repository root. |
| 169 | +
|
| 170 | + ```bash |
| 171 | + cd $REPOSITORY_ROOT |
| 172 | + ``` |
| 173 | +
|
| 174 | +1. Login to Azure: |
| 175 | +
|
| 176 | + ```bash |
| 177 | + azd auth login |
| 178 | + ``` |
| 179 | +
|
| 180 | +1. Check login status. |
| 181 | +
|
| 182 | + ```bash |
| 183 | + azd auth login --check-status |
| 184 | + ``` |
| 185 | +
|
| 186 | +1. Initialize `azd` template. |
| 187 | +
|
| 188 | + ```bash |
| 189 | + azd init |
| 190 | + ``` |
| 191 | +
|
| 192 | + > **NOTE**: You will be asked to provide environment name for provisioning. |
| 193 | +
|
| 194 | +1. Get Google Vertex AI API Key. |
| 195 | +
|
| 196 | + ```bash |
| 197 | + API_KEY=$(dotnet user-secrets --project ./src/OpenChat.PlaygroundApp list --json | \ |
| 198 | + sed -n '/^\/\//d; p' | jq -r '."GoogleVertexAI:ApiKey"') |
| 199 | + ``` |
| 200 | +
|
| 201 | + ```powershell |
| 202 | + # PowerShell |
| 203 | + $API_KEY = (dotnet user-secrets --project ./src/OpenChat.PlaygroundApp list --json | ` |
| 204 | + Select-String -NotMatch '^//(BEGIN|END)' | ConvertFrom-Json).'GoogleVertexAI:ApiKey' |
| 205 | + ``` |
| 206 | +
|
| 207 | +1. Set Google Vertex AI configuration to azd environment variables. |
| 208 | +
|
| 209 | + ```bash |
| 210 | + azd env set GOOGLE_VERTEX_AI_API_KEY $API_KEY |
| 211 | + ``` |
| 212 | +
|
| 213 | + The default model OCP uses is [Gemini 2.5 Flash Lite](https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-lite). If you want to run with a different deployment, say [`gemini-2.5-pro`](https://ai.google.dev/gemini-api/docs/models#gemini-2.5-pro), other than the default one, add it to azd environment variables. |
| 214 | +
|
| 215 | + ```bash |
| 216 | + azd env set GOOGLE_VERTEX_AI_MODEL gemini-2.5-pro |
| 217 | + ``` |
| 218 | +
|
| 219 | +1. Set the connector type to `GoogleVertexAI` |
| 220 | +
|
| 221 | + ```bash |
| 222 | + azd env set CONNECTOR_TYPE GoogleVertexAI |
| 223 | + ``` |
| 224 | +
|
| 225 | +1. Provision and deploy: |
| 226 | +
|
| 227 | + ```bash |
| 228 | + azd up |
| 229 | + ``` |
| 230 | +
|
| 231 | + > **NOTE**: You will be asked to provide Azure subscription and location for deployment. |
| 232 | +
|
| 233 | + Once deployed, you will be able to see the deployed OCP app URL. |
| 234 | +
|
| 235 | +1. Open your web browser, navigate to the OCP app URL, and enter prompts. |
| 236 | +
|
| 237 | +1. Clean up: |
| 238 | +
|
| 239 | + ```bash |
| 240 | + azd down --force --purge |
| 241 | + ``` |
0 commit comments