from crewai import Crew, Process, Agent, Task
from src.sfc_intent.tools.LLMS import my_llm
openai_llm = my_llm("openai")
def my_callback(*args, **kwargs): print("任务执行完毕")
researcher = Agent( role='研究员', goal='进行基础研究', backstory='一位经验丰富的研究员,热衷于发现见解', llm=openai_llm, verbose=True, ) analyst = Agent( role='数据分析师', goal='分析研究结果', backstory='一位细致的分析师,善于发现规律', llm=openai_llm, verbose=True, ) writer = Agent( role='作家', goal='起草最终报告', backstory='一位熟练的作家,具有撰写引人入胜的叙述的天赋', llm=openai_llm, verbose=True, )
research_task = Task(description='收集相关数据...', agent=researcher, expected_output='原始数据',callback=my_callback) analysis_task = Task(description='分析数据...', agent=analyst, expected_output='数据见解') writing_task = Task(description='撰写报告...', agent=writer, expected_output='最终报告')
report_crew = Crew( agents=[researcher, analyst, writer], tasks=[research_task, analysis_task, writing_task], process=Process.sequential, verbose=True, )
result = report_crew.kickoff()
|