Class: AIA::ToolFilter::TFIDF

Inherits:
ToolFilter
  • Object
show all
Defined in:
lib/aia/tool_filter/tfidf.rb

Constant Summary collapse

DEFAULT_THRESHOLD =
0.05
DEFAULT_MAX_TOOLS =
30

Instance Method Summary collapse

Constructor Details

#initialize(tools:, fact_asserter:, threshold: DEFAULT_THRESHOLD, max_tools: DEFAULT_MAX_TOOLS) ⇒ TFIDF

Returns a new instance of TFIDF.

Parameters:

  • tools (Array)

    tool classes/objects with .name and .description

  • fact_asserter (FactAsserter)

    used for tool_name/tool_description extraction

  • threshold (Float) (defaults to: DEFAULT_THRESHOLD)

    minimum cosine similarity to include a tool (default 0.05)

  • max_tools (Integer) (defaults to: DEFAULT_MAX_TOOLS)

    maximum tools to return per turn (default 30)



29
30
31
32
33
34
35
36
37
38
# File 'lib/aia/tool_filter/tfidf.rb', line 29

def initialize(tools:, fact_asserter:, threshold: DEFAULT_THRESHOLD, max_tools: DEFAULT_MAX_TOOLS)
  super(label: "TF-IDF")
  @fact_asserter = fact_asserter
  @threshold     = threshold
  @max_tools     = max_tools
  @tools         = tools
  @tool_entries  = []
  @tfidf         = nil
  @tool_vectors  = []
end