Class: Ask::Agent::MemorySearch
- Inherits:
-
Tool
- Object
- Tool
- Ask::Agent::MemorySearch
- Defined in:
- lib/ask/agent/memory_search.rb
Overview
Tool that searches the session's durable memory (Memory). Injected
into the session by Session.new(memory: memory).
Instance Method Summary collapse
- #execute(query:, limit: 5) ⇒ Object
-
#initialize(memory:) ⇒ MemorySearch
constructor
A new instance of MemorySearch.
Constructor Details
#initialize(memory:) ⇒ MemorySearch
Returns a new instance of MemorySearch.
19 20 21 22 |
# File 'lib/ask/agent/memory_search.rb', line 19 def initialize(memory:) @memory = memory super() end |
Instance Method Details
#execute(query:, limit: 5) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/ask/agent/memory_search.rb', line 24 def execute(query:, limit: 5) hits = @memory.search(query, limit: limit) return Ask::Result.ok(data: "(no matching memories)") if hits.empty? Ask::Result.ok(data: hits.map { |e| "- #{e.content}" }.join("\n")) end |