Replace litellm with direct OpenAI and Anthropic SDKs - #11
Merged
Conversation
Remove litellm dependency due to security concerns and replace with direct openai and anthropic SDK integrations as optional extras. - Add OpenAITranslator for OpenAI, Ollama, and Gemini (via OpenAI-compatible APIs) - Add AnthropicTranslator with thinking config mapping for reasoning effort - Extract shared helpers (_shared.py): prompt builders, retry decorator, JSON parsing, model name extraction, content validation - Add calculate_usage_cost() to cost.py (replaces litellm's completion_cost) - Add SDK presence checks to doctor.py diagnostics - Make openai/anthropic installable as extras: tinbox[openai], tinbox[anthropic] - Update factory to lazy-import translators based on ModelType - All 284 tests pass at 84% coverage
- Convert all str+Enum classes to StrEnum (Python 3.12+) - Use astral-sh/setup-uv in CI for faster installs - All ruff checks now pass (UP042 resolved)
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
OpenAITranslator(handles OpenAI, Ollama, Gemini via OpenAI-compatible APIs) andAnthropicTranslator(with thinking config mapping for reasoning effort)tinbox[openai],tinbox[anthropic], ortinbox[all]for everythingstr, Enum→StrEnum(Python 3.12+), useuvin GitHub ActionsProvider matrix
openai:gpt-5-...OpenAITranslatortinbox[openai]ollama:llama3.1:8bOpenAITranslatortinbox[openai]gemini:gemini-2.5-proOpenAITranslatortinbox[openai]anthropic:claude-...AnthropicTranslatortinbox[anthropic]Key design decisions
_shared.pymodule: prompt construction, JSON parsing, retry decorator, and content validation are shared across both translators — no behavioral driftcreate_translator()uses local imports so base install works without any provider SDKgenerativelanguage.googleapis.com)OPENAI_BASE_URLenv var (documented in README)Test plan
uv pip install -e ".[dev]"installs cleanly