function extensive_mode_example
Demonstrates the usage of DocChatRAG's extensive mode for detailed document analysis with a sample query about methodologies.
/tf/active/vicechatdev/docchat/example_usage.py
76 - 100
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
pathlibdocument_indexerrag_engineconfig
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
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function full_reading_example 77.4% similar
-
function basic_rag_example 77.2% similar
-
class DocChatRAG 74.8% similar
-
function main_v45 67.6% similar
-
function conversation_example 62.3% similar