Class: Agent::SessionContext::Renderers::JSONLines

Inherits:
Object
  • Object
show all
Defined in:
lib/agent/session_context/renderers/json_lines.rb

Instance Method Summary collapse

Instance Method Details

#call(value) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/agent/session_context/renderers/json_lines.rb', line 7

def call(value)
  # Same privacy rule as Renderers::JSON: never hand the Loop itself
  # (or its round trips, which carry Message#raw) to Serializer. One
  # line per round trip, from the already-stripped LoopView Hash.
  return loop_lines(value) if value.is_a?(Loop)

  Array(value).map { |prompt| ::JSON.generate(Serializer.serialize(prompt)) }.join("\n")
end