crewAI
crewAI copied to clipboard
Does CrewAI support dynamic generation of multiple agents?
from flask import Flask, request, jsonify
from crewai import Crew
from textwrap import dedent
from stock_analysis_agents import StockAnalysisAgents
from stock_analysis_tasks import StockAnalysisTasks
from dotenv import load_dotenv
load_dotenv()
app = Flask(__name__)
class FinancialCrew:
def __init__(self, company):
self.company = company
def run(self):
agents = StockAnalysisAgents()
tasks = StockAnalysisTasks()
research_analyst_agent = agents.research_analyst()
financial_analyst_agent = agents.financial_analyst()
investment_advisor_agent = agents.investment_advisor()
research_task = tasks.research(research_analyst_agent, self.company)
financial_task = tasks.financial_analysis(financial_analyst_agent)
filings_task = tasks.filings_analysis(financial_analyst_agent)
recommend_task = tasks.recommend(investment_advisor_agent)
crew = Crew(
agents=[
research_analyst_agent,
financial_analyst_agent,
investment_advisor_agent
],
tasks=[
research_task,
financial_task,
filings_task,
recommend_task
],
verbose=True
)
result = crew.kickoff()
return result
@app.route('/analyze', methods=['POST'])
def analyze():
company = request.json.get('company')
financial_crew = FinancialCrew(company)
result = financial_crew.run()
return jsonify(result)
if __name__ == "__main__":
app.run(debug=True)
The above is a scenario example: I have encapsulated multiple agents using the Flask framework. During the running of the Flask program, if I want to dynamically add agents, such as research_analyst_agent2, financial_analyst_agent2, investment_advisor_agent2, how should I proceed?
yes, but you may need to complete the dynamic agent generation on your side.
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.