Class: Agent::SessionContext::Transcript
- Inherits:
-
Data
- Object
- Data
- Agent::SessionContext::Transcript
- Defined in:
- lib/agent/session_context/transcript.rb
Instance Attribute Summary collapse
-
#captured_at ⇒ Object
readonly
Returns the value of attribute captured_at.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
- .capture(session, reader: Agent::Sessions.read(session), now: Time.now) ⇒ Object
- .injection_kind(agent, text) ⇒ Object
Instance Method Summary collapse
-
#initialize(session:, captured_at:, entries:, warnings:) ⇒ Transcript
constructor
A new instance of Transcript.
Constructor Details
#initialize(session:, captured_at:, entries:, warnings:) ⇒ Transcript
Returns a new instance of Transcript.
186 187 188 189 190 191 192 193 |
# File 'lib/agent/session_context/transcript.rb', line 186 def initialize(session:, captured_at:, entries:, warnings:) super( session: session, captured_at: captured_at, entries: normalize_entries(entries), warnings: normalize_warnings(warnings) ) end |
Instance Attribute Details
#captured_at ⇒ Object (readonly)
Returns the value of attribute captured_at
111 112 113 |
# File 'lib/agent/session_context/transcript.rb', line 111 def captured_at @captured_at end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries
111 112 113 |
# File 'lib/agent/session_context/transcript.rb', line 111 def entries @entries end |
#session ⇒ Object (readonly)
Returns the value of attribute session
111 112 113 |
# File 'lib/agent/session_context/transcript.rb', line 111 def session @session end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings
111 112 113 |
# File 'lib/agent/session_context/transcript.rb', line 111 def warnings @warnings end |
Class Method Details
.capture(session, reader: Agent::Sessions.read(session), now: Time.now) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/agent/session_context/transcript.rb', line 113 def capture(session, reader: Agent::Sessions.read(session), now: Time.now) entries = [] reader..with_index(1) do |, | entries << TranscriptEntry.new( index: , role: .role, at: .at, parts: capture_parts(session, , ) ) end new( session: session, captured_at: now, entries: entries.freeze, warnings: capture_warnings(reader) ) end |
.injection_kind(agent, text) ⇒ Object
133 134 135 136 137 138 139 140 |
# File 'lib/agent/session_context/transcript.rb', line 133 def injection_kind(agent, text) return unless text.is_a?(String) stripped_text = text.b.lstrip marker_kinds = Transcript::INJECTION_MARKERS.fetch(agent&.to_sym, {}) match = marker_kinds.find { |marker, _kind| stripped_text.start_with?(marker.b) } match&.last end |