Class: Agentic::Extension::DomainAdapter
- Inherits:
-
Object
- Object
- Agentic::Extension::DomainAdapter
- Defined in:
- lib/agentic/extension/domain_adapter.rb
Overview
The DomainAdapter integrates domain-specific knowledge into the general agent framework. It provides mechanisms for adapting prompts, tasks, and verification strategies to specific domains like healthcare, finance, legal, etc.
Instance Attribute Summary collapse
-
#domain ⇒ String
readonly
Get the domain identifier.
Instance Method Summary collapse
-
#adapt(component, target, context = {}) ⇒ Object
Apply domain-specific adaptation to a component.
-
#add_knowledge(key, knowledge) ⇒ Object
Add domain-specific knowledge.
-
#configuration ⇒ Hash
Get domain configuration.
-
#get_knowledge(key) ⇒ Object?
Get domain-specific knowledge.
-
#initialize(domain, options = {}) ⇒ DomainAdapter
constructor
Initialize a new DomainAdapter.
-
#register_adapter(component, adapter) ⇒ Boolean
Register an adapter for a specific component.
-
#supports?(component) ⇒ Boolean
Check if the adapter supports a specific component.
Constructor Details
#initialize(domain, options = {}) ⇒ DomainAdapter
Initialize a new DomainAdapter
15 16 17 18 19 20 21 22 23 |
# File 'lib/agentic/extension/domain_adapter.rb', line 15 def initialize(domain, = {}) @domain = domain @logger = [:logger] || Agentic.logger @domain_config = [:domain_config] || {} @adapters = {} @domain_knowledge = {} initialize_default_adapters end |
Instance Attribute Details
#domain ⇒ String (readonly)
Get the domain identifier
86 87 88 |
# File 'lib/agentic/extension/domain_adapter.rb', line 86 def domain @domain end |
Instance Method Details
#adapt(component, target, context = {}) ⇒ Object
Apply domain-specific adaptation to a component
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/agentic/extension/domain_adapter.rb', line 59 def adapt(component, target, context = {}) return target unless @adapters.key?(component) adapter = @adapters[component] context = context.merge(domain: @domain, domain_knowledge: @domain_knowledge) begin result = adapter.call(target, context) @logger.debug("Applied #{@domain} domain adaptation to #{component}") result rescue => e @logger.error("Failed to apply #{@domain} domain adaptation to #{component}: #{e.}") target # Return original if adaptation fails end end |
#add_knowledge(key, knowledge) ⇒ Object
Add domain-specific knowledge
41 42 43 |
# File 'lib/agentic/extension/domain_adapter.rb', line 41 def add_knowledge(key, knowledge) @domain_knowledge[key] = knowledge end |
#configuration ⇒ Hash
Get domain configuration
91 92 93 |
# File 'lib/agentic/extension/domain_adapter.rb', line 91 def configuration @domain_config end |
#get_knowledge(key) ⇒ Object?
Get domain-specific knowledge
49 50 51 |
# File 'lib/agentic/extension/domain_adapter.rb', line 49 def get_knowledge(key) @domain_knowledge[key] end |
#register_adapter(component, adapter) ⇒ Boolean
Register an adapter for a specific component
30 31 32 33 34 35 |
# File 'lib/agentic/extension/domain_adapter.rb', line 30 def register_adapter(component, adapter) return false unless adapter.respond_to?(:call) @adapters[component] = adapter true end |
#supports?(component) ⇒ Boolean
Check if the adapter supports a specific component
79 80 81 |
# File 'lib/agentic/extension/domain_adapter.rb', line 79 def supports?(component) @adapters.key?(component) end |