-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
88 lines (66 loc) · 2.92 KB
/
example.py
File metadata and controls
88 lines (66 loc) · 2.92 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"""
Example script demonstrating how to use the AI Research Agent.
This script shows different ways to interact with the agent:
1. Direct Python usage
2. Testing individual components
"""
from agent import ResearchAgent
from query_clarifier import QueryClarifier
from scholar_fetcher import ScholarFetcher
def example_full_agent():
"""Example: Run the full agent workflow."""
print("\n" + "="*60)
print("EXAMPLE 1: Full Agent Workflow")
print("="*60)
agent = ResearchAgent(max_papers=5)
result = agent.run("deep learning for medical image analysis")
if result.get("output_file"):
print(f"\n✓ Results saved to: {result['output_file']}")
print(f"✓ Papers found: {len(result.get('papers', []))}")
def example_query_clarification():
"""Example: Test query clarification only."""
print("\n" + "="*60)
print("EXAMPLE 2: Query Clarification Only")
print("="*60)
# You can specify the provider explicitly or let it use env variable
# clarifier = QueryClarifier(provider="openai") # Force OpenAI
# clarifier = QueryClarifier(provider="deepseek") # Force DeepSeek
# clarifier = QueryClarifier(provider="openrouter") # Force OpenRouter
clarifier = QueryClarifier() # Use LLM_PROVIDER from .env
queries = [
"AI for healthcare",
"quantum computing applications",
"renewable energy optimization"
]
for query in queries:
print(f"\nOriginal: {query}")
result = clarifier.clarify(query)
print(f"Clarified: {result.clarified_query}")
print(f"Domain: {result.research_domain}")
print(f"Key Concepts: {', '.join(result.key_concepts[:3])}")
def example_scholar_search():
"""Example: Test Google Scholar search only."""
print("\n" + "="*60)
print("EXAMPLE 3: Google Scholar Search Only")
print("="*60)
fetcher = ScholarFetcher(max_results=3)
papers = fetcher.fetch_papers("transformer models natural language processing")
print(f"\nFound {len(papers)} papers:")
for i, paper in enumerate(papers, 1):
print(f"\n{i}. {paper.title}")
print(f" Year: {paper.year}, Citations: {paper.citation_count}")
if __name__ == "__main__":
print("\n" + "="*70)
print(" AI RESEARCH AGENT - EXAMPLES")
print("="*70)
# Uncomment the examples you want to run:
# Example 1: Full agent workflow (requires OpenAI API key)
# example_full_agent()
# Example 2: Query clarification (requires OpenAI API key)
# example_query_clarification()
# Example 3: Scholar search (no API key needed, but may be slow)
# example_scholar_search()
print("\n" + "="*70)
print("NOTE: Uncomment the examples in the script to run them.")
print("Make sure to set your OPENAI_API_KEY in a .env file first!")
print("="*70 + "\n")