|
| 1 | +# OpenChat Playground with Ollama |
| 2 | + |
| 3 | +This page describes how to run OpenChat Playground (OCP) with [Ollama](https://ollama.com/search) 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 Ollama is installed and running on your local machine. If not, install Ollama from [ollama.com](https://ollama.com/) and start the service. |
| 22 | + |
| 23 | + ```bash |
| 24 | + ollama serve |
| 25 | + ``` |
| 26 | + |
| 27 | +1. Pull the model you want to use. The default model OCP uses is "llama3.2" |
| 28 | + |
| 29 | + ```bash |
| 30 | + ollama pull llama3.2 |
| 31 | + ``` |
| 32 | + |
| 33 | + Alternatively, if you want to run with a different model, say [qwen](https://ollama.com/library/qwen) other than the default one, download it first by running the following command. |
| 34 | + |
| 35 | + ```bash |
| 36 | + ollama pull qwen |
| 37 | + ``` |
| 38 | + |
| 39 | +2. Make sure you are at the repository root. |
| 40 | + |
| 41 | + ```bash |
| 42 | + cd $REPOSITORY_ROOT |
| 43 | + ``` |
| 44 | + |
| 45 | +3. Run the app. |
| 46 | + |
| 47 | + ```bash |
| 48 | + # bash/zsh |
| 49 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- \ |
| 50 | + --connector-type Ollama |
| 51 | + ``` |
| 52 | + |
| 53 | + ```powershell |
| 54 | + # PowerShell |
| 55 | + dotnet run --project $REPOSITORY_ROOT\src\OpenChat.PlaygroundApp -- ` |
| 56 | + --connector-type Ollama |
| 57 | + ``` |
| 58 | +
|
| 59 | + Alternatively, if you want to run with a different model, say [qwen](https://ollama.com/library/qwen) other than the default one, download it first by running the following command. |
| 60 | +
|
| 61 | + ```bash |
| 62 | + # bash/zsh |
| 63 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- \ |
| 64 | + --connector-type Ollama \ |
| 65 | + --model qwen |
| 66 | + ``` |
| 67 | +
|
| 68 | + ```powershell |
| 69 | + # PowerShell |
| 70 | + dotnet run --project $REPOSITORY_ROOT\src\OpenChat.PlaygroundApp -- ` |
| 71 | + --connector-type Ollama ` |
| 72 | + --model qwen |
| 73 | + ``` |
| 74 | +
|
| 75 | +4. Open your web browser, navigate to `http://localhost:5280`, and enter prompts. |
| 76 | +
|
| 77 | +## Run on local container |
| 78 | +
|
| 79 | +This approach runs OpenChat Playground in a container while connecting to Ollama running on the host machine. |
| 80 | +
|
| 81 | +1. Configure Ollama to accept connections from containers. |
| 82 | +
|
| 83 | + ```bash |
| 84 | + ollama serve |
| 85 | + ``` |
| 86 | +
|
| 87 | +1. Pull the model you want to use, and verify Ollama is accessible |
| 88 | +
|
| 89 | + ```bash |
| 90 | + ollama pull llama3.2 |
| 91 | + curl http://localhost:11434/api/version |
| 92 | + ``` |
| 93 | + |
| 94 | + ```powershell |
| 95 | + ollama pull llama3.2 |
| 96 | + Invoke-RestMethod -Uri http://localhost:11434/api/version |
| 97 | + ``` |
| 98 | +
|
| 99 | +1. Make sure you are at the repository root. |
| 100 | +
|
| 101 | + ```bash |
| 102 | + cd $REPOSITORY_ROOT |
| 103 | + ``` |
| 104 | +
|
| 105 | +1. Build a container. |
| 106 | +
|
| 107 | + ```bash |
| 108 | + docker build -f Dockerfile -t openchat-playground:latest . |
| 109 | + ``` |
| 110 | +
|
| 111 | +1. Run the app. |
| 112 | +
|
| 113 | + ```bash |
| 114 | + # bash/zsh - from locally built container |
| 115 | + docker run -i --rm -p 8080:8080 openchat-playground:latest \ |
| 116 | + --connector-type Ollama \ |
| 117 | + --base-url http://host.docker.internal:11434 \ |
| 118 | + ``` |
| 119 | +
|
| 120 | + ```powershell |
| 121 | + # PowerShell - from locally built container |
| 122 | + docker run -i --rm -p 8080:8080 openchat-playground:latest ` |
| 123 | + --connector-type Ollama ` |
| 124 | + --base-url http://host.docker.internal:11434 |
| 125 | + ``` |
| 126 | +
|
| 127 | + ```bash |
| 128 | + # bash/zsh - from GitHub Container Registry |
| 129 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest\ |
| 130 | + --connector-type Ollama \ |
| 131 | + --base-url http://host.docker.internal:11434 |
| 132 | + ``` |
| 133 | + |
| 134 | + ```powershell |
| 135 | + # PowerShell - from GitHub Container Registry |
| 136 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest ` |
| 137 | + --connector-type Ollama ` |
| 138 | + --base-url http://host.docker.internal:11434 |
| 139 | + ``` |
| 140 | +
|
| 141 | + Alternatively, if you want to run with a different model, say [qwen](https://ollama.com/library/qwen), make sure you've already downloaded the model by running the `ollama pull qwen` command. |
| 142 | +
|
| 143 | + ```bash |
| 144 | + ollama pull qwen |
| 145 | + ``` |
| 146 | +
|
| 147 | + ```bash |
| 148 | + # bash/zsh - from locally built container |
| 149 | + docker run -i --rm -p 8080:8080 openchat-playground:latest \ |
| 150 | + --connector-type Ollama \ |
| 151 | + --base-url http://host.docker.internal:11434 \ |
| 152 | + --model qwen |
| 153 | + ``` |
| 154 | +
|
| 155 | + ```powershell |
| 156 | + # PowerShell - from locally built container |
| 157 | + docker run -i --rm -p 8080:8080 openchat-playground:latest ` |
| 158 | + --connector-type Ollama ` |
| 159 | + --base-url http://host.docker.internal:11434 ` |
| 160 | + --model qwen |
| 161 | + ``` |
| 162 | +
|
| 163 | + ```bash |
| 164 | + # bash/zsh - from GitHub Container Registry |
| 165 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest\ |
| 166 | + --connector-type Ollama \ |
| 167 | + --base-url http://host.docker.internal:11434 \ |
| 168 | + --model qwen |
| 169 | + ``` |
| 170 | + |
| 171 | + ```powershell |
| 172 | + # PowerShell - from GitHub Container Registry |
| 173 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest ` |
| 174 | + --connector-type Ollama ` |
| 175 | + --base-url http://host.docker.internal:11434 ` |
| 176 | + --model qwen |
| 177 | + ``` |
| 178 | +
|
| 179 | + > **NOTE**: Use `host.docker.internal:11434` to connect to Ollama running on the host machine from inside the container. |
| 180 | +
|
| 181 | +1. Open your web browser, navigate to `http://localhost:8080`, and enter prompts. |
| 182 | +
|
| 183 | +## Run on Azure |
| 184 | +
|
| 185 | +1. Make sure you are at the repository root. |
| 186 | +
|
| 187 | + ```bash |
| 188 | + cd $REPOSITORY_ROOT |
| 189 | + ``` |
| 190 | +
|
| 191 | +1. Login to Azure. |
| 192 | +
|
| 193 | + ```bash |
| 194 | + # Login to Azure Dev CLI |
| 195 | + azd auth login |
| 196 | + ``` |
| 197 | +
|
| 198 | +1. Check login status. |
| 199 | +
|
| 200 | + ```bash |
| 201 | + # Azure Dev CLI |
| 202 | + azd auth login --check-status |
| 203 | + ``` |
| 204 | +
|
| 205 | +1. Initialize `azd` template. |
| 206 | +
|
| 207 | + ```bash |
| 208 | + azd init |
| 209 | + ``` |
| 210 | +
|
| 211 | + > **NOTE**: You will be asked to provide environment name for provisioning. |
| 212 | +
|
| 213 | +1. Set the connector type to `Ollama`. |
| 214 | +
|
| 215 | + ```bash |
| 216 | + azd env set CONNECTOR_TYPE "Ollama" |
| 217 | + ``` |
| 218 | +
|
| 219 | + The default model OCP uses is [llama3.2](https://ollama.com/library/llama3.2). If you want to run with a different model, say [qwen](https://ollama.com/library/qwen) other than the default one, add it to azd environment variables. |
| 220 | +
|
| 221 | + ```bash |
| 222 | + azd env set OLLAMA_MODEL "qwen" |
| 223 | + ``` |
| 224 | +
|
| 225 | +2. As a default, the app uses a Serverless GPU with NVIDIA T4 (`NC8as-T4`). If you want to use NVIDIA A100, set the GPU profile. |
| 226 | +
|
| 227 | + ```bash |
| 228 | + azd env set GPU_PROFILE_NAME "NC24-A100" |
| 229 | + ``` |
| 230 | +
|
| 231 | + If you want to know more about Serverless GPU, visit [Using serverless GPUs in Azure Container Apps](https://learn.microsoft.com/azure/container-apps/gpu-serverless-overview#use-serverless-gpus). |
| 232 | +
|
| 233 | +3. Run the following commands in order to provision and deploy the app. |
| 234 | +
|
| 235 | + ```bash |
| 236 | + azd up |
| 237 | + ``` |
| 238 | +
|
| 239 | + > **NOTE**: You will be asked to provide Azure subscription and location for deployment. |
| 240 | + > **IMPORTANT**: Due to the limitation for GPU support, the available regions are limited to `Australia East`, `Sweden Central` and `West US 3`. For more details, visit [Using serverless GPUs in Azure Container Apps](https://learn.microsoft.com/azure/container-apps/gpu-serverless-overview#supported-regions). |
| 241 | +
|
| 242 | + Once deployed, you will be able to see the deployed OCP app URL. |
| 243 | +
|
| 244 | +4. Open your web browser, navigate to the OCP app URL, and enter prompts. |
| 245 | +
|
| 246 | +5. Clean up all the resources. |
| 247 | +
|
| 248 | + ```bash |
| 249 | + azd down --force --purge |
| 250 | + ``` |
0 commit comments