Class: Ask::Agent::ContextSource
- Inherits:
-
Object
- Object
- Ask::Agent::ContextSource
- Defined in:
- lib/ask/agent/context_source.rb
Overview
A typed, independently observable piece of the system context.
Each source has a unique key, a load function that returns its
current value, a baseline render for initial prompt inclusion,
and an update render for mid-conversation change notifications.
Direct Known Subclasses
Ask::Agent::ContextSources::AlwaysActiveSkills, Ask::Agent::ContextSources::Date, Ask::Agent::ContextSources::Instructions, Ask::Agent::ContextSources::SkillsList
Class Method Summary collapse
- .inherited(subclass) ⇒ Object
-
.key(value = :__no_value__) ⇒ Object
Unique namespaced key for this source (e.g., "core/date").
- .registered_sources ⇒ Object
Instance Method Summary collapse
-
#baseline(value) ⇒ String
Render the initial text for this source.
-
#key ⇒ String
Unique key for this source.
-
#load ⇒ Object
Load the current value of this source.
-
#update(previous, current) ⇒ String?
Render a mid-conversation update message.
Class Method Details
.inherited(subclass) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/ask/agent/context_source.rb', line 39 def inherited(subclass) super # Register source type for discovery @registered_sources ||= [] @registered_sources << subclass end |
.key(value = :__no_value__) ⇒ Object
Unique namespaced key for this source (e.g., "core/date"). Used for change detection and deterministic ordering.
31 32 33 34 35 36 37 |
# File 'lib/ask/agent/context_source.rb', line 31 def key(value = :__no_value__) if value == :__no_value__ @key else @key = value end end |
.registered_sources ⇒ Object
46 47 48 |
# File 'lib/ask/agent/context_source.rb', line 46 def registered_sources @registered_sources || [] end |
Instance Method Details
#baseline(value) ⇒ String
Render the initial text for this source.
65 66 67 |
# File 'lib/ask/agent/context_source.rb', line 65 def baseline(value) raise NotImplementedError end |
#key ⇒ String
Returns unique key for this source.
52 53 54 |
# File 'lib/ask/agent/context_source.rb', line 52 def key self.class.key end |
#load ⇒ Object
Load the current value of this source.
58 59 60 |
# File 'lib/ask/agent/context_source.rb', line 58 def load raise NotImplementedError end |
#update(previous, current) ⇒ String?
Render a mid-conversation update message.
Called when load returns a value different from the previous one.
74 75 76 |
# File 'lib/ask/agent/context_source.rb', line 74 def update(previous, current) nil end |