Skip to main content

llama-index readers mongodb integration

Project description

LlamaIndex Readers Integration: Mongo

Overview

Simple Mongo Reader allows loading data from a MongoDB database. It concatenates specified fields from each document into a single document used by LlamaIndex.

Installation

You can install MongoDB Reader via pip:

pip install llama-index-readers-mongodb

Usage

from llama_index.readers.mongo import SimpleMongoReader

# Initialize SimpleMongoReader
reader = SimpleMongoReader(
    host="<Mongo Host>",  # Mongo host address
    port=27017,  # Mongo port (default: 27017)
    uri="<Mongo Connection String>",  # Provide the URI if not using host and port
)

# Lazy load data from MongoDB
documents = reader.lazy_load_data(
    db_name="<Database Name>",  # Name of the database
    collection_name="<Collection Name>",  # Name of the collection
    field_names=[
        "text"
    ],  # Names of the fields to concatenate (default: ["text"])
    separator="",  # Separator between fields (default: "")
    query_dict=None,  # Query to filter documents (default: None)
    max_docs=0,  # Maximum number of documents to load (default: 0)
    metadata_names=None,  # Names of the fields to add to metadata attribute (default: None)
)

Implementation for MongoDB reader can be found here

This loader is designed to be used as a way to load data into LlamaIndex and/or subsequently used as a Tool in a LangChain Agent.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_readers_mongodb-0.1.8.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page