Module: LangsmithrbRails::Wrappers

Defined in:
lib/langsmithrb_rails/wrappers.rb,
lib/langsmithrb_rails/wrappers/llm.rb,
lib/langsmithrb_rails/wrappers/base.rb,
lib/langsmithrb_rails/wrappers/openai.rb,
lib/langsmithrb_rails/wrappers/anthropic.rb

Overview

Wrappers for LLM providers

Defined Under Namespace

Modules: Anthropic, Base, LLM, OpenAI

Class Method Summary collapse

Class Method Details

.traceable(object, method_name, run_name: nil, project_name: nil, tags: []) ⇒ Object

Create a traceable decorator for any method



37
38
39
# File 'lib/langsmithrb_rails/wrappers.rb', line 37

def self.traceable(object, method_name, run_name: nil, project_name: nil, tags: [])
  LLM.traceable(object, method_name, run_name: run_name, project_name: project_name, tags: tags)
end

.wrap(client, provider:, project_name: nil, tags: []) ⇒ Object

Wrap an LLM provider client with LangSmith tracing



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/langsmithrb_rails/wrappers.rb', line 17

def self.wrap(client, provider:, project_name: nil, tags: [])
  case provider.to_sym
  when :openai
    OpenAI.wrap(client, project_name: project_name, tags: tags)
  when :anthropic
    Anthropic.wrap(client, project_name: project_name, tags: tags)
  when :llm
    LLM.wrap(client, project_name: project_name, tags: tags)
  else
    raise ArgumentError, "Unsupported provider: #{provider}"
  end
end