Open din77 opened 18 hours ago
Hey @din77 just testing this now.
Without sharing the tools, if there more of this you could share, specially around the actual Crew
instance definition?
I'm asking because there is a few different ways you can organize delegation, for example:
allow_delegation
to an agent allows us to ask questions and delegate work to others.process
as hierarchical will require you to set either a manager_llm
or a manager_agent
.
manager_llm
crew will create the manager for you using that llm.manager_agent
we will use that agent, the agent don't need to be on the agents
list for the crew.allow_delegation
is not necessary here for the manager to delegate work, unless you want the other agents to be able to delegate tooimport os
from crewai import Agent, Task, Crew
from crewai.process import Process
os.environ["OPENAI_API_KEY"] = "****"
create_portfolio_manager = Agent(
role="Portfolio Manager",
goal="Optimize the investment portfolio for maximum returns while managing risk",
backstory="A seasoned portfolio manager with expertise in asset allocation and risk management.",
verbose=True,
allow_delegation=True, # Added delegation capability
)
create_fundamental_analyst = Agent(
role="Fundamental Analyst",
goal="Analyze economic indicators, financial reports, and market trends to provide insights for investment decisions",
backstory="An experienced financial analyst with a deep understanding of macroeconomic factors and their impact on markets.",
verbose=True,
allow_delegation=True, # Added delegation capability
)
create_technical_analyst = Agent(
role="Technical Analyst",
goal="Perform technical analysis on forex, indices, and commodities to identify trading opportunities",
backstory="A skilled technical analyst with expertise in chart patterns, indicators, and market trends.",
verbose=True,
allow_delegation=True, # Added delegation capability
)
create_researcher = Agent(
role="Researcher",
goal="Gather and analyze financial news, economic data, and market trends to support decision-making",
backstory="A diligent researcher with a knack for uncovering valuable market insights and trends.",
verbose=True,
allow_delegation=True,
)
create_trader = Agent(
role="Trader",
goal="Execute trades based on analysis and market conditions while managing time-sensitive operations",
backstory="An experienced trader with quick decision-making skills and a deep understanding of market dynamics.",
verbose=True,
allow_delegation=True, # Added delegation capability
)
task = Task(
description="""
Develop and implement a comprehensive investment strategy for the next quarter:
1. Analyze current market conditions across forex, indices, and commodities.
2. Identify investment opportunities based on fundamental and technical analysis.
3. Optimize the portfolio allocation to balance potential returns and risks.
4. Execute necessary trades to implement the strategy.
5. Produce a concise report summarizing the analysis, decisions, and actions taken.
""",
expected_output="""
A comprehensive report containing:
1. Executive summary of market analysis and strategy
2. Key market insights and trends identified
3. Detailed portfolio allocation with rationale
4. List of executed trades and their justifications
5. Risk assessment and mitigation strategies
6. Performance projections for the next quarter
7. Recommendations for ongoing monitoring and potential adjustments
"""
)
manager = Agent(
role="Investment Strategy Manager",
goal="Oversee the development and implementation of a comprehensive investment strategy",
backstory="An experienced investment professional with a track record of successfully managing diverse teams and complex financial projects.",
verbose=True,
allow_delegation=True
)
crew = Crew(
agents=[create_portfolio_manager, create_fundamental_analyst, create_technical_analyst, create_researcher, create_trader],
tasks=[task],
process=Process.hierarchical,
manager_agent=manager
)
crew.kickoff()
Thanks for the reply, new to python and this is my first major project...really excited. So based on your reply message, I assumed I was using manager_llm instead of manager_agent. if that is the case, can the manager_agent be assigned cutomized tools and human_input? and if the manager_agent can accept human_put, what file do I add human_input=True? because Im, also having trouble with that...attached are the Crew Ai files (except tools) only....thanks!
Description
Title: Error when using Crew Manager to delegate tasks with Ollama and LiteLLM
Description
When attempting to use the Crew Manager to delegate tasks using the CrewAI framework with Ollama and LiteLLM, an error occurs indicating that the specified coworker is not found.
Environment
Steps to Reproduce
Error Message
Error executing tool. coworker mentioned not found, it must be one of the following options:
Steps to Reproduce
run crew then error happens
Expected behavior
Expected Behavior
The Crew Manager should be able to delegate tasks or ask questions to other agents (coworkers) in the crew.
Actual Behavior
The system only recognizes the "manager" as a valid coworker, preventing the Crew Manager from interacting with other agents.
Possible Causes
Crew
initialization.allow_delegation
flag might not be properly implemented or recognized by the CrewAI framework.Additional Information
Crew
initialization.allow_delegation
flag is set toTrue
for all agents.Any assistance in resolving this issue would be greatly appreciated. Thank you!
Screenshots/Code snippets
agents.py
def _create_manager(self): return Agent( role="Manager", goal="Make high-level decisions and delegate tasks to other agents", backstory="An experienced financial manager with a track record of successful trading strategies and team leadership.", verbose=True, allow_delegation=True, human_input=True, llm=self.model )
Operating System
macOS Ventura
Python Version
3.10
crewAI Version
0.61.0
crewAI Tools Version
0.12.1
Virtual Environment
Conda
Evidence
Agent: Crew Manager
Task: Oversee the entire trading operation. Analyze reports from all agents and make final investment decisions based on collective insights.
Agent: Crew Manager
Using tool: Ask question to coworker
Tool Input:
{ "question": "Can you provide me with a summary and analysis of current market trends from your area?", "context": "As Crew Manager, I need this information to oversee my team's performance in the trading sector.", "coworker": "Agent Smith" }
Tool Output:
Error executing tool. coworker mentioned not found, it must be one of the following options:
Action 'Ask question to coworker (corrected)' don't exist, these are the only available Actions: Tool Name: Delegate work to coworker(task: str, context: str, coworker: Optional[str] = None, kwargs) Tool Description: Delegate a specific task to one of the following coworkers: Manager The input to this tool should be the coworker, the task you want them to do, and ALL necessary context to execute the task, they know nothing about the task, so share absolute everything you know, don't reference things but instead explain them. Tool Arguments: {'task': {'title': 'Task', 'type': 'string'}, 'context': {'title': 'Context', 'type': 'string'}, 'coworker': {'title': 'Coworker', 'type': 'string'}, 'kwargs': {'title': 'Kwargs', 'type': 'object'}} Tool Name: Ask question to coworker(question: str, context: str, coworker: Optional[str] = None, kwargs) Tool Description: Ask a specific question to one of the following coworkers: Manager The input to this tool should be the coworker, the question you have for them, and ALL necessary context to ask the question properly, they know nothing about the question, so share absolute everything you know, don't reference things but instead explain them. Tool Arguments: {'question': {'title': 'Question', 'type': 'string'}, 'context': {'title': 'Context', 'type': 'string'}, 'coworker': {'title': 'Coworker', 'type': 'string'}, 'kwargs': {'title': 'Kwargs', 'type': 'object'}}
Possible Solution
n/a
Additional context
model
gtraders = Gtraders(model="ollama/phi3.5:3.8b")
Initialize the LLM using LiteLLM
model = "ollama/phi3.5:3.8b" manager_llm = "ollama/phi3.5:3.8b"