class Riffer::Rig::Runtime::SystemPrompt
Public Class Methods
(String base, String cwd, ?Hash[Symbol, ^(Riffer::Rig::Runtime) → String?] sections) → void
Source
# File lib/riffer/rig/runtime/system_prompt.rb, line 14 def initialize(base, cwd, sections = {}) @base = base @cwd = cwd @sections = sections freeze end
@rbs base: String @rbs cwd: String @rbs sections: Hash[Symbol, ^(Riffer::Rig::Runtime) -> String?] @rbs return: void
Public Instance Methods
() → String
Source
# File lib/riffer/rig/runtime/system_prompt.rb, line 28 def bare compose([]) end
@rbs return: String
(Riffer::Agent::Session session, Riffer::Rig::Runtime runtime) → void
Source
# File lib/riffer/rig/runtime/system_prompt.rb, line 41 def refresh(session, runtime) # Upstream candidate: riffer resolves `instructions` once, in Agent.new, so # a per-turn system message has to be swapped into the session by hand. history = session.messages kept = history.first.is_a?(Riffer::Messages::System) ? history.drop(1) : history session.set([Riffer::Messages::System.new(render(runtime)), *kept]) end
@rbs session: Riffer::Agent::Session @rbs runtime: Riffer::Rig::Runtime @rbs return: void
(Riffer::Rig::Runtime runtime) → String
Source
# File lib/riffer/rig/runtime/system_prompt.rb, line 34 def render(runtime) compose(@sections.each_value.map { |section| section.call(runtime).to_s }.reject(&:empty?)) end
@rbs runtime: Riffer::Rig::Runtime @rbs return: String
(Hash[Symbol, ^(Riffer::Rig::Runtime) → String?] sections) → Riffer::Rig::Runtime::SystemPrompt
Source
# File lib/riffer/rig/runtime/system_prompt.rb, line 23 def with_sections(sections) self.class.new(@base, @cwd, sections) end
@rbs sections: Hash[Symbol, ^(Riffer::Rig::Runtime) -> String?] @rbs return: Riffer::Rig::Runtime::SystemPrompt