LlamaIndex
Wrap LlamaIndex query engines, chat engines, and agents for use with the Reminix runtime
The LlamaIndex adapter wraps LlamaIndex components for RAG and agent use cases.
Installation
pip install reminix[runtime,llamaindex]Available Adapters
from_query_engine
Wrap a LlamaIndex QueryEngine for simple Q&A over documents:
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from reminix.adapters.llamaindex import from_query_engine
from reminix.runtime import serve
# Load and index documents
documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)
# Create QueryEngine and wrap it
query_engine = index.as_query_engine()
agent = from_query_engine(query_engine, name="docs-qa")
serve(agent)from_chat_engine
Wrap a LlamaIndex ChatEngine for conversational RAG:
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from reminix.adapters.llamaindex import from_chat_engine
from reminix.runtime import serve
documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)
# Create ChatEngine for conversations
chat_engine = index.as_chat_engine(chat_mode="condense_question")
agent = from_chat_engine(chat_engine, name="docs-chat")
serve(agent)from_agent
Wrap a LlamaIndex Agent (ReActAgent, OpenAIAgent, etc.):
from llama_index.core.agent import ReActAgent
from llama_index.core.tools import FunctionTool
from llama_index.llms.openai import OpenAI
from reminix.adapters.llamaindex import from_agent
from reminix.runtime import serve
# Define tools
def multiply(a: int, b: int) -> int:
return a * b
multiply_tool = FunctionTool.from_defaults(fn=multiply)
# Create agent
llm = OpenAI(model="gpt-4o")
react_agent = ReActAgent.from_tools([multiply_tool], llm=llm)
# Wrap and serve
agent = from_agent(react_agent, name="calculator")
serve(agent)When to Use Each
| Adapter | Use Case |
|---|---|
from_query_engine | Simple Q&A, no conversation history |
from_chat_engine | Conversational RAG with history |
from_agent | Tool-using agents (ReActAgent, etc.) |
Handler Mapping
| Reminix Handler | LlamaIndex Method |
|---|---|
@agent.invoke | engine.aquery() or agent.achat() |
@agent.invoke_stream | engine.astream_chat() |
@agent.chat | engine.achat() |
@agent.chat_stream | engine.astream_chat() |