LangChainRB
Build Ruby-based Retrieval-Augmented Generation applications with LangChainRB and Zilliz Cloud or Milvus Vector Database
Use this integration for FreeLangChainRB and Milvus
LangChainRB is an orchestration layer for building Ruby-based LLM applications and is helpful to string multiple types of systems together, like vector databases (Milvus and Zilliz Cloud), and LLMs. With this solution, you can build semantic search capabilities that are useful for Q&A over documents, chatbots, and agents.
Key features include:
- Prompt Management — create, load and save prompt templates
- Context length validations — validate the context window length to avoid hitting LLM errors
- Data chunking — splitting the data into chunks that make semantic sense from various documents before creating embeddings that get stored in a vector database like Zilliz Cloud.
- Conversation memory — persisting a chat with an LLM to memory
- Provides support for popular LLMs like Anthropic, Cohere, Google Palm, Hugging Face, Local Llama, and OpenAI.
Benefits
- Common domain specific language and APIs
- Interoperability & reduced vendor lock in, pick your favorite LLM
- Best practices & rich feature set
How to execute a vector search with Milvus
How to execute a vector search with Milvus
llm = Langchain::LLM::GooglePalm.new(api_key: “...”) client + Langchain::Vectorsearch::Milvus.new(url:, index_name:, llm: llm) client.add_texts texts: [...], ids: [...] my_pdf = Langchain.root.join(“/Documents/file.pdf”) my_text = Langchain.root.join(“/Documents/file.txt”) my_docx = Langchain.root.join(“/Documents/file.docx”) client.add_data(paths: [my_pdf, my_txt, my_docx])
Some notes about the above example
- This example is using Google Palm for the LLM, you can instantiate the LLM by passing it your API key
- Create a client using the Milvus ruby gem, pass it the URL where Milvus is running, name the index and pass the index
- Send vectors one by one to Milvus or bulk upsert
ActiveRecord
exampleClass Product < ActiveRecord::Base vectorsearch provider: Langchain::Vectorsearch::Milvus.new(url:, index_name:, llm:) After_save :upsert_to_vectorsearch end
Vector search example
# Retrieve similar documents based on the query string passed in client.similarity_search( Query:, k: # number of results to be retrieved ) # Q&A-style querying based on the question passed in client.ask( question: )
Learn about LangChainRB and Milvus Integration