LlamaIndex
LlamaIndex is a data framework for building LLM-powered agents over your data. Specializes in RAG pipelines, document parsing, and agent workflows. Core package is llama-index-core. Integrations are separate packages installed from LlamaHub.
Warnings
- breaking ServiceContext is fully removed. All code using ServiceContext.from_defaults() will fail.
- breaking AgentRunner, AgentWorker, FunctionCallingAgent, OpenAIAgent, StructuredAgentPlanner all removed.
- breaking QueryPipeline class removed.
- breaking llama-index-legacy package deprecated and removed from repository.
- breaking GPTVectorStoreIndex, GPTSimpleKeywordTableIndex and all GPT-prefixed index names removed.
- gotcha pip install llama-index alone installs OpenAI integrations by default. For other providers install llama-index-core plus the specific integration package.
- gotcha index.as_chat_engine() default changed to CondensePlusContextChatEngine in 0.14.x.
Install
-
pip install llama-index -
pip install llama-index-core -
pip install llama-index-core llama-index-llms-openai llama-index-embeddings-openai
Imports
- VectorStoreIndex
from llama_index.core import VectorStoreIndex
- OpenAI (LLM)
from llama_index.llms.openai import OpenAI
- AgentWorkflow
from llama_index.core.agent.workflow import AgentWorkflow
- Settings
from llama_index.core import Settings Settings.llm = OpenAI(model='gpt-4o')
Quickstart
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.llms.openai import OpenAI
from llama_index.embeddings.openai import OpenAIEmbedding
Settings.llm = OpenAI(model='gpt-4o')
Settings.embed_model = OpenAIEmbedding(model='text-embedding-3-small')
documents = SimpleDirectoryReader('data').load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
response = query_engine.query('What did the author do growing up?')
print(response)