Query Vectara Corpus for Electric Vehicle Data
Run semantic search or RAG queries against a Vectara corpus from a LlamaIndex agent.
Why it matters
Leverage a Vectara corpus to perform semantic searches or retrieval-augmented generation (RAG) queries on electric vehicle data. This tool enables agents to access and process information stored within a specified Vectara corpus.
Outcomes
What it gets done
Connect to a Vectara corpus using environment variables for API keys.
Perform semantic searches to retrieve relevant documents.
Execute RAG queries to generate responses grounded in corpus data.
Integrate with LLM agents for automated information retrieval.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/li-tool-tools-vectara-query | bash Overview
Connecting to a Vectara corpus about Electric Vehicles
A LlamaIndex tool for Vectara corpus queries, offering raw semantic search or RAG-grounded generative answers. Use semantic_search for raw matches and rag_query for a synthesized, grounded answer, against an already-populated Vectara corpus.
What it does
The Vectara Query Tool connects a LlamaIndex agent to a Vectara corpus, letting the agent make semantic search or retrieval-augmented generation (RAG) queries against it. VectaraQueryToolSpec reads its configuration from the environment - a VECTARA_CORPUS_KEY identifying which corpus to search, and a VECTARA_API_KEY authorized to query it - rather than taking them as constructor arguments.
Two functions are exposed. semantic_search accepts a query and uses semantic search to return the top matching results. rag_query accepts a query and uses RAG to produce a generative response grounded in the search results, rather than just a list of matches. The source's own worked example queries a corpus about electric vehicles, asking "What are the different types of electric vehicles?" - showing the RAG-style path answering a question directly rather than returning raw search hits.
When to use - and when NOT to
Use semantic_search when you want the raw top matches for a query without a generated answer. Use rag_query when you want a synthesized, grounded answer built from those results instead. Do not use it without a Vectara account and a corpus already populated with your data - the tool queries an existing corpus, it does not create or populate one.
Capabilities
semantic_search returns the top semantic matches for a query. rag_query returns a generative, RAG-grounded answer built from the search results.
How to install
from llama_index.tools.vectara_query import VectaraQueryToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
tool_spec = VectaraQueryToolSpec()
agent = FunctionAgent(
tools=tool_spec.to_tool_list(),
llm=OpenAI(model="gpt-4.1"),
)
Requires a Vectara account with VECTARA_CORPUS_KEY and VECTARA_API_KEY set in the environment; this example targets llama-index-tools-vectara-query version >=0.3.0.
Who it's for
Developers building LlamaIndex agents that need to search or answer questions grounded in a Vectara corpus, either as raw matches or synthesized RAG answers.
Source README
Vectara Query Tool
This tool connects to a Vectara corpus and allows agents to make semantic search or retrieval augmented generation (RAG) queries.
Usage
Please note that this usage example relies on version >=0.3.0.
This tool has a more extensive example usage documented in a Jupyter notebok here
To use this tool, you'll need a Vectara account (If you don't have an account, you can create one here) and the following information in your environment:
VECTARA_CORPUS_KEY: The corpus key for the Vectara corpus that you want your tool to search for information. If you need help creating a corpus with your data, follow this Quick Start guide.VECTARA_API_KEY: An API key that can perform queries on this corpus.
Here's an example usage of the VectaraQueryToolSpec.
from llama_index.tools.vectara_query import VectaraQueryToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
### Connecting to a Vectara corpus about Electric Vehicles
tool_spec = VectaraQueryToolSpec()
agent = FunctionAgent(
tools=tool_spec.to_tool_list(),
llm=OpenAI(model="gpt-4.1"),
)
print(await agent.run("What are the different types of electric vehicles?"))
The available tools are:
semantic_search: A tool that accepts a query and uses semantic search to obtain the top search results.
rag_query: A tool that accepts a query and uses RAG to obtain a generative response grounded in the search results.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.