Skip to content

Route OpenAI o-series and gpt-3.5 model IDs to the OpenAI provider - #494

Open
rahul188 wants to merge 2 commits into
google:mainfrom
rahul188:fix-492-openai-model-patterns
Open

Route OpenAI o-series and gpt-3.5 model IDs to the OpenAI provider#494
rahul188 wants to merge 2 commits into
google:mainfrom
rahul188:fix-492-openai-model-patterns

Conversation

@rahul188

Copy link
Copy Markdown

Description

OPENAI_PATTERNS in langextract/providers/patterns.py only enumerates the gpt-4* / gpt-5* families, so valid OpenAI model IDs from the reasoning line (o1, o3, o3-mini, o4-mini) and the legacy gpt-3.5-turbo family match no pattern and router.resolve raises InferenceConfigError, even though OpenAILanguageModel can serve them.

This adds two patterns:

  • ^gpt-3\.5 — the gpt-3.5-turbo family
  • ^o[1-9] — the o-series reasoning models; the required digit keeps other o-prefixed IDs (e.g. openchat) falling through to the unregistered-model error as before, and it does not collide with any built-in Ollama/Gemini pattern

The new test resolves o1, o3-mini, o4-mini, gpt-3.5-turbo (and gpt-4o as a guard against regressions) to OpenAILanguageModel, and asserts openchat still raises InferenceConfigError so the o-series pattern can't over-match.

Fixes #492

Bug fix

How Has This Been Tested?

$ python -m pytest tests/registry_test.py -q
15 passed, 12 subtests passed

$ python -m pytest tests -q -m "not live_api and not requires_pip" --ignore=tests/test_live_api.py
707 passed, 5 skipped, 1 deselected

The new test was run against unmodified main first and fails there on exactly the four uncovered model IDs (SUBFAILED for o1, o3-mini, o4-mini, gpt-3.5-turbo; gpt-4o passes), and passes with the fix. pyink, isort, and pylint are clean on the changed files.

Checklist:

OPENAI_PATTERNS only enumerated the gpt-4 and gpt-5 families, so valid
OpenAI model IDs from the reasoning line (o1, o3, o3-mini, o4-mini) and
the legacy gpt-3.5-turbo family matched no provider and router.resolve
raised InferenceConfigError. Add patterns for both families. The
o-series pattern requires a digit after the o, so other o-prefixed IDs
still fall through to the unregistered-model error.

Fixes google#492
@github-actions github-actions Bot added the size/XS Pull request with less than 50 lines changed label Jul 22, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Branch Update Required

Your branch is 1 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Pull request with less than 50 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: OpenAI o-series (o1/o3/o4-mini) and gpt-3.5 model IDs route to no provider

1 participant