Module: Rach::Provider
- Defined in:
- lib/rach/provider.rb,
lib/rach/provider/base.rb,
lib/rach/provider/google.rb,
lib/rach/provider/openai.rb,
lib/rach/provider/anthropic.rb more...
Defined Under Namespace
Classes: Anthropic, Base, Google, OpenAI
Constant Summary
collapse
- AVAILABLE_PROVIDERS =
[
Provider::OpenAI,
Provider::Anthropic,
Provider::Google
].to_h { |p| [p.key, p] }.freeze
Class Method Summary
collapse
Class Method Details
permalink
.create_client(provider_key, access_token) ⇒ Object
[View source]
17
18
19
20
|
# File 'lib/rach/provider.rb', line 17
def self.create_client(provider_key, access_token)
provider_class = get_provider_class(provider_key)
provider_class.new(access_token:)
end
|
permalink
.for(model) ⇒ Object
[View source]
10
11
12
13
14
15
|
# File 'lib/rach/provider.rb', line 10
def self.for(model)
_key, provider_class = AVAILABLE_PROVIDERS.find { |_, p| p.supports?(model) }
raise ArgumentError, "Unsupported model: #{model}" unless provider_class
provider_class
end
|
permalink
.get_provider_class(key) ⇒ Object
[View source]
22
23
24
25
26
|
# File 'lib/rach/provider.rb', line 22
def self.get_provider_class(key)
provider_class = AVAILABLE_PROVIDERS[key.to_sym]
raise ArgumentError, "Unknown provider: #{key}" unless provider_class
provider_class
end
|