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', 'ollama' => 'OllamaAdapter', 'gemini' => 'GeminiAdapter' }.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
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dspy/lm/adapter_factory.rb', line 21 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 } # Both OpenAI and Ollama accept additional options .merge!() if %w[openai ollama].include?(provider) adapter_class.new(**) end |