File size: 1,148 Bytes
ba94c6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

import time
import sys
import os
from dotenv import load_dotenv

# Add project root to path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

from modules.tools import search_trials
from modules.utils import setup_llama_index

def test_rag_performance():
    load_dotenv()
    
    # Ensure LLM is set up (needed for expand_query if used, though search_trials handles it)
    setup_llama_index()
    
    query = "immunotherapy for lung cancer"
    print(f"πŸš€ Starting RAG Search for: '{query}'")
    
    start_time = time.time()
    try:
        # LangChain tools must be invoked with a dict
        results = search_trials.invoke({"query": query})
        end_time = time.time()
        
        duration = end_time - start_time
        print(f"βœ… Search completed in {duration:.2f} seconds.")
        print(f"πŸ“„ Result length: {len(results)} chars")
        print("--- Preview ---")
        print(results[:500] + "...")
        
    except Exception as e:
        print(f"❌ Search failed: {e}")
        import traceback
        traceback.print_exc()

if __name__ == "__main__":
    test_rag_performance()