Merged
Conversation
- Deleted client classes from the providers module. - Removed related imports and references in the __init__.py file. - Updated types.py to streamline core data models and removed unused classes. - Simplified utility functions in utils.py, focusing on message normalization and response creation.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Closed
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.
This branch replaces the old SDK-per-provider architecture with a unified HTTP layer backed by stateless adapters, removes ~9k lines of duplicated provider code, adds structured output, completes the provider matrix (OpenRouter), hardens the test suite, and polishes the public API surface.
Architecture Change
Before
src/chimeric/providers/<name>/client.py, each importing that provider's SDK (openai,anthropic,google-generativeai, etc.)base.py(1585 lines) held a monolithic base class shared by all providersAfter
httpxtransport for all providerssrc/chimeric/http.py— oneHttpClientwith sync + async paths, tool-execution loop, SSE parsingsrc/chimeric/adapters/— 4 stateless pure-function adapters (openai,anthropic,google,cohere)src/chimeric/config.py— immutableProviderConfigdataclass +PROVIDER_REGISTRY(8 providers)base_urlonly)pip install chimeric— no per-provider extrasWhat Changed
Core (
src/chimeric/)base.pyproviders/*/client.pyconfig.pyProviderConfigdataclass +PROVIDER_REGISTRYhttp.pyadapters/openai.pyadapters/anthropic.pyadapters/google.pyadapters/cohere.py/chatNDJSON-SSE adapterschema.pychimeric.pyresponse_modelsupport__init__.pyToolManager,ToolCallChunk,ToolExecutionResult,ToolParameters)New public API additions (
chimeric.py)base_url/api_keyconstructor params — registers a custom OpenAI-compatible endpoint (e.g. local llama.cpp / llama-swap / Ollama) as a"custom"provider with automatic model routingresponse_model— pass a Pydantic model class togenerate()/agenerate()for structured JSON output; the parsed instance is available onresponse.parsedTests
New test files
tests/unit/test_config.pyPROVIDER_REGISTRYstructure and immutabilitytests/unit/test_http.pyHttpClientURL/header building, error mappingtests/unit/test_schema.pytests/unit/adapters/test_openai.pytests/unit/adapters/test_anthropic.pytests/unit/adapters/test_google.pytests/unit/adapters/test_cohere.pytests/unit/test_doc_examples.pytests/integration/test_provider_openrouter.pytests/integration/test_structured_outputs.pyRemoved test files
Old SDK-based unit tests (
tests/unit/providers/test_*.py,tests/unit/test_base.py) deleted alongside the code they tested.Documentation
docs/index.mdnative=Truedocs/usage/getting-started.mdnative=True/stop_reason; fixed streaming field namesdocs/usage/configuration.mddocs/usage/local-ai.mdbase_urlusage, llama-swap / Ollama / LM Studiodocs/usage/streaming.mddocs/usage/responses.mdusagenullable guard addeddocs/usage/tools.mdget_capabilities()referencemkdocs.ymlBreaking Changes
native=Trueparameterresponse.metadatapip install chimericinstalls all providersToolManagertop-level exportchimeric.tools.ToolManagerToolCallChunk,ToolExecutionResult,ToolParameterschimeric.*— import fromchimeric.typesif needed