mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-28 01:28:14 +00:00
Fix issue #2647: Make planning LLM inherit authentication parameters from agent's LLM
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -720,8 +720,13 @@ class Crew(BaseModel):
|
||||
def _handle_crew_planning(self):
|
||||
"""Handles the Crew planning."""
|
||||
self._logger.log("info", "Planning the crew execution")
|
||||
|
||||
agent_llm = self.agents[0].llm if self.agents and hasattr(self.agents[0], 'llm') else None
|
||||
|
||||
result = CrewPlanner(
|
||||
tasks=self.tasks, planning_agent_llm=self.planning_llm
|
||||
tasks=self.tasks,
|
||||
planning_agent_llm=self.planning_llm,
|
||||
agent_llm=agent_llm
|
||||
)._handle_crew_planning()
|
||||
|
||||
for task, step_plan in zip(self.tasks, result.list_of_plans_per_task):
|
||||
|
||||
@@ -28,11 +28,22 @@ class PlannerTaskPydanticOutput(BaseModel):
|
||||
|
||||
class CrewPlanner:
|
||||
"""Plans and coordinates the execution of crew tasks."""
|
||||
def __init__(self, tasks: List[Task], planning_agent_llm: Optional[Any] = None):
|
||||
def __init__(self, tasks: List[Task], planning_agent_llm: Optional[Any] = None, agent_llm: Optional[Any] = None):
|
||||
self.tasks = tasks
|
||||
|
||||
if planning_agent_llm is None:
|
||||
self.planning_agent_llm = "gpt-4o-mini"
|
||||
if agent_llm is not None and hasattr(agent_llm, "base_url") and agent_llm.base_url is not None:
|
||||
from crewai.llm import LLM
|
||||
self.planning_agent_llm = LLM(
|
||||
model="gpt-4o-mini",
|
||||
base_url=agent_llm.base_url,
|
||||
api_key=getattr(agent_llm, "api_key", None),
|
||||
organization=getattr(agent_llm, "organization", None),
|
||||
api_version=getattr(agent_llm, "api_version", None),
|
||||
extra_headers=getattr(agent_llm, "extra_headers", None)
|
||||
)
|
||||
else:
|
||||
self.planning_agent_llm = "gpt-4o-mini"
|
||||
else:
|
||||
self.planning_agent_llm = planning_agent_llm
|
||||
|
||||
|
||||
Reference in New Issue
Block a user