Module: RubyLLM::Agents::DSL::Knowledge::InstanceMethods

Included in:
BaseAgent
Defined in:
lib/ruby_llm/agents/dsl/knowledge.rb

Overview

Instance methods mixed into agent instances via include.

Instance Method Summary collapse

Instance Method Details

#compiled_knowledgeString

Compiles all knowledge entries into a single string with headings and separators.

Returns:

  • (String)

    Compiled knowledge (empty string if no entries resolve)



94
95
96
97
98
99
100
101
102
# File 'lib/ruby_llm/agents/dsl/knowledge.rb', line 94

def compiled_knowledge
  self.class.knowledge_entries.filter_map { |entry|
    content = resolve_knowledge(entry)
    next if content.blank?

    heading = entry[:name].to_s.tr("_", " ").gsub(/\b\w/, &:upcase)
    "## #{heading}\n\n#{content}"
  }.join("\n\n---\n\n")
end