Class: DSPy::LM::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/dspy/lm/response.rb

Overview

Normalized response format for all LM providers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, usage: nil, metadata: {}) ⇒ Response

Returns a new instance of Response.



9
10
11
12
13
# File 'lib/dspy/lm/response.rb', line 9

def initialize(content:, usage: nil, metadata: {})
  @content = content
  @usage = usage
  @metadata = 
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



7
8
9
# File 'lib/dspy/lm/response.rb', line 7

def content
  @content
end

#metadataObject (readonly)

Returns the value of attribute metadata.



7
8
9
# File 'lib/dspy/lm/response.rb', line 7

def 
  @metadata
end

#usageObject (readonly)

Returns the value of attribute usage.



7
8
9
# File 'lib/dspy/lm/response.rb', line 7

def usage
  @usage
end

Instance Method Details

#to_hObject



19
20
21
22
23
24
25
# File 'lib/dspy/lm/response.rb', line 19

def to_h
  {
    content: content,
    usage: usage,
    metadata: 
  }
end

#to_sObject



15
16
17
# File 'lib/dspy/lm/response.rb', line 15

def to_s
  content
end