Class: RubyLLM::SemanticRouter::Strategies::Semantic::CustomSearchMatch
- Inherits:
-
Object
- Object
- RubyLLM::SemanticRouter::Strategies::Semantic::CustomSearchMatch
- Defined in:
- lib/rubyllm/semantic_router/strategies/semantic.rb
Overview
Wrapper for custom search results (from find_examples callable) Accepts hashes or objects with agent_name, example_text, distance/score
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #agent_name ⇒ Object
- #distance ⇒ Object
- #example_text ⇒ Object
-
#initialize(result) ⇒ CustomSearchMatch
constructor
A new instance of CustomSearchMatch.
- #neighbor_distance ⇒ Object
Constructor Details
#initialize(result) ⇒ CustomSearchMatch
Returns a new instance of CustomSearchMatch.
202 203 204 |
# File 'lib/rubyllm/semantic_router/strategies/semantic.rb', line 202 def initialize(result) @result = result end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
200 201 202 |
# File 'lib/rubyllm/semantic_router/strategies/semantic.rb', line 200 def result @result end |
Instance Method Details
#agent_name ⇒ Object
206 207 208 |
# File 'lib/rubyllm/semantic_router/strategies/semantic.rb', line 206 def agent_name fetch(:agent_name) || fetch(:agent) end |
#distance ⇒ Object
214 215 216 217 218 219 220 221 222 223 |
# File 'lib/rubyllm/semantic_router/strategies/semantic.rb', line 214 def distance # Support both distance (lower is better) and score (higher is better) if (d = fetch(:distance)) d elsif (s = fetch(:score)) 1.0 - s # Convert score to distance else 0.0 end end |
#example_text ⇒ Object
210 211 212 |
# File 'lib/rubyllm/semantic_router/strategies/semantic.rb', line 210 def example_text fetch(:example_text) || fetch(:text) end |
#neighbor_distance ⇒ Object
225 226 227 |
# File 'lib/rubyllm/semantic_router/strategies/semantic.rb', line 225 def neighbor_distance distance end |