from pathlib import Path
from raglight import RAGPipeline
from raglight.integrations import default_registries
from raglight.integrations.chroma import ChromaVectorStore
from raglight.integrations.ollama import OllamaEmbeddings, OllamaLLM
from raglight.models import FolderSource
DOCUMENTS = Path("./documents")
embeddings = OllamaEmbeddings(model_name="nomic-embed-text")
llm = OllamaLLM(model_name="qwen3:0.6b", preload_model=False)
vector_store = ChromaVectorStore(
collection_name="local-documents",
embeddings_model=embeddings,
persist_directory="./raglight-db",
)
pipeline = RAGPipeline(
llm=llm,
embeddings=embeddings,
vector_store=vector_store,
document_processors=default_registries.document_processors,
)
ingestion = pipeline.ingest([FolderSource(DOCUMENTS)])
if ingestion.failures:
raise RuntimeError(ingestion.to_dict())
response = pipeline.generate("What are the main topics in these documents?")
print(response.answer)
print("Sources:", [source.metadata for source in response.sources])