File size: 1,996 Bytes
8534dd6
 
 
 
 
 
4a27de3
 
 
 
 
 
 
8534dd6
4a27de3
 
 
8534dd6
4a27de3
 
 
 
 
 
 
 
60d836b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a27de3
8534dd6
4a27de3
 
60d836b
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from helpers import (
    query_you_com,
    query_tavily,
    query_perplexity,
)  # , brave_search_summarization,


def test_queries():
    test_query = "How is the weather in Palo Alto, CA?"

    print("Testing You.com API:")
    # you_com_result = query_you_com(test_query)
    you_com_result = query_you_com(test_query)
    print(you_com_result["answer"])

    print("\nTesting Tavily.com API:")
    tavily_result = query_tavily(test_query)
    print(tavily_result["answer"])

    print("\nTesting Perplexity.ai API:")
    perplexity_result = query_perplexity(test_query)
    print(perplexity_result)

    # print("\nTesting Brave.com API:")
    # brave_result = brave_search_summarization(test_query)
    # print(brave_result)
    
def test_brave_ai_wrapper():
    # Initialize the BraveAIWrapper with your API key
    api_key = "your_api_key_here"
    brave_ai = BraveAIWrapper(api_key=api_key)

    # Define the test query
    query = "What is some of the best mountain biking near Crested Butte, CO?"

    # Test get_brave_results
    print("Testing get_brave_results...")
    results = brave_ai.get_brave_results(query)
    if results:
        print("get_brave_results output:", json.dumps(results, indent=2))
    else:
        print("get_brave_results failed.")

    # Test get_and_summarize
    print("\nTesting get_and_summarize...")
    summary = brave_ai.get_and_summarize(query)
    if summary:
        print("get_and_summarize output:", summary)
    else:
        print("get_and_summarize failed.")

    # Test download_documents
    print("\nTesting download_documents...")
    documents = brave_ai.download_documents(query)
    if documents:
        for doc in documents:
            print("Document metadata:", doc.metadata)
            print("Document content:", doc.page_content[:200])  # Print first 200 characters
            print("-" * 40)
    else:
        print("download_documents failed.")


if __name__ == "__main__":
    test_queries()
    test_brave_ai_wrapper()