Class: ActiveGenie::Providers::UnifiedProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/active_genie/providers/unified_provider.rb

Constant Summary collapse

PROVIDER_NAME_TO_PROVIDER =
{
  openai: OpenaiProvider,
  anthropic: AnthropicProvider,
  google: GoogleProvider,
  deepseek: DeepseekProvider
}.freeze

Class Method Summary collapse

Class Method Details

.function_calling(messages, function, config: {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/active_genie/providers/unified_provider.rb', line 22

def function_calling(messages, function, config: {})
  model, provider_name = model_and_provider_by(config)

  provider = PROVIDER_NAME_TO_PROVIDER[provider_name&.to_sym]

  raise ActiveGenie::WithoutAvailableProviderError if provider.nil?

  config.llm.model = model

  response = provider.new(config).function_calling(messages, function)

  normalize_response(response)
end