🔍 Code Extractor

function full_reading_example

Maturity: 44

Demonstrates the full reading mode of a RAG (Retrieval-Augmented Generation) system by processing all documents to answer a comprehensive query about key findings.

File:
/tf/active/vicechatdev/docchat/example_usage.py
Lines:
103 - 132
Complexity:
simple

Purpose

This function serves as a demonstration/example of how to use the DocChatRAG system in 'full_reading' mode, which processes all available documents rather than using selective retrieval. It showcases progress tracking, result formatting, and metadata extraction. This mode is useful when comprehensive analysis across all documents is needed, though it takes longer (1-5 minutes) than standard retrieval modes.

Source Code

def full_reading_example():
    """Example: Use Full Reading mode"""
    print("\n=== Full Reading Mode Example ===\n")
    
    rag = DocChatRAG()
    
    query = "What are all the key findings across all documents?"
    
    print(f"Query: {query}\n")
    print("Processing all documents (this may take 1-5 minutes)...\n")
    
    # Progress callback
    def show_progress(message):
        print(f"  → {message}")
    
    result = rag.chat(
        query=query,
        mode="full_reading",
        progress_callback=show_progress
    )
    
    print("\nResponse:")
    print("-" * 80)
    print(result['response'])
    print("-" * 80)
    
    print(f"\nMetadata:")
    print(f"  Mode: {result['mode']}")
    print(f"  Total documents: {result.get('num_documents', 0)}")
    print(f"  Relevant documents: {result.get('num_relevant_documents', 0)}")

Return Value

This function does not return any value (implicitly returns None). It prints output directly to the console, including the query, processing progress updates, the generated response, and metadata about the operation (mode used, total documents processed, and number of relevant documents found).

Dependencies

  • pathlib
  • document_indexer
  • rag_engine
  • config

Required Imports

from pathlib import Path
from document_indexer import DocumentIndexer
from rag_engine import DocChatRAG
import config

Usage Example

# Ensure documents are indexed and config is set up
# Then simply call the function:
full_reading_example()

# Expected output:
# === Full Reading Mode Example ===
# Query: What are all the key findings across all documents?
# Processing all documents (this may take 1-5 minutes)...
#   → [progress messages]
# Response:
# --------------------------------------------------------------------------------
# [Generated response with key findings]
# --------------------------------------------------------------------------------
# Metadata:
#   Mode: full_reading
#   Total documents: 10
#   Relevant documents: 8

Best Practices

  • This is a demonstration function meant to be run as an example, not integrated into production code
  • The full_reading mode processes all documents and can take 1-5 minutes - use sparingly and only when comprehensive analysis is needed
  • Consider implementing timeout handling for production use cases
  • The progress_callback pattern shown here is useful for long-running operations to provide user feedback
  • Ensure documents are properly indexed before calling this function
  • For production use, extract the core logic and add error handling around the rag.chat() call
  • Consider adding logging instead of print statements for production environments

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function process_full_reading_background 78.8% similar

    Asynchronous background task processor that executes a full reading mode RAG (Retrieval-Augmented Generation) query, tracks progress, and stores results in session history.

    From: /tf/active/vicechatdev/docchat/app.py
  • function extensive_mode_example 77.4% similar

    Demonstrates the usage of DocChatRAG's extensive mode for detailed document analysis with a sample query about methodologies.

    From: /tf/active/vicechatdev/docchat/example_usage.py
  • function basic_rag_example 75.8% similar

    Demonstrates a basic RAG (Retrieval-Augmented Generation) workflow by initializing a DocChatRAG engine, executing a sample query about document topics, and displaying the response with metadata.

    From: /tf/active/vicechatdev/docchat/example_usage.py
  • class DocChatRAG 75.4% similar

    Main RAG engine with three operating modes: 1. Basic RAG (similarity search) 2. Extensive (full document retrieval with preprocessing) 3. Full Reading (process all documents)

    From: /tf/active/vicechatdev/docchat/rag_engine.py
  • function conversation_example 65.3% similar

    Demonstrates a multi-turn conversational RAG system with chat history management, showing how follow-up questions are automatically optimized based on conversation context.

    From: /tf/active/vicechatdev/docchat/example_usage.py
← Back to Browse