mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
Update config typecheck to accept agents
This commit is contained in:
@@ -103,7 +103,8 @@ def crew(func):
|
|||||||
for task_name in sorted_task_names:
|
for task_name in sorted_task_names:
|
||||||
task_instance = tasks[task_name]()
|
task_instance = tasks[task_name]()
|
||||||
instantiated_tasks.append(task_instance)
|
instantiated_tasks.append(task_instance)
|
||||||
if hasattr(task_instance, "agent"):
|
agent_instance = getattr(task_instance, "agent", None)
|
||||||
|
if agent_instance is not None:
|
||||||
agent_instance = task_instance.agent
|
agent_instance = task_instance.agent
|
||||||
if agent_instance.role not in agent_roles:
|
if agent_instance.role not in agent_roles:
|
||||||
instantiated_agents.append(agent_instance)
|
instantiated_agents.append(agent_instance)
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ def CrewBase(cls):
|
|||||||
tasks_config_path = self.base_directory / self.original_tasks_config_path
|
tasks_config_path = self.base_directory / self.original_tasks_config_path
|
||||||
|
|
||||||
self.agents_config = self.load_yaml(agents_config_path)
|
self.agents_config = self.load_yaml(agents_config_path)
|
||||||
|
print("agent_config", self.agents_config)
|
||||||
self.tasks_config = self.load_yaml(tasks_config_path)
|
self.tasks_config = self.load_yaml(tasks_config_path)
|
||||||
|
print("task_config", self.tasks_config)
|
||||||
|
|
||||||
self.map_all_agent_variables()
|
self.map_all_agent_variables()
|
||||||
self.map_all_task_variables()
|
self.map_all_task_variables()
|
||||||
@@ -136,6 +138,8 @@ def CrewBase(cls):
|
|||||||
output_pydantic_functions,
|
output_pydantic_functions,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print(f"config for task {task_name}:", self.tasks_config[task_name])
|
||||||
|
|
||||||
def _map_task_variables(
|
def _map_task_variables(
|
||||||
self,
|
self,
|
||||||
task_name: str,
|
task_name: str,
|
||||||
@@ -147,6 +151,7 @@ def CrewBase(cls):
|
|||||||
callback_functions: Dict[str, Callable],
|
callback_functions: Dict[str, Callable],
|
||||||
output_pydantic_functions: Dict[str, Callable],
|
output_pydantic_functions: Dict[str, Callable],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
# print("TASK INFO", task_info)
|
||||||
if context_list := task_info.get("context"):
|
if context_list := task_info.get("context"):
|
||||||
self.tasks_config[task_name]["context"] = [
|
self.tasks_config[task_name]["context"] = [
|
||||||
tasks[context_task_name]() for context_task_name in context_list
|
tasks[context_task_name]() for context_task_name in context_list
|
||||||
@@ -175,4 +180,6 @@ def CrewBase(cls):
|
|||||||
callback_functions[callback]() for callback in callbacks
|
callback_functions[callback]() for callback in callbacks
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# print("FINAL TASK CONFIG", self.tasks_config)
|
||||||
|
|
||||||
return WrappedClass
|
return WrappedClass
|
||||||
|
|||||||
@@ -23,17 +23,16 @@ def process_config(
|
|||||||
# Copy values from config (originally from YAML) to the model's attributes.
|
# Copy values from config (originally from YAML) to the model's attributes.
|
||||||
# Only copy if the attribute isn't already set, preserving any explicitly defined values.
|
# Only copy if the attribute isn't already set, preserving any explicitly defined values.
|
||||||
for key, value in config.items():
|
for key, value in config.items():
|
||||||
if key not in model_class.model_fields:
|
if key not in model_class.model_fields or values.get(key) is not None:
|
||||||
continue
|
continue
|
||||||
if values.get(key) is not None:
|
|
||||||
continue
|
if isinstance(value, dict):
|
||||||
if isinstance(value, (str, int, float, bool, list)):
|
|
||||||
values[key] = value
|
|
||||||
elif isinstance(value, dict):
|
|
||||||
if isinstance(values.get(key), dict):
|
if isinstance(values.get(key), dict):
|
||||||
values[key].update(value)
|
values[key].update(value)
|
||||||
else:
|
else:
|
||||||
values[key] = value
|
values[key] = value
|
||||||
|
else:
|
||||||
|
values[key] = value
|
||||||
|
|
||||||
# Remove the config from values to avoid duplicate processing
|
# Remove the config from values to avoid duplicate processing
|
||||||
values.pop("config", None)
|
values.pop("config", None)
|
||||||
|
|||||||
Reference in New Issue
Block a user