Update agents/crew.py
Browse files- agents/crew.py +18 -18
agents/crew.py
CHANGED
|
@@ -5,10 +5,10 @@
|
|
| 5 |
|
| 6 |
import os
|
| 7 |
from agents.llms import (
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
)
|
| 13 |
from agents.tools.ai_tools import AITools
|
| 14 |
from agents.tools.arithmetic_tools import ArithmeticTools
|
|
@@ -29,7 +29,7 @@ class GAIACrew():
|
|
| 29 |
return Agent(
|
| 30 |
config=self.agents_config["web_search_agent"],
|
| 31 |
allow_delegation=False,
|
| 32 |
-
llm=
|
| 33 |
max_iter=2,
|
| 34 |
tools=[AITools.web_search_tool],
|
| 35 |
verbose=True
|
|
@@ -40,7 +40,7 @@ class GAIACrew():
|
|
| 40 |
return Agent(
|
| 41 |
config=self.agents_config["web_browser_agent"],
|
| 42 |
allow_delegation=False,
|
| 43 |
-
llm=
|
| 44 |
max_iter=3,
|
| 45 |
tools=[AITools.web_browser_tool],
|
| 46 |
verbose=True
|
|
@@ -51,7 +51,7 @@ class GAIACrew():
|
|
| 51 |
return Agent(
|
| 52 |
config=self.agents_config["chess_analysis_agent"],
|
| 53 |
allow_delegation=False,
|
| 54 |
-
llm=
|
| 55 |
max_iter=2,
|
| 56 |
tools=[AITools.chess_analysis_tool],
|
| 57 |
verbose=True
|
|
@@ -62,7 +62,7 @@ class GAIACrew():
|
|
| 62 |
return Agent(
|
| 63 |
config=self.agents_config["image_analysis_agent"],
|
| 64 |
allow_delegation=False,
|
| 65 |
-
llm=
|
| 66 |
max_iter=2,
|
| 67 |
tools=[AITools.image_analysis_tool],
|
| 68 |
verbose=True
|
|
@@ -73,7 +73,7 @@ class GAIACrew():
|
|
| 73 |
return Agent(
|
| 74 |
config=self.agents_config["audio_analysis_agent"],
|
| 75 |
allow_delegation=False,
|
| 76 |
-
llm=
|
| 77 |
max_iter=2,
|
| 78 |
tools=[AITools.audio_analysis_tool],
|
| 79 |
verbose=True
|
|
@@ -84,7 +84,7 @@ class GAIACrew():
|
|
| 84 |
return Agent(
|
| 85 |
config=self.agents_config["video_analysis_agent"],
|
| 86 |
allow_delegation=False,
|
| 87 |
-
llm=
|
| 88 |
max_iter=2,
|
| 89 |
tools=[AITools.video_analysis_tool],
|
| 90 |
verbose=True
|
|
@@ -95,7 +95,7 @@ class GAIACrew():
|
|
| 95 |
return Agent(
|
| 96 |
config=self.agents_config["youtube_analysis_agent"],
|
| 97 |
allow_delegation=False,
|
| 98 |
-
llm=
|
| 99 |
max_iter=2,
|
| 100 |
tools=[AITools.youtube_analysis_tool],
|
| 101 |
verbose=True
|
|
@@ -106,7 +106,7 @@ class GAIACrew():
|
|
| 106 |
return Agent(
|
| 107 |
config=self.agents_config["document_analysis_agent"],
|
| 108 |
allow_delegation=False,
|
| 109 |
-
llm=
|
| 110 |
max_iter=2,
|
| 111 |
tools=[AITools.document_analysis_tool],
|
| 112 |
verbose=True
|
|
@@ -117,7 +117,7 @@ class GAIACrew():
|
|
| 117 |
return Agent(
|
| 118 |
config=self.agents_config["document_analysis_agent"],
|
| 119 |
allow_delegation=False,
|
| 120 |
-
llm=
|
| 121 |
max_iter=2,
|
| 122 |
tools=[ArithmeticTools.add, ArithmeticTools.subtract, ArithmeticTools.multiply, ArithmeticTools.divide, ArithmeticTools.modulus],
|
| 123 |
verbose=True
|
|
@@ -128,7 +128,7 @@ class GAIACrew():
|
|
| 128 |
return Agent(
|
| 129 |
config=self.agents_config["code_generation_agent"],
|
| 130 |
allow_delegation=False,
|
| 131 |
-
llm=
|
| 132 |
max_iter=3,
|
| 133 |
tools=[AITools.code_generation_tool],
|
| 134 |
verbose=True
|
|
@@ -139,7 +139,7 @@ class GAIACrew():
|
|
| 139 |
return Agent(
|
| 140 |
config=self.agents_config["code_execution_agent"],
|
| 141 |
allow_delegation=False,
|
| 142 |
-
llm=
|
| 143 |
max_iter=3,
|
| 144 |
tools=[AITools.code_execution_tool],
|
| 145 |
verbose=True
|
|
@@ -150,7 +150,7 @@ class GAIACrew():
|
|
| 150 |
return Agent(
|
| 151 |
config=self.agents_config["manager_agent"],
|
| 152 |
allow_delegation=True,
|
| 153 |
-
llm=
|
| 154 |
max_iter=5,
|
| 155 |
verbose=True
|
| 156 |
)
|
|
@@ -190,12 +190,12 @@ def run_crew(question, file_path):
|
|
| 190 |
return final_answer
|
| 191 |
|
| 192 |
def get_final_answer(question, answer):
|
| 193 |
-
prompt =
|
| 194 |
|
| 195 |
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
| 196 |
|
| 197 |
response = client.models.generate_content(
|
| 198 |
-
model=
|
| 199 |
contents=[prompt]
|
| 200 |
)
|
| 201 |
|
|
|
|
| 5 |
|
| 6 |
import os
|
| 7 |
from agents.llms import (
|
| 8 |
+
LLM_MANAGER,
|
| 9 |
+
LLM_AGENT,
|
| 10 |
+
LLM_FINAL_ANSWER,
|
| 11 |
+
PROMPT_FINAL_ANSWER
|
| 12 |
)
|
| 13 |
from agents.tools.ai_tools import AITools
|
| 14 |
from agents.tools.arithmetic_tools import ArithmeticTools
|
|
|
|
| 29 |
return Agent(
|
| 30 |
config=self.agents_config["web_search_agent"],
|
| 31 |
allow_delegation=False,
|
| 32 |
+
llm=LLM_AGENT,
|
| 33 |
max_iter=2,
|
| 34 |
tools=[AITools.web_search_tool],
|
| 35 |
verbose=True
|
|
|
|
| 40 |
return Agent(
|
| 41 |
config=self.agents_config["web_browser_agent"],
|
| 42 |
allow_delegation=False,
|
| 43 |
+
llm=LLM_AGENT,
|
| 44 |
max_iter=3,
|
| 45 |
tools=[AITools.web_browser_tool],
|
| 46 |
verbose=True
|
|
|
|
| 51 |
return Agent(
|
| 52 |
config=self.agents_config["chess_analysis_agent"],
|
| 53 |
allow_delegation=False,
|
| 54 |
+
llm=LLM_AGENT,
|
| 55 |
max_iter=2,
|
| 56 |
tools=[AITools.chess_analysis_tool],
|
| 57 |
verbose=True
|
|
|
|
| 62 |
return Agent(
|
| 63 |
config=self.agents_config["image_analysis_agent"],
|
| 64 |
allow_delegation=False,
|
| 65 |
+
llm=LLM_AGENT,
|
| 66 |
max_iter=2,
|
| 67 |
tools=[AITools.image_analysis_tool],
|
| 68 |
verbose=True
|
|
|
|
| 73 |
return Agent(
|
| 74 |
config=self.agents_config["audio_analysis_agent"],
|
| 75 |
allow_delegation=False,
|
| 76 |
+
llm=LLM_AGENT,
|
| 77 |
max_iter=2,
|
| 78 |
tools=[AITools.audio_analysis_tool],
|
| 79 |
verbose=True
|
|
|
|
| 84 |
return Agent(
|
| 85 |
config=self.agents_config["video_analysis_agent"],
|
| 86 |
allow_delegation=False,
|
| 87 |
+
llm=LLM_AGENT,
|
| 88 |
max_iter=2,
|
| 89 |
tools=[AITools.video_analysis_tool],
|
| 90 |
verbose=True
|
|
|
|
| 95 |
return Agent(
|
| 96 |
config=self.agents_config["youtube_analysis_agent"],
|
| 97 |
allow_delegation=False,
|
| 98 |
+
llm=LLM_AGENT,
|
| 99 |
max_iter=2,
|
| 100 |
tools=[AITools.youtube_analysis_tool],
|
| 101 |
verbose=True
|
|
|
|
| 106 |
return Agent(
|
| 107 |
config=self.agents_config["document_analysis_agent"],
|
| 108 |
allow_delegation=False,
|
| 109 |
+
llm=LLM_AGENT,
|
| 110 |
max_iter=2,
|
| 111 |
tools=[AITools.document_analysis_tool],
|
| 112 |
verbose=True
|
|
|
|
| 117 |
return Agent(
|
| 118 |
config=self.agents_config["document_analysis_agent"],
|
| 119 |
allow_delegation=False,
|
| 120 |
+
llm=LLM_AGENT,
|
| 121 |
max_iter=2,
|
| 122 |
tools=[ArithmeticTools.add, ArithmeticTools.subtract, ArithmeticTools.multiply, ArithmeticTools.divide, ArithmeticTools.modulus],
|
| 123 |
verbose=True
|
|
|
|
| 128 |
return Agent(
|
| 129 |
config=self.agents_config["code_generation_agent"],
|
| 130 |
allow_delegation=False,
|
| 131 |
+
llm=LLM_AGENT,
|
| 132 |
max_iter=3,
|
| 133 |
tools=[AITools.code_generation_tool],
|
| 134 |
verbose=True
|
|
|
|
| 139 |
return Agent(
|
| 140 |
config=self.agents_config["code_execution_agent"],
|
| 141 |
allow_delegation=False,
|
| 142 |
+
llm=LLM_AGENT,
|
| 143 |
max_iter=3,
|
| 144 |
tools=[AITools.code_execution_tool],
|
| 145 |
verbose=True
|
|
|
|
| 150 |
return Agent(
|
| 151 |
config=self.agents_config["manager_agent"],
|
| 152 |
allow_delegation=True,
|
| 153 |
+
llm=LLM_MANAGER,
|
| 154 |
max_iter=5,
|
| 155 |
verbose=True
|
| 156 |
)
|
|
|
|
| 190 |
return final_answer
|
| 191 |
|
| 192 |
def get_final_answer(question, answer):
|
| 193 |
+
prompt = PROMPT_FINAL_ANSWER.format(question=question, answer=answer)
|
| 194 |
|
| 195 |
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
| 196 |
|
| 197 |
response = client.models.generate_content(
|
| 198 |
+
model=LLM_FINAL_ANSWER,
|
| 199 |
contents=[prompt]
|
| 200 |
)
|
| 201 |
|