From 609a67b02b20273cf0e4c5316846767a7cfd744c Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:03:45 -0700 Subject: [PATCH 01/13] Add GitHub testing workflow --- .github/workflows/test-github-models.yaml | 50 +++++++++++++++++++++++ reasoning.py | 14 +++++-- 2 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test-github-models.yaml diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml new file mode 100644 index 0000000..6abc423 --- /dev/null +++ b/.github/workflows/test-github-models.yaml @@ -0,0 +1,50 @@ +name: Test GitHub Models + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # Also run when chat.py files are modified + paths: + - 'chat.py' + - 'spanish/chat.py' + - 'requirements.txt' + - '.github/workflows/test-github-models.yaml' + +jobs: + test-github-models: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v5 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Test main chat.py with GitHub Models + env: + API_HOST: github + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_MODEL: gpt-4o-mini + run: | + echo "Testing main chat.py file..." + python chat.py + + - name: Test Spanish chat.py with GitHub Models + env: + API_HOST: github + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_MODEL: gpt-4o-mini + run: | + echo "Testing Spanish chat.py file..." + python spanish/chat.py diff --git a/reasoning.py b/reasoning.py index 5bb30ea..8a0e2bd 100644 --- a/reasoning.py +++ b/reasoning.py @@ -37,11 +37,19 @@ messages=[ { "role": "user", - "content": "Multiply together 1897234 and 12903812039.", + "content": "How many r's are in strawberry? Answer in a complete sentence with explanation.", }, ], - reasoning_effort="minimal", - verbosity="low", + reasoning_effort="low", ) + +# Reasoning contnet is only available for gpt-oss models running on Ollama +# To see reasoning traces with gpt-5 family, use the Responses API +if hasattr(response.choices[0].message, "reasoning"): + print("🤔 Thinking...") + print(response.choices[0].message.reasoning) + print("🛑 Done thinking.") +print("Response:") print(response.choices[0].message.content) +print("Usage:") print(response.usage) From f2651924151f5108b5b75b6e3f02377b019dafcd Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:06:10 -0700 Subject: [PATCH 02/13] Modify chat.py --- .github/workflows/test-github-models.yaml | 1 + chat.py | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml index 6abc423..aaee3bd 100644 --- a/.github/workflows/test-github-models.yaml +++ b/.github/workflows/test-github-models.yaml @@ -8,6 +8,7 @@ on: # Also run when chat.py files are modified paths: - 'chat.py' + - 'reasoning.py' - 'spanish/chat.py' - 'requirements.txt' - '.github/workflows/test-github-models.yaml' diff --git a/chat.py b/chat.py index 76e343a..252f395 100644 --- a/chat.py +++ b/chat.py @@ -12,10 +12,9 @@ token_provider = azure.identity.get_bearer_token_provider( azure.identity.DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default" ) - client = openai.AzureOpenAI( - api_version=os.environ["AZURE_OPENAI_VERSION"], - azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"], - azure_ad_token_provider=token_provider, + client = openai.OpenAI( + base_url=os.environ["AZURE_OPENAI_ENDPOINT"], + api_key=token_provider, ) MODEL_NAME = os.environ["AZURE_OPENAI_DEPLOYMENT"] From 80b27c370a2ebe33ba9c16889788334477d7b188 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:07:50 -0700 Subject: [PATCH 03/13] Modify chat.py --- .github/workflows/test-github-models.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml index aaee3bd..f638278 100644 --- a/.github/workflows/test-github-models.yaml +++ b/.github/workflows/test-github-models.yaml @@ -36,7 +36,7 @@ jobs: env: API_HOST: github GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_MODEL: gpt-4o-mini + GITHUB_MODEL: openai/gpt-4o-mini run: | echo "Testing main chat.py file..." python chat.py @@ -45,7 +45,7 @@ jobs: env: API_HOST: github GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_MODEL: gpt-4o-mini + GITHUB_MODEL: openai/gpt-4o-mini run: | echo "Testing Spanish chat.py file..." python spanish/chat.py From 428845abafd2103a0e4f66e6e51292e199cba153 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:19:06 -0700 Subject: [PATCH 04/13] Clean up the workflow --- .github/workflows/test-github-models.yaml | 30 +++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml index f638278..9454469 100644 --- a/.github/workflows/test-github-models.yaml +++ b/.github/workflows/test-github-models.yaml @@ -1,4 +1,4 @@ -name: Test GitHub Models +name: Test example files are working with GitHub models on: push: @@ -8,7 +8,6 @@ on: # Also run when chat.py files are modified paths: - 'chat.py' - - 'reasoning.py' - 'spanish/chat.py' - 'requirements.txt' - '.github/workflows/test-github-models.yaml' @@ -18,6 +17,11 @@ jobs: runs-on: ubuntu-latest permissions: contents: read + strategy: + matrix: + python_file: + - "chat.py" + - "spanish/chat.py" steps: - uses: actions/checkout@v5 @@ -25,27 +29,21 @@ jobs: - name: Set up Python 3.11 uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version-file: "pyproject.toml" + + - name: Install uv + uses: astral-sh/setup-uv@v6 - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Test main chat.py with GitHub Models + uv pip install -r requirements.txt env: - API_HOST: github - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_MODEL: openai/gpt-4o-mini - run: | - echo "Testing main chat.py file..." - python chat.py + UV_SYSTEM_PYTHON: 1 - - name: Test Spanish chat.py with GitHub Models + - name: Test ${{ matrix.python_file }} with GitHub Models env: API_HOST: github GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_MODEL: openai/gpt-4o-mini run: | - echo "Testing Spanish chat.py file..." - python spanish/chat.py + python ${{ matrix.python_file }} From f5c8e7ab1c02d193582994acf715502c5d7ccfb9 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:24:02 -0700 Subject: [PATCH 05/13] Get uv working hopefully --- .github/workflows/test-github-models.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml index 9454469..2ba5f7c 100644 --- a/.github/workflows/test-github-models.yaml +++ b/.github/workflows/test-github-models.yaml @@ -37,8 +37,6 @@ jobs: - name: Install dependencies run: | uv pip install -r requirements.txt - env: - UV_SYSTEM_PYTHON: 1 - name: Test ${{ matrix.python_file }} with GitHub Models env: From eb52f201d5ab15c8c58bbaa48b86689f775678ab Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:25:12 -0700 Subject: [PATCH 06/13] Get uv working hopefully --- .github/workflows/test-github-models.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml index 2ba5f7c..3c76579 100644 --- a/.github/workflows/test-github-models.yaml +++ b/.github/workflows/test-github-models.yaml @@ -17,11 +17,6 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - strategy: - matrix: - python_file: - - "chat.py" - - "spanish/chat.py" steps: - uses: actions/checkout@v5 @@ -38,10 +33,14 @@ jobs: run: | uv pip install -r requirements.txt - - name: Test ${{ matrix.python_file }} with GitHub Models + - name: Test chat files with GitHub Models env: API_HOST: github GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_MODEL: openai/gpt-4o-mini run: | - python ${{ matrix.python_file }} + files=("chat.py" "spanish/chat.py") + for file in "${files[@]}"; do + echo "Testing $file..." + python "$file" || exit 1 + done From 0a634bf41d91d16b7831039bb021a088dabea1e9 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:27:30 -0700 Subject: [PATCH 07/13] Get uv working hopefully --- .github/workflows/python.yaml | 2 +- .github/workflows/test-github-models.yaml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 183f9ec..75821f5 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -1,4 +1,4 @@ -name: Python checks +name: Check example files are linted and formatted on: push: diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml index 3c76579..9c96f4b 100644 --- a/.github/workflows/test-github-models.yaml +++ b/.github/workflows/test-github-models.yaml @@ -31,6 +31,7 @@ jobs: - name: Install dependencies run: | + uv venv .venv uv pip install -r requirements.txt - name: Test chat files with GitHub Models @@ -39,8 +40,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_MODEL: openai/gpt-4o-mini run: | + source .venv/bin/activate files=("chat.py" "spanish/chat.py") for file in "${files[@]}"; do echo "Testing $file..." - python "$file" || exit 1 + uv python "$file" || exit 1 done From c3ad4b3a5e04efae84b8edf9984ed6669ec0cb7e Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:28:09 -0700 Subject: [PATCH 08/13] Get uv working hopefully --- .github/workflows/test-github-models.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml index 9c96f4b..5e76284 100644 --- a/.github/workflows/test-github-models.yaml +++ b/.github/workflows/test-github-models.yaml @@ -44,5 +44,5 @@ jobs: files=("chat.py" "spanish/chat.py") for file in "${files[@]}"; do echo "Testing $file..." - uv python "$file" || exit 1 + python "$file" || exit 1 done From 15c758114de20fc447afe0b7fe025b686adef355 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:29:31 -0700 Subject: [PATCH 09/13] Get uv working hopefully --- .github/workflows/test-github-models.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml index 5e76284..0e49878 100644 --- a/.github/workflows/test-github-models.yaml +++ b/.github/workflows/test-github-models.yaml @@ -5,12 +5,14 @@ on: branches: [ main ] pull_request: branches: [ main ] - # Also run when chat.py files are modified paths: - - 'chat.py' - - 'spanish/chat.py' - 'requirements.txt' - '.github/workflows/test-github-models.yaml' + - 'chat.py' + - 'spanish/chat.py' + +permissions: + models: read jobs: test-github-models: From fbf5d6dfbb20390c29348e1d64e7a95f01a3f448 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:31:07 -0700 Subject: [PATCH 10/13] Get uv working hopefully --- .github/workflows/test-github-models.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml index 0e49878..1867514 100644 --- a/.github/workflows/test-github-models.yaml +++ b/.github/workflows/test-github-models.yaml @@ -13,6 +13,7 @@ on: permissions: models: read + contents: read jobs: test-github-models: From e3abfbcd269a69ba66faad55e9c371a8e9b5f5e8 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:34:43 -0700 Subject: [PATCH 11/13] Get uv working hopefully --- .github/workflows/test-github-models.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml index 1867514..d8a5741 100644 --- a/.github/workflows/test-github-models.yaml +++ b/.github/workflows/test-github-models.yaml @@ -1,4 +1,4 @@ -name: Test example files are working with GitHub models +name: Run example files with GitHub models on: push: @@ -11,15 +11,12 @@ on: - 'chat.py' - 'spanish/chat.py' -permissions: - models: read - contents: read - jobs: test-github-models: runs-on: ubuntu-latest permissions: contents: read + models: read steps: - uses: actions/checkout@v5 From fa0c55780fb886dde6164ed9835cc96fc7ceaf86 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 13:46:21 -0700 Subject: [PATCH 12/13] Use uv in both places --- .github/workflows/python.yaml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 75821f5..3a7b84a 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -15,11 +15,15 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.11" - - name: Install dependencies + - name: Install uv + uses: astral-sh/setup-uv@v6 + - name: Set up virtual environment and install dependencies run: | - python -m pip install --upgrade pip - pip install -r requirements-dev.txt + uv venv .venv + uv pip install -r requirements-dev.txt - name: Lint with ruff - run: ruff check . + run: | + uv run ruff check . - name: Check formatting with black - run: black . --check --verbose + run: | + uv run black . --check --verbose From 4a30c881da588d4871f017e2f22424c5d3f17c82 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 22 Sep 2025 14:01:48 -0700 Subject: [PATCH 13/13] Revert chat.py changes --- chat.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/chat.py b/chat.py index 252f395..76e343a 100644 --- a/chat.py +++ b/chat.py @@ -12,9 +12,10 @@ token_provider = azure.identity.get_bearer_token_provider( azure.identity.DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default" ) - client = openai.OpenAI( - base_url=os.environ["AZURE_OPENAI_ENDPOINT"], - api_key=token_provider, + client = openai.AzureOpenAI( + api_version=os.environ["AZURE_OPENAI_VERSION"], + azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"], + azure_ad_token_provider=token_provider, ) MODEL_NAME = os.environ["AZURE_OPENAI_DEPLOYMENT"]