Feat/add litellm provider#268
Open
RheagalFire wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #268 +/- ##
==========================================
+ Coverage 21.96% 23.63% +1.67%
==========================================
Files 8 39 +31
Lines 346 2187 +1841
==========================================
+ Hits 76 517 +441
- Misses 264 1629 +1365
- Partials 6 41 +35
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
go-openaiSDK since the LiteLLM proxy speaks the OpenAI Chat Completions protocol.Motivation
CodeGPT currently supports 4 providers (OpenAI, Azure, Gemini, Anthropic) plus OpenAI-compatible endpoints via
base_url. Users who want to use providers like AWS Bedrock, Google Vertex AI, Groq, Mistral, or Cohere need to set up separate proxy infrastructure. LiteLLM is a widely-adopted open-source AI gateway (45k+ GitHub stars) that normalizes 100+ provider APIs into the OpenAI format - users runlitellm --model anthropic/claude-sonnet-4-6and get a local OpenAI-compatible server atlocalhost:4000.Adding LiteLLM as a named provider (instead of requiring users to manually configure
base_url) provides:litellm.*config namespace (api_key, base_url, api_key_helper)codegpt config set openai.provider litellmChanges
provider/litellm/litellm.go- New LiteLLM client implementingcore.Generative(Completion, CompletionStream, GetSummaryPrefix with function-call fallback)provider/litellm/options.go- Functional options pattern matching existing providers (WithToken, WithModel, WithBaseURL, etc.)provider/litellm/func.go- Conventional commit prefix extraction via OpenAI-format tool callsprovider/litellm/func_test.go- Unit test for summary prefix argument parsingprovider/litellm/options_test.go- Config validation, defaults, and option application testsprovider/litellm/stream_test.go- Mock SSE server tests for streaming, completion, function calling, fallback, and error handlingcore/platform.go- AddedLiteLLMplatform constantcmd/provider.go- AddedNewLiteLLM()factory andGetClient()dispatchcmd/config_list.go- Addedlitellm.*config key descriptionscmd/config_set.go- Addedlitellm.*CLI flags and viper bindingscmd/cmd.go- Addedlitellm.api_keyto sensitive credential storeTests
1. Unit tests (12 tests, 89.9% coverage):
2. Full test suite - 0 regressions across all packages.
3. Lint clean:
make lint->0 issues.4. Build clean:
go build ./...succeeds with no errors.Risk / Compatibility
sashabaranov/go-openaiSDK.litellm.api_keytoopenai.api_keyif not set.Example usage