File size: 2,365 Bytes
c79086f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# import smolagents.models as sm_models

# _orig_roles = sm_models.MessageRole.roles

# @classmethod
# def _roles_with_control(cls):
#     return _orig_roles() + ["control"]

# sm_models.MessageRole.roles = _roles_with_control



from smolagents import (CodeAgent, 
                        GradioUI)
from smolagents.default_tools import (DuckDuckGoSearchTool, 
                                      VisitWebpageTool, 
                                      WikipediaSearchTool, 
                                      SpeechToTextTool,
                                      PythonInterpreterTool)
import yaml
from final_answer import FinalAnswerTool, check_reasoning, ensure_formatting
from tools import (use_vision_model, youtube_frames_to_images,
                         read_file, 
                         extract_text_from_image, analyze_csv_file, 
                         analyze_excel_file, youtube_transcribe,
                         transcribe_audio, review_youtube_video)
import os
from model_provider import create_react_model
import time

# Load prompts from YAML file
with open("prompts.yaml", 'r') as stream:
    prompt_templates = yaml.safe_load(stream)
    
def get_manager_agent():
    return CodeAgent(
        model=create_react_model(),
        tools=[FinalAnswerTool(), 
            DuckDuckGoSearchTool(), 
            VisitWebpageTool(max_output_length=500000), 
            WikipediaSearchTool(extract_format='HTML'),
            SpeechToTextTool(),
            youtube_transcribe,
            #    use_vision_model,
            #    youtube_frames_to_images,
            #    review_youtube_video,
            read_file, 
            extract_text_from_image, 
            analyze_csv_file, analyze_excel_file,
            transcribe_audio,
            ],
        managed_agents=[],
        additional_authorized_imports=['os', 'pandas', 'numpy', 'PIL', 'tempfile', 'PIL.Image'],
        max_steps=10,
        verbosity_level=1,
        planning_interval=10,
        name="Manager",
        description="The manager of the team, responsible for overseeing and guiding the team's work.",
        final_answer_checks=[
            check_reasoning, 
            ensure_formatting,
        ],
        prompt_templates=prompt_templates
    )

manager_agent = get_manager_agent()



if __name__ == "__main__":
    GradioUI(manager_agent).launch()