Add a document to a Collection

Overview

A Collection can contain multiple documents. Added documents are indexed and stored in a database. When you ask a question about the document(s), h2oGPTe crawls through the indexed document(s) in the Collection to find relevant content to answer the question while utilizing the Collection’s large language model (LLM) to summarize a concise question response. A user can add documents during or after creating a Collection.

Example

from h2ogpte import H2OGPTE

client = H2OGPTE(
    address="https://h2ogpte.genai.h2o.ai",
    api_key='sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
)

collection_id = client.create_collection(
    name="The name of my Collection",
    description="The description of my Collection",
)

with open("annual-report.pdf", "rb") as f:
    report = client.upload("annual-report.pdf", f)

client.ingest_uploads(
    collection_id=collection_id,
    upload_ids=[report]
)

Add a document in agent-only mode

When using agent-only mode, documents bypass standard ingestion and indexing. Files ingested in this mode can only be used with agents and are not available for regular RAG queries.

from h2ogpte import H2OGPTE

client = H2OGPTE(
    address="https://h2ogpte.genai.h2o.ai",
    api_key='sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
)

collection_id = client.create_collection(
    name="The name of my Collection",
    description="The description of my Collection",
)

client.ingest_website(
    collection_id=collection_id,
    url="https://example.com/document.pdf",
    ingest_mode="agent_only"
)