Overview
DocumentIndexer is the underlying class that powers LangChat.index(). Use it directly only when you need to index documents outside of a LangChat instance — for example, in a standalone indexing script that doesn’t start the full chatbot.
For most use cases, use lc.index() instead.
Constructor
str
required
Pinecone API key.
str
required
Pinecone index name.
str
required
OpenAI API key for creating embeddings.
str
default:"text-embedding-3-large"
OpenAI embedding model.
Methods
load_and_index_documents()
Index a single file.
str
required
Path to the document file.
int
default:"1000"
Characters per chunk.
int
default:"200"
Overlap between adjacent chunks.
str | None
default:"None"
Pinecone namespace.
bool
default:"True"
Skip chunks already in Pinecone (checked by content hash).
dict with chunks_indexed, chunks_skipped, and metadata.
load_and_index_multiple_documents()
Index multiple files.
load_and_index_documents(), but accepts a list of file paths.
Standalone indexing script
UseDocumentIndexer directly when you want to index documents independently of the chatbot:
LangChat.index() is a convenience wrapper around DocumentIndexer that reads credentials from environment variables automatically. Prefer it when you already have a LangChat instance.