🔍 Code Extractor

function extensive_mode_example

Maturity: 44

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

File:
/tf/active/vicechatdev/docchat/example_usage.py
Lines:
76 - 100
Complexity:
simple

Purpose

This function serves as a demonstration/example of how to use the DocChatRAG system in 'extensive' mode, which performs more thorough document processing. It showcases querying with higher top_k values (10 documents) for comprehensive analysis, displays processing time expectations, and prints formatted results including response text and metadata. This is primarily an educational/tutorial function for developers learning to use the RAG system.

Source Code

def extensive_mode_example():
    """Example: Use Extensive mode"""
    print("\n=== Extensive Mode Example ===\n")
    
    rag = DocChatRAG()
    
    query = "Provide a detailed summary of the methodologies discussed"
    
    print(f"Query: {query}\n")
    print("Processing (this may take 10-30 seconds)...\n")
    
    result = rag.chat(
        query=query,
        mode="extensive",
        top_k=10
    )
    
    print("Response:")
    print("-" * 80)
    print(result['response'])
    print("-" * 80)
    
    print(f"\nMetadata:")
    print(f"  Mode: {result['mode']}")
    print(f"  Documents processed: {result.get('num_documents', 0)}")

Return Value

This function does not return any value (implicitly returns None). It performs side effects by printing output to the console, including the query, processing status, the RAG system's response, and metadata about the operation (mode used and number of documents processed).

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 all dependencies are installed and configured
# Make sure documents are indexed and config.py is set up

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

# Call the example function
extensive_mode_example()

# Expected output:
# === Extensive Mode Example ===
# Query: Provide a detailed summary of the methodologies discussed
# Processing (this may take 10-30 seconds)...
# Response:
# --------------------------------------------------------------------------------
# [Detailed response from RAG system]
# --------------------------------------------------------------------------------
# Metadata:
#   Mode: extensive
#   Documents processed: 10

Best Practices

  • This is a demonstration function and should not be used in production code directly
  • Ensure the RAG system is properly initialized with indexed documents before calling
  • Be aware that extensive mode takes 10-30 seconds to process as noted in the function
  • The function uses hardcoded query and parameters - modify these for different use cases
  • Consider wrapping the RAG initialization in try-except blocks for production use
  • The top_k=10 parameter retrieves 10 documents, which may be resource-intensive depending on document size
  • Monitor memory usage when processing large document sets in extensive mode

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function full_reading_example 77.4% similar

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

    From: /tf/active/vicechatdev/docchat/example_usage.py
  • function basic_rag_example 77.2% 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 74.8% 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 main_v45 67.6% similar

    Orchestrates and executes a series of example demonstrations for the DocChat system, including document indexing, RAG queries, and conversation modes.

    From: /tf/active/vicechatdev/docchat/example_usage.py
  • function conversation_example 62.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