function check_rag_config
Diagnostic function that inspects and reports configuration details of a hybrid RAG (Retrieval-Augmented Generation) engine module, including model settings and class attributes.
/tf/active/vicechatdev/vice_ai/check_rag_config.py
8 - 44
moderate
Purpose
This function performs runtime introspection of the hybrid_rag_engine.py module to discover and display its configuration without fully initializing it. It dynamically loads the module, searches for model-related configurations, examines the OneCo_hybrid_RAG class if present, and prints known server configuration details. This is useful for debugging, configuration verification, and understanding the RAG system setup without triggering full initialization.
Source Code
def check_rag_config():
try:
# Minimal import without full initialization
import importlib.util
spec = importlib.util.spec_from_file_location("hybrid_rag_engine", "/tf/active/vice_ai/hybrid_rag_engine.py")
if spec and spec.loader:
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
# Look for default configurations in the module
print("Checking hybrid_rag_engine module for default configurations...")
# Check if there are any default model configurations
for attr_name in dir(module):
attr = getattr(module, attr_name)
if 'gpt' in str(attr).lower() or 'model' in str(attr).lower():
print(f"{attr_name}: {attr}")
# Try to look at the class definition
if hasattr(module, 'OneCo_hybrid_RAG'):
rag_class = getattr(module, 'OneCo_hybrid_RAG')
print(f"RAG class found: {rag_class}")
# Check class attributes and methods
for attr in dir(rag_class):
if 'model' in attr.lower() or 'config' in attr.lower() or 'llm' in attr.lower():
print(f" Class attribute: {attr}")
except Exception as e:
print(f"Error checking RAG config: {e}")
# Also check what the logs showed us from the server
print("\nFrom server logs, we know:")
print("- Main LLM: OpenAI gpt-4o (temp: 0)")
print("- Small LLM: gpt-4o-mini")
print("- Collections: 20 available")
print("- Flow control settings exist")
Return Value
This function does not return any value (implicitly returns None). All output is printed to stdout, including discovered module attributes, class information, and hardcoded server configuration details.
Dependencies
importlib.util
Required Imports
import importlib.util
Conditional/Optional Imports
These imports are only needed under specific conditions:
import importlib.util
Condition: Required for dynamic module loading from file path
Required (conditional)Usage Example
# Simple invocation - no parameters needed
check_rag_config()
# Expected output includes:
# - Module attributes containing 'gpt' or 'model' keywords
# - OneCo_hybrid_RAG class attributes related to models, config, or LLM
# - Hardcoded server configuration summary
# Example output:
# Checking hybrid_rag_engine module for default configurations...
# model_name: gpt-4o
# RAG class found: <class 'OneCo_hybrid_RAG'>
# Class attribute: llm_model
# Class attribute: config_path
#
# From server logs, we know:
# - Main LLM: OpenAI gpt-4o (temp: 0)
# - Small LLM: gpt-4o-mini
# - Collections: 20 available
# - Flow control settings exist
Best Practices
- This function is intended for diagnostic and debugging purposes only, not for production use
- Ensure the target module path (/tf/active/vice_ai/hybrid_rag_engine.py) exists before calling
- The function uses broad exception handling which may mask specific errors - review printed output carefully
- Dynamic module loading can have side effects if the target module has top-level code execution
- The hardcoded server configuration details may become outdated and should be verified against actual logs
- Consider redirecting stdout if you need to capture the output programmatically
- This function performs introspection by searching for keywords ('gpt', 'model', 'config', 'llm') which may produce false positives
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function test_rag_engine 67.4% similar
-
function test_config 63.3% similar
-
function check_configuration 61.9% similar
-
function init_chat_engine_v1 61.2% similar
-
function basic_rag_example 59.7% similar