Class: RubyLlmMesh::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm_mesh/response.rb,
sig/ruby_llm_mesh.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, provider:, model: nil, usage: {}, raw: nil, latency_ms: nil, fallback_used: false, cache_hit: false) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ruby_llm_mesh/response.rb', line 7

def initialize(content:, provider:, model: nil, usage: {}, raw: nil, latency_ms: nil,
               fallback_used: false, cache_hit: false)
  @content = content
  @provider = provider
  @model = model
  @usage = usage || {}
  @raw = raw
  @latency_ms = latency_ms
  @fallback_used = fallback_used
  @cache_hit = cache_hit
end

Instance Attribute Details

#cache_hitBoolean (readonly)

Returns the value of attribute cache_hit.

Returns:

  • (Boolean)


5
6
7
# File 'lib/ruby_llm_mesh/response.rb', line 5

def cache_hit
  @cache_hit
end

#contentString (readonly)

Returns the value of attribute content.

Returns:

  • (String)


5
6
7
# File 'lib/ruby_llm_mesh/response.rb', line 5

def content
  @content
end

#fallback_usedBoolean (readonly)

Returns the value of attribute fallback_used.

Returns:

  • (Boolean)


5
6
7
# File 'lib/ruby_llm_mesh/response.rb', line 5

def fallback_used
  @fallback_used
end

#latency_msInteger? (readonly)

Returns the value of attribute latency_ms.

Returns:

  • (Integer, nil)


5
6
7
# File 'lib/ruby_llm_mesh/response.rb', line 5

def latency_ms
  @latency_ms
end

#modelString? (readonly)

Returns the value of attribute model.

Returns:

  • (String, nil)


5
6
7
# File 'lib/ruby_llm_mesh/response.rb', line 5

def model
  @model
end

#providerSymbol (readonly)

Returns the value of attribute provider.

Returns:

  • (Symbol)


5
6
7
# File 'lib/ruby_llm_mesh/response.rb', line 5

def provider
  @provider
end

#rawObject (readonly)

Returns the value of attribute raw.

Returns:

  • (Object)


5
6
7
# File 'lib/ruby_llm_mesh/response.rb', line 5

def raw
  @raw
end

#usageHash[untyped, untyped] (readonly)

Returns the value of attribute usage.

Returns:

  • (Hash[untyped, untyped])


5
6
7
# File 'lib/ruby_llm_mesh/response.rb', line 5

def usage
  @usage
end

Instance Method Details

#textString

Returns:

  • (String)


19
20
21
# File 'lib/ruby_llm_mesh/response.rb', line 19

def text
  content
end

#to_hHash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ruby_llm_mesh/response.rb', line 27

def to_h
  {
    content: content,
    provider: provider,
    model: model,
    usage: usage,
    latency_ms: latency_ms,
    fallback_used: fallback_used,
    cache_hit: cache_hit
  }
end

#to_sString

Returns:

  • (String)


23
24
25
# File 'lib/ruby_llm_mesh/response.rb', line 23

def to_s
  content.to_s
end