Ferocious0xide commited on
Commit
b43ab58
·
verified ·
1 Parent(s): 8839c56

Update app.py with new search features.

Browse files
Files changed (1) hide show
  1. app.py +46 -28
app.py CHANGED
@@ -3,6 +3,10 @@ import datetime
3
  import pytz
4
  import yaml
5
  from tools.final_answer import FinalAnswerTool
 
 
 
 
6
  from Gradio_UI import GradioUI
7
 
8
  @tool
@@ -48,41 +52,55 @@ def initialize_agent():
48
 
49
  # Initialize tools
50
  final_answer = FinalAnswerTool()
 
 
 
 
51
  web_search = DuckDuckGoSearchTool(max_results=5) # Initialize DDG search with 5 results
52
  visit_webpage = VisitWebpageTool()
53
 
54
- # Initialize components
55
- final_answer = FinalAnswerTool()
 
 
 
 
 
56
 
57
- # Initialize the model
58
- model = HfApiModel(
59
- max_tokens=2096,
60
- temperature=0.5,
61
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
62
- custom_role_conversions=None,
63
- )
64
 
65
- # Load prompt templates
66
- with open("prompts.yaml", 'r') as stream:
67
- prompt_templates = yaml.safe_load(stream)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
- # Initialize agent with all tools
70
- agent = CodeAgent(
71
- model=model,
72
- tools=[
73
- final_answer,
74
- calculator,
75
- get_current_time_in_timezone
76
- ],
77
- max_steps=6,
78
- verbosity_level=1,
79
- grammar=None,
80
- planning_interval=None,
81
- name=None,
82
- description=None,
83
- prompt_templates=prompt_templates
84
- )
85
 
86
  # Launch Gradio UI
87
  if __name__ == "__main__":
 
 
 
 
 
88
  GradioUI(agent).launch()
 
3
  import pytz
4
  import yaml
5
  from tools.final_answer import FinalAnswerTool
6
+ from tools.book_tool import BookSearchTool, BookDetailsTool
7
+ from tools.arxiv_tool import ArxivSearchTool, LatestPapersTool
8
+ from tools.search_tool import DuckDuckGoSearchTool, VisitWebpageTool
9
+ from scheduler import initialize_scheduler
10
  from Gradio_UI import GradioUI
11
 
12
  @tool
 
52
 
53
  # Initialize tools
54
  final_answer = FinalAnswerTool()
55
+ book_search = BookSearchTool()
56
+ book_details = BookDetailsTool()
57
+ arxiv_search = ArxivSearchTool()
58
+ latest_papers = LatestPapersTool()
59
  web_search = DuckDuckGoSearchTool(max_results=5) # Initialize DDG search with 5 results
60
  visit_webpage = VisitWebpageTool()
61
 
62
+ # Initialize the model
63
+ model = HfApiModel(
64
+ max_tokens=2096,
65
+ temperature=0.5,
66
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
67
+ custom_role_conversions=None,
68
+ )
69
 
70
+ # Load prompt templates
71
+ with open("prompts.yaml", 'r') as stream:
72
+ prompt_templates = yaml.safe_load(stream)
 
 
 
 
73
 
74
+ # Initialize agent with all tools
75
+ agent = CodeAgent(
76
+ model=model,
77
+ tools=[
78
+ final_answer,
79
+ calculator,
80
+ get_current_time_in_timezone,
81
+ book_search,
82
+ book_details,
83
+ arxiv_search,
84
+ latest_papers,
85
+ web_search,
86
+ visit_webpage
87
+ ],
88
+ max_steps=8,
89
+ verbosity_level=1,
90
+ grammar=None,
91
+ planning_interval=None,
92
+ name="ResearchAssistant",
93
+ description="An AI assistant specialized in helping users discover and research books, papers, and web content on AI and machine learning.",
94
+ prompt_templates=prompt_templates
95
+ )
96
 
97
+ return agent
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  # Launch Gradio UI
100
  if __name__ == "__main__":
101
+ # Initialize the scheduler for daily ArXiv updates
102
+ scheduler = initialize_scheduler()
103
+
104
+ # Initialize and launch the agent
105
+ agent = initialize_agent()
106
  GradioUI(agent).launch()