Class: Insika::Context::CatalogProvider

Inherits:
Insika::ContextProvider show all
Defined in:
lib/insika/context/catalog_provider.rb

Overview

Base for providers that inject level 1 of a catalog (skills, deferred tools) as a :system fragment. The subclass says WHICH entries and the priority; the fragment assembly (format -> skip if empty -> a single fragment with source = the provider id) is shared.

Direct Known Subclasses

Providers::Skill, Providers::ToolSearch

Instance Method Summary collapse

Methods inherited from Insika::ContextProvider

#enabled_for?, #id, #required?

Constructor Details

#initialize(catalog:) ⇒ CatalogProvider

Returns a new instance of CatalogProvider.



10
11
12
# File 'lib/insika/context/catalog_provider.rb', line 10

def initialize(catalog:)
  @catalog = catalog
end

Instance Method Details

#call(request) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/insika/context/catalog_provider.rb', line 14

def call(request)
  block = @catalog.format_for_prompt(entries(request))
  return [] if block.empty?

  [ContextFragment.build(content: block, placement: :system,
                         priority: priority, source: id)]
end