File size: 3,837 Bytes
d5ce935
 
e3e865e
cc6bd3b
e3e865e
d26c7f3
cc6bd3b
d26c7f3
 
e3e865e
cc6bd3b
e3e865e
d26c7f3
cc6bd3b
e3e865e
cc6bd3b
e3e865e
851947c
d5ce935
 
 
 
 
 
851947c
cc6bd3b
e3e865e
d26c7f3
e3e865e
 
d5ce935
e3e865e
fae0e51
 
851947c
 
 
 
fae0e51
 
 
e3e865e
d26c7f3
e3e865e
fae0e51
 
cc6bd3b
d26c7f3
e3e865e
d26c7f3
e3e865e
 
d5ce935
e3e865e
851947c
 
e3e865e
851947c
e3e865e
 
 
851947c
 
e3e865e
d26c7f3
e3e865e
d26c7f3
 
e3e865e
851947c
e3e865e
851947c
d5ce935
 
 
d26c7f3
e3e865e
851947c
e3e865e
d26c7f3
d5ce935
 
 
d26c7f3
e3e865e
d26c7f3
e3e865e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
851947c
 
 
 
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from llama_index.core.tools import FunctionTool

from typing import List

from itf_agent import IAgent
from toolbox import Toolbox
from args import Args


class Summarizer(IAgent):
    def __init__(self, temperature, max_tokens):
        super().__init__(temperature, max_tokens, "04_summarizer.txt", Args.primary_llm_interface)


class Researcher(IAgent):
    def __init__(self, temperature, max_tokens):
        super().__init__(temperature, max_tokens, "05_researcher.txt", Args.primary_llm_interface)

    def setup_tools(self) -> List[FunctionTool]:
        return [
                Toolbox.web_search.duckduckgo_text_search,
                Toolbox.web_search.duckduckgo_images_search,
                Toolbox.web_search.duckduckgo_videos_search
            ]


class EncryptionExpert(IAgent):
    def __init__(self, temperature, max_tokens):
        super().__init__(temperature, max_tokens, "06_encryption_expert.txt", Args.primary_llm_interface)

    def setup_tools(self) -> List[FunctionTool]:
        return [
                Toolbox.encryption.ascii_encode,
                Toolbox.encryption.ascii_decode,
                Toolbox.encryption.base64_encode,
                Toolbox.encryption.base64_decode,
                Toolbox.encryption.caesar_cipher_encode,
                Toolbox.encryption.caesar_cipher_decode,
                Toolbox.encryption.caesar_cipher_brute_force,
                Toolbox.encryption.reverse_string,
                Toolbox.math.unit_converter
            ]

    def setup_slaves(self) -> List:
        reasoner = Reasoner(self.temperature, self.max_tokens)
        return [reasoner]


class MathExpert(IAgent):
    def __init__(self, temperature, max_tokens):
        super().__init__(temperature, max_tokens, "07_math_expert.txt", Args.primary_llm_interface)

    def setup_tools(self) -> List[FunctionTool]:
        return [
            Toolbox.math.symbolic_calc,
            Toolbox.math.unit_converter,
            ]

    def setup_slaves(self) -> List:
        reasoner = Reasoner(self.temperature, self.max_tokens)
        return [reasoner]


class Reasoner(IAgent):
    def __init__(self, temperature, max_tokens):
        super().__init__(temperature, max_tokens, "08_reasoner.txt", Args.primary_llm_interface)


class ImageHandler(IAgent):
    def __init__(self, temperature, max_tokens):
        super().__init__(temperature, max_tokens, "09_image_handler.txt", Args.vlm_interface)

    async def query(self, question: str, has_context=True) -> str:
        return "Image Handler is not available due to maintainance !"


class VideoHandler(IAgent):
    def __init__(self, temperature, max_tokens):
        super().__init__(temperature, max_tokens, "10_video_handler.txt", Args.vlm_interface)

    async def query(self, question: str, has_context=True) -> str:
        return "Video Handler is not available due to maintainance !"


class Solver(IAgent):
    def __init__(self, temperature, max_tokens):
        super().__init__(temperature, max_tokens, "03_solver.txt", Args.primary_llm_interface)

    def setup_slaves(self) -> List:
        summarizer = Summarizer(self.temperature, self.max_tokens)
        researcher = Researcher(self.temperature, self.max_tokens)
        encryption_expert = EncryptionExpert(self.temperature, self.max_tokens)
        math_expert = MathExpert(self.temperature, self.max_tokens)
        reasoner = Reasoner(self.temperature, self.max_tokens)
        image_handler = ImageHandler(self.temperature, self.max_tokens)
        video_handler = VideoHandler(self.temperature, self.max_tokens)

        return [
            summarizer,
            researcher,
            encryption_expert,
            math_expert,
            reasoner,
            image_handler,
            video_handler
            ]


# if __name__ == "__main__":
#     pass