Class: DSPy::Anthropic::Guardrails

Inherits:
Object
  • Object
show all
Defined in:
lib/dspy/anthropic/guardrails.rb

Constant Summary collapse

SUPPORTED_ANTHROPIC_VERSIONS =
"~> 1.12".freeze

Class Method Summary collapse

Class Method Details

.ensure_anthropic_installed!Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dspy/anthropic/guardrails.rb', line 10

def self.ensure_anthropic_installed!
  require 'anthropic'

  spec = Gem.loaded_specs["anthropic"]
  unless spec && Gem::Requirement.new(SUPPORTED_ANTHROPIC_VERSIONS).satisfied_by?(spec.version)
    msg = "      DSPY requires the `anthropic` gem \#{SUPPORTED_ANTHROPIC_VERSIONS}.\n      Please install or upgrade it with `bundle add anthropic --version \"\#{SUPPORTED_ANTHROPIC_VERSIONS}\"`.\n    MSG\n    raise DSPy::LM::UnsupportedVersionError, msg\n  end\nend\n"