Spaces:
Paused
Paused
Modularised the agents 7
Browse files- __pycache__/crew.cpython-310.pyc +0 -0
- crew.py +19 -2
__pycache__/crew.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/crew.cpython-310.pyc and b/__pycache__/crew.cpython-310.pyc differ
|
|
|
crew.py
CHANGED
|
@@ -87,7 +87,7 @@ def get_tools_for(agent_name: str):
|
|
| 87 |
|
| 88 |
#CrewAIInstrumentor().instrument(tracer_provider=tracer_provider)
|
| 89 |
|
| 90 |
-
|
| 91 |
class GAIACrew():
|
| 92 |
tasks: List[Task]
|
| 93 |
|
|
@@ -114,6 +114,22 @@ class GAIACrew():
|
|
| 114 |
for name in self.agents_config
|
| 115 |
]
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
def run_crew(question, file_path):
|
| 119 |
final_question = question
|
|
@@ -125,7 +141,8 @@ def run_crew(question, file_path):
|
|
| 125 |
else:
|
| 126 |
final_question = f"{question} File path: {file_path}."
|
| 127 |
|
| 128 |
-
|
|
|
|
| 129 |
final_answer = get_final_answer(FINAL_ANSWER_MODEL, question, str(answer))
|
| 130 |
|
| 131 |
print(f"=> Initial question: {question}")
|
|
|
|
| 87 |
|
| 88 |
#CrewAIInstrumentor().instrument(tracer_provider=tracer_provider)
|
| 89 |
|
| 90 |
+
#@CrewBase
|
| 91 |
class GAIACrew():
|
| 92 |
tasks: List[Task]
|
| 93 |
|
|
|
|
| 114 |
for name in self.agents_config
|
| 115 |
]
|
| 116 |
|
| 117 |
+
@task
|
| 118 |
+
def manager_task(self) -> Task:
|
| 119 |
+
task = Task(
|
| 120 |
+
config=self.tasks_config["manager_task"]
|
| 121 |
+
)
|
| 122 |
+
task.agent = next(agent for agent in self.agents if agent.config["name"] == "manager_agent")
|
| 123 |
+
return task
|
| 124 |
+
|
| 125 |
+
def get_crew(self) -> Crew:
|
| 126 |
+
return Crew(
|
| 127 |
+
agents=self.agents,
|
| 128 |
+
tasks=[self.manager_task()],
|
| 129 |
+
verbose=True
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
|
| 134 |
def run_crew(question, file_path):
|
| 135 |
final_question = question
|
|
|
|
| 141 |
else:
|
| 142 |
final_question = f"{question} File path: {file_path}."
|
| 143 |
|
| 144 |
+
crew_instance = GAIACrew()
|
| 145 |
+
answer = crew_instance.get_crew().kickoff(inputs={"question": final_question})
|
| 146 |
final_answer = get_final_answer(FINAL_ANSWER_MODEL, question, str(answer))
|
| 147 |
|
| 148 |
print(f"=> Initial question: {question}")
|