Files
magnus919_agent-skills/llamaindex/templates/basic-rag.py
T
Magnus Hedemark 3e86349539 feat: add llamaindex — expert skill for LlamaIndex framework
Comprehensive skill covering:
- Core architecture (7 primitives, Settings, data flow)
- RAG strategies (basic through advanced with hybrid retrieval, reranking)
- Multi-agent orchestration (AgentWorkflow, handoff bug fix)
- Event-driven workflows (durable execution, checkpoint/resume)
- Production deployment (llama-deploy, debugging, observability)
- PropertyGraphIndex (knowledge graphs, hybrid retrieval)
- Evaluation and span-attached observability
- Integration ecosystem (vector stores, LlamaHub, LlamaParse)

9 reference files, 4 templates, 1 verification script.
MIT licensed. 100% AI agent portable (no platform-specific content).

Signed-off-by: Magnus Hedemark <magnus919@pm.me>
2026-07-09 13:32:53 -04:00

32 lines
829 B
Python

#!/usr/bin/env python3
"""
Minimal RAG pipeline using LlamaIndex.
Loads documents from a directory, builds a vector index, and answers queries.
"""
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from llama_index.llms.openai import OpenAI
from llama_index.core import Settings
# --- Configuration ---
Settings.llm = OpenAI(model="gpt-4o-mini")
DATA_DIR = "./data"
# --- Load ---
documents = SimpleDirectoryReader(DATA_DIR).load_data()
# --- Index ---
index = VectorStoreIndex.from_documents(documents)
# --- Query ---
query_engine = index.as_query_engine(
similarity_top_k=5,
)
response = query_engine.query("What does this data say about your question?")
print(f"Answer: {response}")
# Show sources
for source in response.source_nodes:
print(f" [{source.score:.3f}] {source.text[:100]}...")