Yago Bolivar commited on
Commit
865a026
·
1 Parent(s): 9a8c22f

fix: update tool instantiation for compatibility and improve requirements

Browse files
Files changed (2) hide show
  1. app.py +21 -96
  2. requirements.txt +3 -4
app.py CHANGED
@@ -45,133 +45,58 @@ video_processor_tool = VideoProcessingTool()
45
  code_execution_tool_instance = CodeExecutionTool()
46
 
47
  # --- Specialized Agents Definition ---
48
- # Create tool instances compatible with the HF Space's smolagents version
49
- web_browse_tool = Tool(
50
- name="browse",
51
- description="Fetches the content of a web page and extracts its text.",
52
- function=web_browser_tool.browse
53
- )
54
-
55
  web_agent = ToolCallingAgent(
56
- tools=[web_browse_tool],
57
  model=model,
58
  name="WebSearchAgent",
59
  description="Handles web browsing tasks, such as fetching content from URLs."
60
  )
61
 
62
- # Create file processing tools
63
- identify_file_tool = Tool(
64
- name="identify_file",
65
- description="Identifies the type of a file and suggests an action based on the file type.",
66
- function=file_identifier_tool.identify_file
67
- )
68
-
69
- parse_spreadsheet_tool = Tool(
70
- name="parse_spreadsheet",
71
- description="Parses a spreadsheet file and returns its content as structured data.",
72
- function=spreadsheet_tool_instance.parse_spreadsheet
73
- )
74
-
75
- transcribe_audio_tool = Tool(
76
- name="transcribe_audio",
77
- description="Transcribes audio content from an audio file to text.",
78
- function=transcribe_audio
79
- )
80
-
81
- parse_markdown_table_tool = Tool(
82
- name="parse_markdown_table",
83
- description="Parses a markdown table and returns its content as structured data.",
84
- function=parse_markdown_table
85
- )
86
-
87
  file_processing_agent = ToolCallingAgent(
88
- tools=[identify_file_tool, parse_spreadsheet_tool, transcribe_audio_tool, parse_markdown_table_tool],
 
 
 
 
 
89
  model=model,
90
  name="FileProcessorAgent",
91
  description="Handles file identification, spreadsheet parsing, audio transcription, and markdown table parsing."
92
  )
93
 
94
- # Create vision tools
95
- process_image_tool = Tool(
96
- name="process_image",
97
- description="Processes an image file and returns information about its content.",
98
- function=image_processor_tool.process_image
99
- )
100
-
101
- extract_text_from_image_tool = Tool(
102
- name="extract_text_from_image",
103
- description="Extracts text from an image using OCR.",
104
- function=image_processor_tool.extract_text_from_image
105
- )
106
-
107
- analyze_chess_image_tool = Tool(
108
- name="analyze_chess_image",
109
- description="Analyzes an image of a chess board and returns information about the position.",
110
- function=image_processor_tool.analyze_chess_image
111
- )
112
-
113
  vision_agent = ToolCallingAgent(
114
- tools=[process_image_tool, extract_text_from_image_tool, analyze_chess_image_tool],
 
 
 
 
115
  model=model,
116
  name="VisionAgent",
117
  description="Handles image processing, OCR, and chess image analysis."
118
  )
119
 
120
- # Create video tools
121
- get_video_transcript_tool = Tool(
122
- name="get_video_transcript",
123
- description="Extracts transcript from a video file.",
124
- function=video_processor_tool.get_video_transcript
125
- )
126
-
127
- download_video_tool = Tool(
128
- name="download_video",
129
- description="Downloads a video from a URL.",
130
- function=video_processor_tool.download_video
131
- )
132
-
133
- extract_frames_tool = Tool(
134
- name="extract_frames",
135
- description="Extracts frames from a video file.",
136
- function=video_processor_tool.extract_frames
137
- )
138
-
139
- detect_objects_in_video_tool = Tool(
140
- name="detect_objects_in_video",
141
- description="Detects objects in a video file.",
142
- function=video_processor_tool.detect_objects_in_video
143
- )
144
-
145
  video_agent = ToolCallingAgent(
146
- tools=[get_video_transcript_tool, download_video_tool, extract_frames_tool, detect_objects_in_video_tool],
 
 
 
 
 
147
  model=model,
148
  name="VideoAgent",
149
  description="Handles video processing tasks like transcript extraction, downloading, frame extraction, and object detection."
150
  )
151
 
152
- # Create code interpreter tool
153
- execute_code_tool = Tool(
154
- name="execute_code",
155
- description="Executes Python code in a controlled environment and returns the result.",
156
- function=code_execution_tool_instance.execute_code
157
- )
158
-
159
  code_interpreter_agent = ToolCallingAgent(
160
- tools=[execute_code_tool],
161
  model=model,
162
  name="CodeInterpreterAgent",
163
  description="Executes Python code snippets in a controlled environment."
164
  )
165
 
166
- # Create text tool
167
- reverse_text_tool = Tool(
168
- name="reverse_text",
169
- description="Reverses the provided text.",
170
- function=reverse_text
171
- )
172
-
173
  text_tool_agent = ToolCallingAgent(
174
- tools=[reverse_text_tool],
175
  model=model,
176
  name="TextToolAgent",
177
  description="Performs text manipulation tasks like reversing text."
 
45
  code_execution_tool_instance = CodeExecutionTool()
46
 
47
  # --- Specialized Agents Definition ---
48
+ # Use a basic list of functions for tools
 
 
 
 
 
 
49
  web_agent = ToolCallingAgent(
50
+ tools=[web_browser_tool.browse],
51
  model=model,
52
  name="WebSearchAgent",
53
  description="Handles web browsing tasks, such as fetching content from URLs."
54
  )
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  file_processing_agent = ToolCallingAgent(
57
+ tools=[
58
+ file_identifier_tool.identify_file,
59
+ spreadsheet_tool_instance.parse_spreadsheet,
60
+ transcribe_audio,
61
+ parse_markdown_table
62
+ ],
63
  model=model,
64
  name="FileProcessorAgent",
65
  description="Handles file identification, spreadsheet parsing, audio transcription, and markdown table parsing."
66
  )
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  vision_agent = ToolCallingAgent(
69
+ tools=[
70
+ image_processor_tool.process_image,
71
+ image_processor_tool.extract_text_from_image,
72
+ image_processor_tool.analyze_chess_image
73
+ ],
74
  model=model,
75
  name="VisionAgent",
76
  description="Handles image processing, OCR, and chess image analysis."
77
  )
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  video_agent = ToolCallingAgent(
80
+ tools=[
81
+ video_processor_tool.get_video_transcript,
82
+ video_processor_tool.download_video,
83
+ video_processor_tool.extract_frames,
84
+ video_processor_tool.detect_objects_in_video
85
+ ],
86
  model=model,
87
  name="VideoAgent",
88
  description="Handles video processing tasks like transcript extraction, downloading, frame extraction, and object detection."
89
  )
90
 
 
 
 
 
 
 
 
91
  code_interpreter_agent = ToolCallingAgent(
92
+ tools=[code_execution_tool_instance.execute_code],
93
  model=model,
94
  name="CodeInterpreterAgent",
95
  description="Executes Python code snippets in a controlled environment."
96
  )
97
 
 
 
 
 
 
 
 
98
  text_tool_agent = ToolCallingAgent(
99
+ tools=[reverse_text],
100
  model=model,
101
  name="TextToolAgent",
102
  description="Performs text manipulation tasks like reversing text."
requirements.txt CHANGED
@@ -1,14 +1,14 @@
1
- attr==0.3.2
2
  beautifulsoup4==4.13.4
3
  chess==1.11.2
4
  colorama==0.4.6
5
- ConfigParser==7.2.0
6
  cryptography==45.0.2
7
  docutils==0.21.2
8
  filelock==3.18.0
9
  gpt4all==2.8.2
10
  gradio==5.30.0
11
- HTMLParser==0.0.2
12
  ipython==9.2.0
13
  ipywidgets==8.1.7
14
  keyring==25.6.0
@@ -24,7 +24,6 @@ python-dotenv==1.1.0
24
  redis==6.1.0
25
  smolagents==1.15.0
26
  Sphinx==8.2.3
27
- thread==2.0.5
28
  torch>=2.0.0
29
  transformers==4.51.3
30
  urllib3_secure_extra==0.1.0
 
1
+ attrs>=21.4.0
2
  beautifulsoup4==4.13.4
3
  chess==1.11.2
4
  colorama==0.4.6
5
+ configparser>=5.0.0
6
  cryptography==45.0.2
7
  docutils==0.21.2
8
  filelock==3.18.0
9
  gpt4all==2.8.2
10
  gradio==5.30.0
11
+ html.parser
12
  ipython==9.2.0
13
  ipywidgets==8.1.7
14
  keyring==25.6.0
 
24
  redis==6.1.0
25
  smolagents==1.15.0
26
  Sphinx==8.2.3
 
27
  torch>=2.0.0
28
  transformers==4.51.3
29
  urllib3_secure_extra==0.1.0