feat: add LiteLLM judge api_type - #288
Open
prodmanpd wants to merge 1 commit into
Open
Conversation
Collaborator
|
Thanks for the contribution. Could you clarify the use case for adding a LiteLLM API type? ClawBench already have support for OpenAI, Anthropic, and Google GenAI API types and custom URLs, which should cover almost all cases calling LLM APIs I believe. Can you explain the motivation why a LiteLLM is needed for calling LLM APIs for the judge. |
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.
What does this PR do?
Adds a
litellmjudgeapi_type, so the ClawBench judge can reach any of 100+ providers (OpenAI, Anthropic, Gemini, Bedrock, Vertex, Azure, Groq, ...) through a single call instead of a per-wire-format raw-HTTP function.litellm.completionnatively speaks the OpenAI / Anthropic / Gemini / Bedrock protocols, so it collapses the existing per-api_typehandlers into one path, anddrop_params=Truekeeps a single call portable across providers.Changes:
src/clawbench/runner/judge.pyandjudge_llm.py- new_call_litellm(...)+ alitellmbranch in each judge's dispatch (mirrors the sibling_call_openai_chat/_call_anthropic_messages).src/clawbench/runner/run_support/api_preflight.py-litellmpreflight validation (a tiny call before containers run).src/clawbench/tui.py-litellmadded toAPI_TYPES+ a LiteLLM provider preset.pyproject.toml- optional extralitellm = ["litellm>=1.85.0,<2.0"](lazy-imported, so the base install is unaffected).tests/test_judge_litellm.py- dispatch / kwargs / preflight / import-error coverage.Additive and opt-in: existing
api_typehandlers are untouched;litellmis an optional dependency imported lazily inside_call_litellm, with a clear ImportError pointing topip install clawbench[litellm]if the api_type is used without it.Corpus
Test plan
uvenvironment:uv run --frozen pytest tests/test_judge_litellm.py-> 6 passed (dispatch in both judges,drop_params=True, credentials forwarded only when set, preflight, and the ImportError path).uv run --frozen ruff check .->All checks passed!;uv run --frozen ruff format --check .-> clean;uv run --frozen pyright <changed files>-> 0 errors.judge_llm.judge_requestwithapi_type: "litellm"routed through a LiteLLM proxy (gpt-4o-mini). Aligned instruction ->{"match": true, ...}; contradicting instruction ->{"match": false, "reason": "Instruction specifies 'BLUE shirt', request body shows 'item: red shirt'"}. This exercises the full chain:judge_request->api_typedispatch ->_call_litellm->litellm.completion-> provider -> parsed verdict.litellm>=1.85.0,<2.0installs against the current latest stable (1.97.0).