LLM backend plugins#93
Open
jtoman wants to merge 3 commits into
Open
Conversation
Instead of hardcoding "anthropic" and "openai", we generalize ProviderKind into an abstract class, one with two key dynamic dispatches that encapsulate the behavior we would case split over the two constants for: selecting the correct memory tool implementation and text/file document rendering. This new ABC is called ProviderServices, and is threaded through everywhere the old ProviderKind was. Further, the actual providers are now auto-discovered and loaded via importlib.metadata entrypoints under `certora.autoprove.llm_provider`. These entrypoints are expected to resolve to an instance of ProviderSpec, which describes how to select which provider to use for a model name, and the provider itself. The provider is responsible for taking the model name and configuration options and producing a modelprovider; itself encapsulates the model "builder" (itself parameterized over caching/thinking behavior) and the "provider services", which is the ABC described above. As a validation of this approach, the existing OpenAI and anthropic providers have been moved to be "built in plugins". In principle adding Kimi, Qwen, Deepseek, etc. should simply be a matter of implementing the various Provider apis. Common base classes/abstractions are provided for the anticipated common cases to cut down on boilerplate. While doing this refactoring, took the opportunity to clean up some apis; including removing the (deprecated and very broken) get_checkpointer, the composer.workflow.providers shim, and other now unused and orphan llm builders.
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.
Instead of hardcoding "anthropic" and "openai", we generalize ProviderKind into an abstract class, one with two key dynamic dispatches that encapsulate the behavior we would case split over the two constants for: selecting the correct memory tool implementation and text/file document rendering. This new ABC is called ProviderServices, and is threaded through everywhere the old ProviderKind was.
Further, the actual providers are now auto-discovered and loaded via importlib.metadata entrypoints under
certora.autoprove.llm_provider. These entrypoints are expected to resolve to an instance of ProviderSpec, which describes how to select which provider to use for a model name, and the provider itself. The provider is responsible for taking the model name and configuration options and producing a modelprovider; itself encapsulates the model "builder" (itself parameterized over caching/thinking behavior) and the "provider services", which is the ABC described above.As a validation of this approach, the existing OpenAI and anthropic providers have been moved to be "built in plugins". In principle adding Kimi, Qwen, Deepseek, etc. should simply be a matter of implementing the various Provider apis. Common base classes/abstractions are provided for the anticipated common cases to cut down on boilerplate.
While doing this refactoring, took the opportunity to clean up some apis; including removing the (deprecated and very broken) get_checkpointer, the composer.workflow.providers shim, and other now unused and orphan llm builders.