Class: Langchain::Tool::Vectorsearch
- Inherits:
-
Object
- Object
- Langchain::Tool::Vectorsearch
- Extended by:
- Langchain::ToolDefinition
- Defined in:
- lib/langchain/tool/vectorsearch.rb
Overview
A tool wraps vectorsearch classes
Usage:
# Initialize the LLM that will be used to generate embeddings
ollama = Langchain::LLM::Ollama.new(url: ENV["OLLAMA_URL"]
chroma = Langchain::Vectorsearch::Chroma.new(url: ENV["CHROMA_URL"], index_name: "my_index", llm: ollama)
# This tool can now be used by the Assistant
vectorsearch_tool = Langchain::Tool::Vectorsearch.new(vectorsearch: chroma)
Instance Attribute Summary collapse
-
#vectorsearch ⇒ Object
readonly
Returns the value of attribute vectorsearch.
Instance Method Summary collapse
-
#initialize(vectorsearch:) ⇒ Vectorsearch
constructor
Initializes the Vectorsearch tool.
-
#similarity_search(query:, k: 4) ⇒ Object
Executes the vector search and returns the results.
Methods included from Langchain::ToolDefinition
define_function, function_schemas, tool_name
Constructor Details
#initialize(vectorsearch:) ⇒ Vectorsearch
Initializes the Vectorsearch tool
28 29 30 |
# File 'lib/langchain/tool/vectorsearch.rb', line 28 def initialize(vectorsearch:) @vectorsearch = vectorsearch end |
Instance Attribute Details
#vectorsearch ⇒ Object (readonly)
Returns the value of attribute vectorsearch.
23 24 25 |
# File 'lib/langchain/tool/vectorsearch.rb', line 23 def vectorsearch @vectorsearch end |
Instance Method Details
#similarity_search(query:, k: 4) ⇒ Object
Executes the vector search and returns the results
36 37 38 |
# File 'lib/langchain/tool/vectorsearch.rb', line 36 def similarity_search(query:, k: 4) vectorsearch.similarity_search(query:, k: 4) end |