Class: DSPy::Module

Inherits:
Object
  • Object
show all
Extended by:
T::Generic, T::Sig
Includes:
Dry::Configurable
Defined in:
lib/dspy/module.rb

Direct Known Subclasses

Predict

Instance Method Summary collapse

Instance Method Details

#call(**input_values) ⇒ Object



42
43
44
# File 'lib/dspy/module.rb', line 42

def call(**input_values)
  forward(**input_values)
end

#call_untyped(**input_values) ⇒ Object



48
49
50
# File 'lib/dspy/module.rb', line 48

def call_untyped(**input_values)
  forward_untyped(**input_values)
end

#forward(**input_values) ⇒ Object



23
24
25
26
# File 'lib/dspy/module.rb', line 23

def forward(**input_values)
  # Cast the result of forward_untyped to the expected output type
  T.cast(forward_untyped(**input_values), T.type_parameter(:O))
end

#forward_untyped(**input_values) ⇒ Object

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/dspy/module.rb', line 30

def forward_untyped(**input_values)
  raise NotImplementedError, "Subclasses must implement forward_untyped method"
end

#lmObject



54
55
56
# File 'lib/dspy/module.rb', line 54

def lm
  config.lm || DSPy.current_lm
end