RAGChain Docs
  • Introduction
  • Quick Start
  • Installation
  • RAGchain Structure
    • File Loader
      • Dataset Loader
        • Ko-Strategy-QA Loader
      • Hwp Loader
      • Rust Hwp Loader
      • Win32 Hwp Loader
      • OCR
        • Nougat Loader
        • Mathpix Markdown Loader
        • Deepdoctection Loader
    • Text Spliter
      • Recursive Text Splitter
      • Markdown Header Splitter
      • HTML Header splitter
      • Code splitter
      • Token splitter
    • Retrieval
      • BM25 Retrieval
      • Hybrid Retrieval
      • Hyde Retrieval
      • VectorDB Retrieval
    • LLM
    • DB
      • MongoDB
      • Pickle DB
    • Reranker
      • BM25 Reranker
      • UPR Reranker
      • TART Reranker
      • MonoT5 Reranker
      • LLM Reranker
    • Benchmark
      • Auto Evaluator
      • Dataset Evaluators
        • Qasper
        • Ko-Strategy-QA
        • Strategy-QA
        • ms-marco
  • Utils
    • Query Decomposition
    • Evidence Extractor
    • Embedding
    • Slim Vector Store
      • Pinecone Slim
      • Chroma Slim
    • File Cache
    • Linker
      • Redis Linker
      • Dynamo Linker
      • Json Linker
    • REDE Search Detector
    • Semantic Clustering
  • Pipeline
    • BasicIngestPipeline
    • BasicRunPipeline
    • RerankRunPipeline
    • ViscondeRunPipeline
  • For Advanced RAG
    • Time-Aware RAG
    • Importance-Aware RAG
Powered by GitBook
On this page
  • Overview
  • Usage
  1. Utils
  2. Linker

Json Linker

Json Linker Class Documentation

Overview

JsonLinker is a singleton class that allows the role of a linker to be played locally to use JSON file without using an external DB like redisDB or dynamoDB.

The class manages JSON files. It is used to link database and passage IDs that are stored in retrievals. The class is part of the RAGchain project and is located in the RAGchain/utils/linker/json_linker.py file.

The class inherits from the BaseLinker class and implements the put_json, get_json, and flush_db abstract methods.

The class uses the json Python library to interact with a JSON file. It requires the JSON_LINKER_PATH environment variable to be set, which specifies the path to the JSON file.

Usage

To use the JsonLinker class, you first need to set the required environment variable LINKER_TYPEand JSON_LINKER_PATH.

LINKER_TYPE="json"
JSON_LINKER_PATH="json file path(name)"

Here is an example of how to use the JsonLinker class:

from RAGchain.utils.linker import JsonLinker

# Create an instance of the JsonLinker class
linker = JsonLinker()

# Check the connection to the Json database
if linker.connection_check():
    print("Connected to Json database")

# Put JSON data into the Json database
linker.put_json("1234", {"name": "John", "age": 30})

# Get JSON data from the Json database
data = linker.get_json(["1234"])
print(data)

# Flush the Json database
linker.flush_db()

Please note that the put_json method requires a unique ID and a JSON data as parameters. The get_json method requires a list of IDs as a parameter. The flush_db method does not require any parameters.

PreviousDynamo LinkerNextREDE Search Detector

Last updated 1 year ago