Skip to content

Support OPENAI_BASE_URL routing and JSON parsing#453

Open
bpulluta wants to merge 6 commits into
mainfrom
litellm-dev
Open

Support OPENAI_BASE_URL routing and JSON parsing#453
bpulluta wants to merge 6 commits into
mainfrom
litellm-dev

Conversation

@bpulluta
Copy link
Copy Markdown
Collaborator

Summary

  • add OPENAI_BASE_URL and OPENAI_API_KEY env mapping for openai client config
  • keep explicit client kwargs precedence for backward compatibility
  • add fallback parser for responses that include prose before JSON
  • add unit tests for openai config env handling and parsing fallback

Validation

  • pixi run -e pdev ruff check compass/llm/config.py compass/utilities/parsing.py tests/python/unit/utilities/test_utilities_parsing.py tests/python/unit/llm/test_config.py
  • pixi run -e pdev pytest -q tests/python/unit/utilities/test_utilities_parsing.py tests/python/unit/llm/test_config.py

Copilot AI review requested due to automatic review settings May 28, 2026 21:42
@bpulluta bpulluta changed the title Support OPENAI_BASE_URL routing and robust JSON parsing Support OPENAI_BASE_URL routing and JSON parsing May 28, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.18%. Comparing base (9c17ada) to head (da66d3f).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #453      +/-   ##
==========================================
+ Coverage   56.11%   61.18%   +5.07%     
==========================================
  Files          63       77      +14     
  Lines        6080     6846     +766     
  Branches      591      675      +84     
==========================================
+ Hits         3412     4189     +777     
+ Misses       2598     2542      -56     
- Partials       70      115      +45     
Flag Coverage Δ
unittests 61.18% <100.00%> (+5.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds OpenAI environment-based client configuration and makes LLM JSON response parsing more tolerant of prose-wrapped JSON, supporting routed OpenAI-compatible endpoints.

Changes:

  • Maps OPENAI_API_KEY and OPENAI_BASE_URL into OpenAI client kwargs while preserving explicit kwargs precedence.
  • Adds fallback parsing for embedded JSON payloads after strict JSON decoding fails.
  • Adds unit tests for OpenAI config env handling and prose-before-JSON parsing.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
compass/llm/config.py Adds OpenAI env var mapping for client initialization.
compass/utilities/parsing.py Adds fallback recovery for embedded JSON objects or arrays.
tests/python/unit/llm/test_config.py Adds tests for OpenAI and Azure client kwargs env handling.
tests/python/unit/utilities/test_utilities_parsing.py Adds coverage for prose-prefixed JSON parsing.

Comment thread compass/utilities/parsing.py Outdated
Comment thread compass/utilities/parsing.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread compass/utilities/parsing.py
bpulluta and others added 2 commits June 3, 2026 10:08
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants