RagLeap
Blog

How to build a RAG chatbot in Python with ragleap-rag, pgvector and Gemini

Short answer: install ragleap-rag, point it at a PostgreSQL database with the pgvector extension, give it a Gemini key for embeddings, ingest your text and call rag.ask(...). This guide follows the README of ragleap-rag 0.14.0 (Python 3.10 or newer) and says what is and is not verified. ragleap-rag is one library of the RagLeap project; the other libraries cover knowledge graphs, agents, tools, vector stores and operations.

What do you need before you start?

  • A PostgreSQL database with the pgvector extension.
  • A Gemini API key, used for embeddings in the README quickstart. You bring your own keys; the README says nothing is routed through RagLeap.

How do you install it?

pip install ragleap-rag
# or
uv add ragleap-rag[gemini]

How do you ingest a document and ask a question?

This is the README quickstart, unchanged:

from ragleap import RagLeap, ProviderConfig, EmbeddingConfig

rag = RagLeap(
    database_url="postgresql://user:pass@localhost/mydb",
    embedder=EmbeddingConfig(provider="gemini", model="models/gemini-embedding-001", dimensions=3072, api_key="your-gemini-key"),
    primary=ProviderConfig(provider="gemini", model="gemini-3.6-flash", api_key="your-gemini-key"),
)
rag.init_schema()  # one-time, idempotent: safe to call every run

rag.ingest_text("handbook.txt", "Employees get unlimited PTO and a $500/year learning budget.")

answer = rag.ask("How much PTO do employees get?")
print(answer["answer"])

The README shows the printed answer as Employees get unlimited PTO. (Source 1). Besides text, rag.ingest(filename, raw_bytes) takes a .txt, .pdf or .docx file.

How does retrieval work?

Retrieval is hybrid by default: dense results (pgvector cosine similarity) and sparse results (Postgres full-text search) are combined with Reciprocal Rank Fusion, so both meaning-based matches and exact keywords or identifiers are found. Pass hybrid=False to rag.ask(...) for dense-only retrieval, which costs one query instead of two. temperature, system_prompt and max_tokens are per-call arguments.

Can you use a different vector database?

Yes. Vectors go to Postgres by default, and you can swap the backend with vector_backend=. The README example uses FAISS, which is local and in-process:

from ragleap.vectorstores import FAISSBackend

rag = RagLeap(
    database_url="postgresql://user:pass@localhost/mydb",  # still required, for conversation memory
    vector_backend=FAISSBackend(persist_directory="./my_faiss_data"),  # vectors go here instead
    embedder=EmbeddingConfig(provider="gemini", model="models/gemini-embedding-001", dimensions=3072, api_key="..."),
    primary=ProviderConfig(provider="gemini", model="gemini-3.6-flash", api_key="..."),
)

The README also lists Pinecone, Weaviate, Qdrant and Milvus backends (installed with extras such as ragleap-rag[qdrant]). With FAISS, hybrid=True falls back to dense-only. The README states that none of the four has been tested against a real account. The guides carry the full table.

What else is in the README?

Sections on retrieval-only use, streaming, async support, conversation memory, reranking, the document lifecycle, and metadata and filtering. Read them in the package folder before relying on a feature.

What this does not do

  • ragleap-rag is the retrieval and answer engine. Agents live in ragleap-agents; the full AI employee system is RagLeap Core.
  • In this quickstart your text and questions go to Gemini for embeddings and answers.
  • No accuracy or speed claims are made here. Test it on your own documents.

Sources

ragleap-rag on PyPI (0.14.0), the README on GitHub, and the library page.

Back to the blog