Class: Phronomy::KnowledgeSource::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/phronomy/knowledge_source/base.rb

Overview

Abstract base class for all KnowledgeSource implementations.

Subclasses must implement #fetch(query:) and return an Array of chunk Hashes. Each chunk Hash must contain: :content [String] the text to inject into the context :type [Symbol] semantic tag (e.g. :static, :rag, :entity)

Direct Known Subclasses

EntityKnowledge, RAGKnowledge, StaticKnowledge

Instance Method Summary collapse

Instance Method Details

#fetch(query: nil) ⇒ Array<Hash>

Retrieve knowledge chunks relevant to the given query.

Parameters:

  • query (String, nil) (defaults to: nil)

    the current user input used to select relevant chunks

Returns:

  • (Array<Hash>)

    array of { content: String, type: Symbol }

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/phronomy/knowledge_source/base.rb', line 16

def fetch(query: nil)
  raise NotImplementedError, "#{self.class}#fetch is not implemented"
end

#static?Boolean

Returns true when this source's content is considered static (i.e. does not change between agent invocations). Static sources are eligible for fingerprint-based caching in ContextVersionCache.

Override in subclasses that return fixed content.

Returns:

  • (Boolean)


27
28
29
# File 'lib/phronomy/knowledge_source/base.rb', line 27

def static?
  false
end