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, cancellation_token: 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.
23 24 25 26 27 |
# File 'lib/phronomy/knowledge_source/static_knowledge.rb', line 23 def initialize(text, type: :static, source: nil) @text = text.to_s @type = type @source = source end |
Instance Method Details
#fetch(query: nil, cancellation_token: nil) ⇒ Array<Hash>
Returns the fixed text as a single chunk, regardless of query.
35 36 37 38 39 40 41 42 |
# File 'lib/phronomy/knowledge_source/static_knowledge.rb', line 35 def fetch(query: nil, cancellation_token: nil) cancellation_token&.raise_if_cancelled! 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.
47 48 49 |
# File 'lib/phronomy/knowledge_source/static_knowledge.rb', line 47 def static? true end |