Skip to content

Commit a96a35f

Browse files
authored
Merge pull request #23 from madebygps/ollama-devcontainer-support
ollama support updates
2 parents fef7022 + be32b0a commit a96a35f

6 files changed

Lines changed: 40 additions & 13 deletions

File tree

.devcontainer/ollama/devcontainer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"context": "../.."
88
},
99
"features": {
10-
"ghcr.io/prulloac/devcontainer-features/ollama:1": {}
10+
"ghcr.io/prulloac/devcontainer-features/ollama:1": {
11+
"pull": "gemma4:e4b"
12+
}
1113
},
1214
// Configure tool-specific properties.
1315
"customizations": {
@@ -26,7 +28,7 @@
2628
},
2729

2830
// Use 'postCreateCommand' to run commands after the container is created.
29-
"postCreateCommand": "cp .env.sample.ollama .env && ollama pull llama3.1",
31+
"postCreateCommand": "cp .env.sample.ollama .env",
3032

3133
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
3234
"remoteUser": "vscode",

.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ AZURE_OPENAI_ENDPOINT=https://YOUR-AZURE-OPENAI-SERVICE-NAME.openai.azure.com
55
AZURE_OPENAI_CHAT_DEPLOYMENT=YOUR-AZURE-DEPLOYMENT-NAME
66
# Needed for Ollama:
77
OLLAMA_ENDPOINT=http://localhost:11434/v1
8-
OLLAMA_MODEL=llama3.1
8+
OLLAMA_MODEL=gemma4:e4b
99
# Needed for OpenAI.com:
1010
OPENAI_KEY=YOUR-OPENAI-KEY
1111
OPENAI_MODEL=gpt-3.5-turbo

.env.sample.ollama

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# See .env.sample for all options
22
API_HOST=ollama
33
OLLAMA_ENDPOINT=http://localhost:11434/v1
4-
OLLAMA_MODEL=llama3.1
4+
OLLAMA_MODEL=gemma4:e4b

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,27 +142,43 @@ This project includes infrastructure as code (IaC) to provision Azure OpenAI dep
142142

143143
## Using Ollama models
144144

145+
Most chat, streaming, function calling, structured outputs, CSV RAG, and document RAG flow samples work with local Ollama chat models. These samples have been tested with `gemma4:e4b` and `qwen3.5:4b`. The document ingestion and hybrid vector search samples currently use `text-embedding-3-small` for embeddings, so those scripts need Azure OpenAI/OpenAI embeddings or a code update before they can run in a local-only Ollama setup. The `reasoning.py` sample is intended for reasoning models, such as `gpt-oss`.
146+
147+
If you use GitHub Codespaces or Dev Containers, you can use the Ollama devcontainer, which installs Ollama and pulls the default model for you:
148+
149+
```text
150+
https://codespaces.new/Azure-Samples/python-openai-demos?devcontainer_path=.devcontainer/ollama/devcontainer.json
151+
```
152+
145153
1. Install [Ollama](https://ollama.com/) and follow the instructions to set it up on your local machine.
146-
2. Pull a model, for example:
154+
2. Pull the recommended model:
155+
156+
```shell
157+
ollama pull gemma4:e4b
158+
```
159+
160+
Another tested option is:
147161

148162
```shell
149-
ollama pull llama3.1
163+
ollama pull qwen3.5:4b
150164
```
151165

152-
3. Create a `.env` file by copying the `.env.sample` file and updating it with your Ollama endpoint and model name.
166+
3. Create a `.env` file by copying the Ollama-specific environment sample:
153167

154168
```bash
155-
cp .env.sample .env
169+
cp .env.sample.ollama .env
156170
```
157171

158-
4. Update the `.env` file with your Ollama endpoint and model name (any model you've pulled):
172+
4. Update the `.env` file with your Ollama endpoint and model name, if needed:
159173

160174
```bash
161175
API_HOST=ollama
162176
OLLAMA_ENDPOINT=http://localhost:11434/v1
163-
OLLAMA_MODEL=llama3.1
177+
OLLAMA_MODEL=gemma4:e4b
164178
```
165179

180+
Use `http://localhost:11434/v1` when Ollama and Python run in the same environment, including the Ollama devcontainer. If Python runs in a different container and Ollama runs on the host machine, use `http://host.docker.internal:11434/v1` instead.
181+
166182
## Resources
167183

168184
* [Video series: Learn Python + AI (October 2025)](https://techcommunity.microsoft.com/blog/educatordeveloperblog/level-up-your-python--ai-skills-with-our-complete-series/4464546)

requirements-rag.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pymupdf4llm
22
lunr
33
sentence-transformers
4+
tiktoken

spanish/README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,30 @@ OPENAI_MODEL=gpt-4o-mini
137137

138138
### Usando modelos de Ollama
139139

140-
Instala [Ollama](https://ollama.com/) y descarga un modelo:
140+
Instala [Ollama](https://ollama.com/) y descarga el modelo recomendado:
141141

142142
```bash
143-
ollama pull llama3.1
143+
ollama pull gemma4:e4b
144+
```
145+
146+
Otra opcion probada es:
147+
148+
```bash
149+
ollama pull qwen3.5:4b
144150
```
145151

146152
Configura tu `.env`:
147153

148154
```bash
149155
API_HOST=ollama
150156
OLLAMA_ENDPOINT=http://localhost:11434/v1
151-
OLLAMA_MODEL=llama3.1
157+
OLLAMA_MODEL=gemma4:e4b
152158
```
153159

154160
Si ejecutas dentro de un Dev Container, reemplaza `localhost` por `host.docker.internal`.
155161

162+
La mayoria de los ejemplos de chat, streaming, function calling, salidas estructuradas, RAG con CSV y flujo RAG con documentos funcionan con modelos de chat locales de Ollama. Los ejemplos de ingesta de documentos y busqueda vectorial hibrida actualmente usan `text-embedding-3-small` para embeddings, asi que esos scripts necesitan embeddings de Azure OpenAI/OpenAI o una actualizacion de codigo antes de poder ejecutarse en una configuracion local solo con Ollama.
163+
156164
## Recursos
157165

158166
* [Próxima serie octubre 2025: Python + IA](https://aka.ms/PythonIA/serie)

0 commit comments

Comments
 (0)