Class: Kodo::Tools::RecallFacts
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- Kodo::Tools::RecallFacts
- Extended by:
- PromptContributor
- Defined in:
- lib/kodo/tools/recall_facts.rb
Instance Method Summary collapse
- #execute(query: nil, category: nil) ⇒ Object
-
#initialize(knowledge:, audit:) ⇒ RecallFacts
constructor
A new instance of RecallFacts.
- #name ⇒ Object
Methods included from PromptContributor
capability_name, capability_primary, disabled_guidance, enabled_guidance
Constructor Details
#initialize(knowledge:, audit:) ⇒ RecallFacts
Returns a new instance of RecallFacts.
19 20 21 22 23 |
# File 'lib/kodo/tools/recall_facts.rb', line 19 def initialize(knowledge:, audit:) super() @knowledge = knowledge @audit = audit end |
Instance Method Details
#execute(query: nil, category: nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/kodo/tools/recall_facts.rb', line 25 def execute(query: nil, category: nil) if category && !Memory::Knowledge::VALID_CATEGORIES.include?(category) return "Invalid category '#{category}'. Use: #{Memory::Knowledge::VALID_CATEGORIES.join(', ')}" end results = @knowledge.recall(query: query, category: category) @audit.log( event: "tool_recall_facts", detail: "query:#{query || '*'} cat:#{category || '*'} results:#{results.length}" ) if results.empty? "No facts found#{" matching '#{query}'" if query}#{" in category '#{category}'" if category}." else lines = results.map { |f| "- [#{f['category']}] #{f['content']} (id: #{f['id']})" } "Found #{results.length} fact(s):\n#{lines.join("\n")}" end end |
#name ⇒ Object
45 46 47 |
# File 'lib/kodo/tools/recall_facts.rb', line 45 def name "recall_facts" end |