feat: add [ LiteLLM AI Gateway ] for provider independence#186
Open
Aarish Alam (RheagalFire) wants to merge 3 commits intobraintrustdata:mainfrom
Open
feat: add [ LiteLLM AI Gateway ] for provider independence#186Aarish Alam (RheagalFire) wants to merge 3 commits intobraintrustdata:mainfrom
Aarish Alam (RheagalFire) wants to merge 3 commits intobraintrustdata:mainfrom
Conversation
Author
|
cc Ankur Goyal (@ankrgyl) Olmo Maldonado (@ibolmo). would like your review here. |
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
Fits cleanly into the existing LLMClient architecture (py/autoevals/oai.py:129) which is duck-typed on the OpenAI v1 protocol. The adapter implements that surface; no changes to core.
Changes
py/autoevals/litellm.py: LiteLLMClient / AsyncLiteLLMClient + _LiteLLMResponses adapter that translates Responses-API params (input=, flat tool schema) back to Chat-Completions params (messages=, nested tool schema) before calling litellm.completion.
py/autoevals/init.py: re-exports the new clients.
setup.py: litellm optional extra.
py/autoevals/test_litellm.py: 9 mocked tests (adds coverage for Responses-API shim input→messages translation and flat→nested tool-schema translation).
Testing & Usage
Unit tests (all pass):
Live end-to-end smoke test against Azure OpenAI (
azure/gpt-4o):This exercised three paths. (1) raw chat.completions.create routed to litellm.completion. (2) full scorer path init(client=LiteLLMClient()) → Factuality.eval() → LLMClient.complete → shim → litellm.completion → parsed score with rationale. (3) Responses-API shim with input=... kwarg, which translates to messages=... before reaching LiteLLM (exercises the fix for the default gpt-5-mini routing).
Example usage
from autoevals import init
from autoevals.litellm import LiteLLMClient
from autoevals.llm import Factuality
init(
client=LiteLLMClient(),
default_model="anthropic/claude-3-5-sonnet-20241022",
)
evaluator = Factuality()
result = evaluator.eval(input="...", output="...", expected="...")
init(client=LiteLLMClient(), default_model="bedrock/anthropic.claude-3-sonnet-20240229-v1:0")
init(client=LiteLLMClient(), default_model="gemini/gemini-1.5-pro")
init(client=LiteLLMClient(), default_model="ollama/llama3")
from autoevals.litellm import AsyncLiteLLMClient
init(client=AsyncLiteLLMClient(), default_model="openai/gpt-4o-mini")