Class: Phronomy::KnowledgeSource::StaticKnowledge
- Defined in:
- lib/phronomy/knowledge_source/static_knowledge.rb
Overview
A KnowledgeSource backed by fixed text provided at construction time.
Useful for injecting static documents, policy files, or configuration knowledge that does not change per request.
Instance Method Summary collapse
-
#fetch(query: nil) ⇒ Array<Hash>
Returns the fixed text as a single chunk, regardless of query.
-
#initialize(text, type: :static, source: nil) ⇒ StaticKnowledge
constructor
A new instance of StaticKnowledge.
-
#static? ⇒ true
Static knowledge content never changes between invocations.
Constructor Details
#initialize(text, type: :static, source: nil) ⇒ StaticKnowledge
Returns a new instance of StaticKnowledge.
22 23 24 25 26 |
# File 'lib/phronomy/knowledge_source/static_knowledge.rb', line 22 def initialize(text, type: :static, source: nil) @text = text.to_s @type = type @source = source end |
Instance Method Details
#fetch(query: nil) ⇒ Array<Hash>
Returns the fixed text as a single chunk, regardless of query.
32 33 34 35 36 37 38 |
# File 'lib/phronomy/knowledge_source/static_knowledge.rb', line 32 def fetch(query: nil) return [] if @text.empty? chunk = {content: @text, type: @type} chunk[:source] = @source if @source [chunk] end |
#static? ⇒ true
Static knowledge content never changes between invocations.
42 43 44 |
# File 'lib/phronomy/knowledge_source/static_knowledge.rb', line 42 def static? true end |