Class: DSPy::LM::AdapterFactory
- Inherits:
-
Object
- Object
- DSPy::LM::AdapterFactory
- Defined in:
- lib/dspy/lm/adapter_factory.rb
Overview
Factory for creating appropriate adapters based on model_id
Constant Summary collapse
- ADAPTER_MAP =
Maps provider prefixes to adapter classes
{ 'openai' => 'OpenAIAdapter', 'anthropic' => 'AnthropicAdapter' }.freeze
Class Method Summary collapse
-
.create(model_id, api_key:, **options) ⇒ DSPy::LM::Adapter
Creates an adapter instance based on model_id.
Class Method Details
.create(model_id, api_key:, **options) ⇒ DSPy::LM::Adapter
Creates an adapter instance based on model_id
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dspy/lm/adapter_factory.rb', line 19 def create(model_id, api_key:, **) provider, model = parse_model_id(model_id) adapter_class = get_adapter_class(provider) # Pass provider-specific options = { model: model, api_key: api_key } .merge!() if provider == 'openai' # Only OpenAI accepts structured_outputs for now adapter_class.new(**) end |