Skip to content

Commit c0e286f

Browse files
authored
Port from Chat Completions API to Responses API (#292)
* Port to Responses API * Revert temperature change * Update async credentials, rm GitHub Models * Port frontend to be more Responses like, remove unused session state and follow-up Qs * Hopefully fix the CI and tests * Use async cred for pg in prod * Fix CI and mypy * Exclude 3.10 from macos arm64, they dont work
1 parent c50a5a3 commit c0e286f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+488
-705
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ FROM mcr.microsoft.com/devcontainers/${IMAGE}
44
ENV PYTHONUNBUFFERED 1
55

66
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
7-
&& apt-get -y install --no-install-recommends postgresql-client \
8-
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
7+
&& apt-get -y install --no-install-recommends postgresql-client zstd \
8+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

.devcontainer/devcontainer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@
2929
"extensions": [
3030
"ms-python.python",
3131
"ms-python.vscode-pylance",
32-
"ms-python.vscode-python-envs",
3332
"charliermarsh.ruff",
3433
"mtxr.sqltools",
3534
"mtxr.sqltools-driver-pg",
3635
"esbenp.prettier-vscode",
3736
"mechatroner.rainbow-csv",
3837
"ms-vscode.vscode-node-azure-pack",
39-
"esbenp.prettier-vscode",
4038
"twixes.pypi-assistant",
41-
"ms-python.vscode-python-envs",
4239
"teamsdevapp.vscode-ai-foundry",
4340
"ms-windows-ai-studio.windows-ai-studio"
4441
],

.env.sample

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ POSTGRES_PASSWORD=postgres
55
POSTGRES_DATABASE=postgres
66
POSTGRES_SSL=disable
77

8-
# OPENAI_CHAT_HOST can be either azure, openai, ollama, or github:
8+
# OPENAI_CHAT_HOST can be either azure, openai, or ollama:
99
OPENAI_CHAT_HOST=azure
10-
# OPENAI_EMBED_HOST can be either azure, openai, ollama, or github:
10+
# OPENAI_EMBED_HOST can be either azure, openai, or ollama:
1111
OPENAI_EMBED_HOST=azure
1212
# Needed for Azure:
1313
# You also need to `azd auth login` if running this locally
1414
AZURE_OPENAI_ENDPOINT=https://YOUR-AZURE-OPENAI-SERVICE-NAME.openai.azure.com
15-
AZURE_OPENAI_VERSION=2024-03-01-preview
16-
AZURE_OPENAI_CHAT_DEPLOYMENT=gpt-4o-mini
17-
AZURE_OPENAI_CHAT_MODEL=gpt-4o-mini
15+
AZURE_OPENAI_CHAT_DEPLOYMENT=gpt-5.4
16+
AZURE_OPENAI_CHAT_MODEL=gpt-5.4
1817
AZURE_OPENAI_EMBED_DEPLOYMENT=text-embedding-3-large
1918
AZURE_OPENAI_EMBED_MODEL=text-embedding-3-large
2019
AZURE_OPENAI_EMBED_DIMENSIONS=1024
@@ -35,9 +34,3 @@ OLLAMA_ENDPOINT=http://host.docker.internal:11434/v1
3534
OLLAMA_CHAT_MODEL=llama3.1
3635
OLLAMA_EMBED_MODEL=nomic-embed-text
3736
OLLAMA_EMBEDDING_COLUMN=embedding_nomic
38-
# Needed for GitHub Models:
39-
GITHUB_TOKEN=YOUR-GITHUB-TOKEN
40-
GITHUB_MODEL=openai/gpt-4o
41-
GITHUB_EMBED_MODEL=openai/text-embedding-3-large
42-
GITHUB_EMBED_DIMENSIONS=1024
43-
GITHUB_EMBEDDING_COLUMN=embedding_3l

.github/copilot-instructions.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RAG on PostgreSQL is a Python FastAPI backend with React TypeScript frontend tha
1111
Install the following tools before beginning development:
1212

1313
- **Python 3.10+** (3.12 recommended)
14-
- **Node.js 18+** for frontend development
14+
- **Node.js 18+** for frontend development
1515
- **PostgreSQL 14+** with pgvector extension
1616
- **Azure Developer CLI (azd)** for deployment
1717
- **Docker Desktop** for dev containers (optional)
@@ -37,7 +37,7 @@ Run these commands in sequence. NEVER CANCEL any long-running commands:
3737
```bash
3838
# Ubuntu/Debian:
3939
sudo apt update && sudo apt install -y postgresql-16-pgvector
40-
40+
4141
# Start PostgreSQL and set password
4242
sudo service postgresql start
4343
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres'"
@@ -97,7 +97,7 @@ Use "Frontend & Backend" configuration in the VS Code Run & Debug menu.
9797
### Linting and Formatting (ALWAYS run before committing)
9898
```bash
9999
ruff check . # Lint code (takes <1 second)
100-
ruff format . # Format code (takes <1 second)
100+
ruff format . # Format code (takes <1 second)
101101
mypy . --python-version 3.12 # Type check (takes ~42 seconds)
102102
```
103103

@@ -121,7 +121,7 @@ pytest tests/e2e.py --tracing=retain-on-failure
121121
**CRITICAL TIMING INFORMATION** - Set these timeout values and NEVER CANCEL:
122122

123123
- **Dependencies install**: 90 seconds (use 180+ second timeout)
124-
- **Frontend npm install**: 22 seconds (use 60+ second timeout)
124+
- **Frontend npm install**: 22 seconds (use 60+ second timeout)
125125
- **Frontend build**: 12 seconds (use 30+ second timeout)
126126
- **MyPy type checking**: 42 seconds (use 90+ second timeout)
127127
- **Full test suite**: 25 seconds (use 60+ second timeout)
@@ -156,7 +156,7 @@ pytest tests/e2e.py --tracing=retain-on-failure
156156
# Test API endpoints
157157
curl http://localhost:8000/items/1
158158
# Should return JSON with item data
159-
159+
160160
# Test frontend
161161
curl http://localhost:8000/ | head -n 5
162162
# Should return HTML with "RAG on PostgreSQL" title
@@ -226,9 +226,6 @@ The application supports multiple OpenAI providers:
226226
3. **Ollama** (local):
227227
Set `OPENAI_CHAT_HOST=ollama`
228228

229-
4. **GitHub Models**:
230-
Set `OPENAI_CHAT_HOST=github`
231-
232229
## Common Issues and Solutions
233230

234231
### Database Connection Issues
@@ -267,7 +264,7 @@ Open `http://localhost:8089/` and point to your running application.
267264
The application provides these REST API endpoints (view full docs at `http://localhost:8000/docs`):
268265

269266
- `GET /items/{id}` - Get specific item by ID
270-
- `GET /search` - Search items with text query
267+
- `GET /search` - Search items with text query
271268
- `GET /similar` - Find similar items using vector search
272269
- `POST /chat` - Chat with RAG system (requires OpenAI configuration)
273270
- `POST /chat/stream` - Streaming chat responses
@@ -286,7 +283,7 @@ curl "http://localhost:8000/search?query=tent&limit=5"
286283
**Quick ls -la output for repository root:**
287284
```
288285
.devcontainer/ # Dev container configuration
289-
.env.sample # Environment variables template
286+
.env.sample # Environment variables template
290287
.github/ # GitHub Actions workflows
291288
.gitignore # Git ignore patterns
292289
.pre-commit-config.yaml # Pre-commit hook configuration
@@ -309,8 +306,8 @@ tests/ # Test suite
309306
- **Always build and test locally before committing**
310307
- **Use pre-commit hooks** - they run ruff automatically
311308
- **Check the GitHub Actions** in `.github/workflows/` for CI requirements
312-
- **Reference the full README.md** for deployment and Azure-specific details
309+
- **Reference the full README.md** for deployment and Azure-specific details
313310
- **Use VS Code with the Python and Ruff extensions** for the best development experience
314311
- **Never skip the frontend build** - the backend serves static files from `src/backend/static/`
315312

316-
This project follows modern Python and TypeScript development practices with comprehensive tooling for code quality, testing, and deployment.
313+
This project follows modern Python and TypeScript development practices with comprehensive tooling for code quality, testing, and deployment.

.github/workflows/app-tests.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ jobs:
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
os: ["ubuntu-latest", "macos-latest-xlarge", "macos-13", "windows-latest"]
30+
os: ["ubuntu-latest", "macos-26", "windows-latest"]
3131
python_version: ["3.10", "3.11", "3.12"]
3232
exclude:
33-
- os: macos-latest-xlarge
33+
- os: macos-26
3434
python_version: "3.10"
3535
env:
3636
UV_SYSTEM_PYTHON: 1
@@ -43,12 +43,12 @@ jobs:
4343
- uses: actions/checkout@v4
4444

4545
- name: (MacOS) Install postgreSQL and pgvector using brew
46-
if: matrix.os == 'macos-13' || matrix.os == 'macos-latest-xlarge'
46+
if: matrix.os == 'macos-26'
4747
run: |
48-
brew install postgresql@14
49-
brew link --overwrite postgresql@14
48+
brew install postgresql@18
49+
brew link --overwrite postgresql@18
5050
brew install pgvector
51-
brew services start postgresql@14 && sleep 1
51+
brew services start postgresql@18 && sleep 1
5252
createuser -s ${{ env.POSTGRES_USERNAME }}
5353
psql -d postgres -c "ALTER USER ${{ env.POSTGRES_USERNAME }} WITH PASSWORD '${{ env.POSTGRES_PASSWORD }}'"
5454
psql -d postgres -c 'CREATE EXTENSION vector'

.github/workflows/evaluate.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
OPENAI_CHAT_HOST: ${{ vars.OPENAI_CHAT_HOST }}
3535
OPENAI_EMBED_HOST: ${{ vars.OPENAI_EMBED_HOST }}
3636
AZURE_OPENAI_ENDPOINT: ${{ vars.AZURE_OPENAI_ENDPOINT }}
37-
AZURE_OPENAI_VERSION: ${{ vars.AZURE_OPENAI_VERSION }}
3837
AZURE_OPENAI_CHAT_DEPLOYMENT: ${{ vars.AZURE_OPENAI_CHAT_DEPLOYMENT }}
3938
AZURE_OPENAI_CHAT_MODEL: ${{ vars.AZURE_OPENAI_CHAT_MODEL }}
4039
AZURE_OPENAI_EMBED_DEPLOYMENT: ${{ vars.AZURE_OPENAI_EMBED_DEPLOYMENT }}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@
3636
"htmlcov": true,
3737
".mypy_cache": true,
3838
".coverage": true
39-
}
39+
},
40+
"python-envs.defaultEnvManager": "ms-python.python:system"
4041
}

AGENTS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,19 @@ When adding new azd environment variables, update:
88
1. infra/main.parameters.json : Add the new parameter with a Bicep-friendly variable name and map to the new environment variable
99
1. infra/main.bicep: Add the new Bicep parameter at the top, and add it to the `webAppEnv` object
1010
1. .github/workflows/azure-dev.yml: Add the new environment variable under `env` section. If it's a @secure variable in main.bicep, it should come from `secrets`, otherwise from `vars`.
11+
12+
## Upgrading Python packages
13+
14+
1. Update the version constraint in src/backend/pyproject.toml
15+
16+
2. Re-compile src/backend/requirements.txt from the src folder:
17+
18+
```shell
19+
uv pip compile pyproject.toml -o requirements.txt --python-version 3.10
20+
```
21+
22+
3. Reinstall with:
23+
24+
```shell
25+
python -m pip install -r src/backend/requirements.txt
26+
```

azure.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ pipeline:
4242
- OPENAI_CHAT_HOST
4343
- OPENAI_EMBED_HOST
4444
- AZURE_OPENAI_ENDPOINT
45-
- AZURE_OPENAI_VERSION
4645
- AZURE_OPENAI_CHAT_DEPLOYMENT
4746
- AZURE_OPENAI_CHAT_MODEL
4847
- AZURE_OPENAI_CHAT_DEPLOYMENT_VERSION

evals/eval_config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"use_advanced_flow": true,
99
"top": 3,
1010
"retrieval_mode": "hybrid",
11-
"temperature": 0.3,
12-
"seed": 42
11+
"temperature": 0.3
1312
}
1413
},
1514
"target_response_answer_jmespath": "message.content",

0 commit comments

Comments
 (0)