Skip to main content

Input document loading utilities for GraphRAG

Project description

GraphRAG Inputs

This package provides input document loading utilities for GraphRAG, supporting multiple file formats including CSV, JSON, JSON Lines, and plain text.

Supported File Types

The following four standard file formats are supported out of the box:

  • CSV - Tabular data with configurable column mappings
  • JSON - JSON files with configurable property paths
  • JSON Lines - Line-delimited JSON records
  • Text - Plain text files

Markitdown Support

Additionally, we support the InputType.MarkItDown format, which uses the MarkItDown library to import any supported file type. The MarkItDown converter can handle a wide variety of file formats including Office documents, PDFs, HTML, and more.

Note: Additional optional dependencies may need to be installed depending on the file type you're processing. The choice of converter is determined by MarkItDowns's processing logic, which primarily uses the file extension to select the appropriate converter. Please refer to the MarkItDown repository for installation instructions and detailed information about supported formats.

Examples

Basic usage with the factory:

from graphrag_input import create_input_reader, InputConfig, InputType
from graphrag_storage import StorageConfig, create_storage

config = InputConfig(
    type=InputType.Csv,
    text_column="content",
    title_column="title",
)
storage = create_storage(StorageConfig(base_dir="./input"))
reader = create_input_reader(config, storage)
documents = await reader.read_files()

Import a pdf with MarkItDown:

pip install 'markitdown[pdf]' # required dependency for pdf processing
from graphrag_input import create_input_reader, InputConfig, InputType
from graphrag_storage import StorageConfig, create_storage

config = InputConfig(
    type=InputType.MarkitDown,
    file_pattern=".*\\.pdf$"
)
storage = create_storage(StorageConfig(base_dir="./input"))
reader = create_input_reader(config, storage)
documents = await reader.read_files()

YAML config example for above:

input:
  type: markitdown
  file_pattern: ".*\\.pdf$$"
input_storage:
    type: file
    base_dir: "input"

Note that when specifying column names for data extraction, we can handle nested objects (e.g., in JSON) with dot notation:

from graphrag_input import get_property

data = {"user": {"profile": {"name": "Alice"}}}
name = get_property(data, "user.profile.name")  # Returns "Alice"

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

graphrag_input-3.0.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graphrag_input-3.0.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file graphrag_input-3.0.1.tar.gz.

File metadata

  • Download URL: graphrag_input-3.0.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.4

File hashes

Hashes for graphrag_input-3.0.1.tar.gz
Algorithm Hash digest
SHA256 3ede3d372e0c8d20aa62e60fe9ab71aa681f2b440af99cf15c050de2ab1c13d0
MD5 aed6518d86eea0bd599f5906a23602c7
BLAKE2b-256 b9282cee996d526d5c56b1b6a9e321511b4927a401d28856f85b794a0c9007c9

See more details on using hashes here.

File details

Details for the file graphrag_input-3.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for graphrag_input-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 353a72dff3d3801b11e545ba4905d1481e3b4ff8de07217e522772a252079fc8
MD5 19047c2e2ac0d905251a443022c9e416
BLAKE2b-256 7c0040c41c5ca653fd48f53e5f2e8ff9e41acc571e30ffc0ef20cca25646fd61

See more details on using hashes here.

Supported by

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