Add capability to override default GitHub Copilot authentication endp…#25915
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR adds support for configurable GitHub Copilot endpoints via environment variables ( Confidence Score: 5/5Safe to merge — all remaining findings are minor documentation polish with no impact on runtime behaviour. The three previously-critical issues (IndentationError at import time, inverted api_base priority in embedding, os.getenv inside the polling loop) are all resolved. The new env-var fallback chains are consistent across all three transformation files, env-var lookups are correctly hoisted above retry loops in the authenticator, and the five new authenticator tests are mock-only and well-structured. The only remaining findings are P2 style issues in the provider documentation. docs/my-website/docs/providers/github_copilot.md — unclosed parenthesis in comment and missing GITHUB_COPILOT_CLIENT_ID from the example block
|
| Filename | Overview |
|---|---|
| litellm/llms/github_copilot/authenticator.py | Renames module-level constants to DEFAULT_* prefix and adds os.getenv() calls to support overriding URLs and client ID at call time; env var lookups are correctly hoisted above retry loops |
| litellm/llms/github_copilot/common_utils.py | Renames GITHUB_COPILOT_API_BASE constant to DEFAULT_GITHUB_COPILOT_API_BASE for consistency; no logic changes |
| litellm/llms/github_copilot/chat/transformation.py | Updates api_base fallback chain to: caller-supplied api_base → authenticator cache → GITHUB_COPILOT_API_BASE env var → hardcoded default; now consistent with embedding and responses paths |
| litellm/llms/github_copilot/embedding/transformation.py | Fixes previously-inverted api_base priority (was: authenticator → caller → default) to the correct order: caller → authenticator → env var → default; also adds env var layer |
| litellm/llms/github_copilot/responses/transformation.py | Adds GITHUB_COPILOT_API_BASE env var layer to the existing correct fallback chain; removes stale docstring that previously limited support to individual accounts only |
| tests/test_litellm/llms/github_copilot/test_github_copilot_authenticator.py | Adds 5 new mock-only tests covering all 4 new authenticator env vars (DEVICE_CODE_URL, ACCESS_TOKEN_URL, API_KEY_URL, CLIENT_ID); tests correctly use patch.dict and assert exact call arguments |
| docs/my-website/docs/providers/github_copilot.md | Documents 4 of the 5 new env vars; missing GITHUB_COPILOT_CLIENT_ID and has an unclosed parenthesis in the comment block |
| docs/my-website/docs/proxy/config_settings.md | Adds all 5 new env vars including GITHUB_COPILOT_CLIENT_ID with correct default value matching the code |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Request to github_copilot provider] --> B{api_base supplied?}
B -- Yes --> E[Use supplied api_base]
B -- No --> C{authenticator.get_api_base from api-key.json?}
C -- Yes --> E
C -- No --> D{GITHUB_COPILOT_API_BASE env var set?}
D -- Yes --> E
D -- No --> F[Use DEFAULT_GITHUB_COPILOT_API_BASE]
E --> G[Append /chat, /embeddings, or /responses]
H[Device code auth flow] --> I{GITHUB_COPILOT_DEVICE_CODE_URL set?}
I -- Yes --> J[POST to custom URL]
I -- No --> K[POST to github.com/login/device/code]
L[Poll for access token] --> M{GITHUB_COPILOT_ACCESS_TOKEN_URL set?}
M -- Yes --> N[POST to custom URL]
M -- No --> O[POST to github.com/login/oauth/access_token]
P[Refresh API key] --> Q{GITHUB_COPILOT_API_KEY_URL set?}
Q -- Yes --> R[GET from custom URL]
Q -- No --> S[GET from api.github.com/copilot_internal/v2/token]
Reviews (8): Last reviewed commit: "Fix default value for Copilot client ID ..." | Re-trigger Greptile
0e5d083 to
1b928e3
Compare
…oints This feature adds support for GitHub Enterprise subsriptions with custom domain/data ownership (which use a different URL compared to standard accounts)
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1c46260 to
259dfdf
Compare
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
f69b9d6
into
BerriAI:litellm_internal_staging
BerriAI#25915) * Add capability to override default GitHub Copilot authentication endpoints This feature adds support for GitHub Enterprise subsriptions with custom domain/data ownership (which use a different URL compared to standard accounts) * Update documentation with new parameters * Move access token URL and Client ID retrieval outside for loop Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * Fix spurious comment from Greptile review * Align api_base retrieval behavior across chat and embedding transformations * Add missing GitHub Copilot client ID parameter in docs * Update website documentation with newer options for GitHub Enterprise Copilot * Fix default value for Copilot client ID in docs Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Relevant issues
Fixes #25914
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
CI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Screenshots / Proof of Fix
Type
🆕 New Feature
Changes