Module: LlmCostTracker::Integrations
- Defined in:
- lib/llm_cost_tracker/integrations.rb,
lib/llm_cost_tracker/integrations/base.rb,
lib/llm_cost_tracker/integrations/openai.rb,
lib/llm_cost_tracker/integrations/ruby_llm.rb,
lib/llm_cost_tracker/integrations/anthropic.rb
Defined Under Namespace
Modules: Anthropic, Base, Openai, RubyLlm
Constant Summary
collapse
- AVAILABLE =
{
openai: Openai,
anthropic: Anthropic,
ruby_llm: RubyLlm
}.freeze
Class Method Summary
collapse
Class Method Details
.checks(names = LlmCostTracker.configuration.instrumented_integrations) ⇒ Object
22
23
24
25
26
|
# File 'lib/llm_cost_tracker/integrations.rb', line 22
def checks(names = LlmCostTracker.configuration.instrumented_integrations)
return [Base::Result.new(:integrations, :ok, "no SDK integrations enabled")] if names.empty?
normalize(names).map { |name| fetch(name).status }
end
|
.fetch(name) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/llm_cost_tracker/integrations.rb', line 32
def fetch(name)
AVAILABLE.fetch(name.to_sym) do
message = "Unknown integration: #{name.inspect}. Use one of: #{names.join(', ')}"
raise LlmCostTracker::Error, message
end
end
|
.install!(names = LlmCostTracker.configuration.instrumented_integrations) ⇒ Object
18
19
20
|
# File 'lib/llm_cost_tracker/integrations.rb', line 18
def install!(names = LlmCostTracker.configuration.instrumented_integrations)
normalize(names).each { |name| fetch(name).install }
end
|
.names ⇒ Object
39
40
41
|
# File 'lib/llm_cost_tracker/integrations.rb', line 39
def names
AVAILABLE.keys
end
|
.normalize(names) ⇒ Object
28
29
30
|
# File 'lib/llm_cost_tracker/integrations.rb', line 28
def normalize(names)
Array(names).flatten.map(&:to_sym).uniq
end
|