crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
19.25k stars 2.67k forks source link

callback results #274

Closed iplayfast closed 3 weeks ago

iplayfast commented 6 months ago

I was following along a video tutorial https://www.youtube.com/watch?v=Jl6BuoXcZPE&ab_channel=codewithbrandon and everything was working fine. I subsituted ollama for openai but things seemed to be working except for the very last step. The callback function for the last step is missing the task_output.result.

How do I debug this? Where is the callback documentation. Full source at https://github.com/iplayfast/OllamaPlayground/tree/main/crewAIAsync

def save_markdown(task_output):
    #get today's date in the format YYY-MM-DD
    today_date = datetime.now().strftime('%Y-%m-%d')
    # set the filename with today's date
    filename = f"{today_date}.md"
    #write the task output to the markdown file
    with open(filename,'w') as file:
        file.write(task_output.result)########## Error here
    print(f"Newsletter saved as {filename}")
joaomdmoura commented 6 months ago

what version of crewai are you using? because you might want to do task_output.raw_output or you can even have the task save the output by setting a output_file=filename.md to the task

João Moura @joaomdmoura http://twitter.com/joaomdmoura

Em seg., 26 de fev. de 2024 às 04:39, Chris Bruner @.***> escreveu:

I was following along a video tutorial https://www.youtube.com/watch?v=Jl6BuoXcZPE&ab_channel=codewithbrandon and everything was working fine. I subsituted ollama for openai but things seemed to be working except for the very last step. The callback function for the last step is missing the task_output.result.

How do I debug this? Where is the callback documentation. Full source at https://github.com/iplayfast/OllamaPlayground/tree/main/crewAIAsync

def save_markdown(task_output):

get today's date in the format YYY-MM-DD

today_date = datetime.now().strftime('%Y-%m-%d')
# set the filename with today's date
filename = f"{today_date}.md"
#write the task output to the markdown file
with open(filename,'w') as file:
    file.write(task_output.result)########## Error here
print(f"Newsletter saved as {filename}")

— Reply to this email directly, view it on GitHub https://github.com/joaomdmoura/crewAI/issues/274, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFC3N25JPUDHHUTPMSED7LYVQ32JAVCNFSM6AAAAABDZVRALKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGE2TGNBVG43DGMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

iplayfast commented 6 months ago

Well that was interesting

I'm unable to create a comprehensive AI newsletter for you as the required tool "NewsletterCompiler" is not available. However, I can suggest you delegate this 
task to a team member who has expertise in creating newsletters, and provide them with the necessary context and examples for reference. Here's an example messa
ge for delegating the work:

Subject: Request for creating a comprehensive AI newsletter

Hi [Team Member],

I hope this message finds you well. I have been tasked with creating a weekly AI newsletter for our internal team and external subscribers. The newsletter shoul
d include accurate, well-formatted summaries for each AI news story from the provided list. Each summary should provide sufficient context for our readers and m
aintain a consistent style and layout throughout the newsletter as shown in the example output.

Could you please create a comprehensive AI newsletter in markdown format based on this description and the following examples? I believe your expertise in creat
ing newsletters would be greatly beneficial to this project.

If you have any questions or need additional context, feel free to ask. I will ensure that all necessary information is provided.

Looking forward to your contribution!

Please modify the message as per your specific needs and team communication style. Let me know if you require further assistance.
iplayfast commented 6 months ago

just updated to version crewai-0.14.3 Current output:

...
Use Tool: Ask question to co-worker
tool: Co-worker B (Editor)
question: Do the summaries accurately reflect the tone, style, and content of each article? Could you suggest any improvements or revisions to ensure that our newsletter remains engaging for our subscribers? 

Failed to convert text into a pydantic model due to the following error: Failed to parse ToolCalling from completion {'schemaVersion': '1.0.0', 'tools': [{'toolName': 'Delegate work to co-worker', 'description': 'Delegate a specific task to one of the co-workers.', 'arguments': {'coworker': {'type': 'string'}, 'task': {'type': 'string'}, 'context': {'type': 'string'}}, 'validUsageExamples': [{'toolName': 'Co-worker A (AI Specialist)', 'arguments': {'coworker': 'Co-worker A', 'task': 'Analyze each news story from the provided list and summarize the key findings and implications for our audience while maintaining a consistent style and tone.', 'context': "To perform this task effectively, please read through the provided articles carefully. Identify the main points, arguments, and implications of each piece. Once you have a clear understanding, write concise summaries that capture the essence of each news story while adhering to our publication's style and tone. Be sure to include any important details and insights from the articles, as well as your own analysis and interpretation where appropriate. Here are some guiding questions to consider: What is the main issue or problem addressed in each article? What solutions or proposals are put forward? How might these developments impact our audience or the broader field of AI?"}}, {'toolName': 'Co-worker B (Editor)', 'arguments': {'coworker': 'Co-worker B', 'task': 'Create concise summaries for each news story from the provided list while maintaining a consistent style and tone.', 'context': "To perform this task effectively, please read through the full articles carefully. Identify the main points, arguments, and implications of each piece. Once you have a clear understanding, write succinct summaries that capture the essence of each news story while adhering to our publication's style and tone. Be sure to include any important details and insights from the articles, as well as your own analysis and interpretation where appropriate. Remember, the goal is to make the information accessible and engaging for our subscribers."}}]}, {'toolName': 'Ask question to co-worker', 'description': 'Ask a specific question to one of the co-workers.', 'arguments': {'coworker': {'type': 'string'}, 'question': {'type': 'string'}, 'context': {'type': 'string'}}, 'validUsageExamples': [{'toolName': 'Co-worker A (AI Specialist)', 'arguments': {'coworker': 'Co-worker A', 'question': 'Could you please clarify any technical details or complex concepts in the articles that I might not fully understand? Additionally, could you provide your analysis on how these developments might impact the broader field of AI and our audience specifically?'}}, {'toolName': 'Co-worker B (Editor)', 'arguments': {'coworker': 'Co-worker B', 'question': 'Do the summaries accurately reflect the tone, style, and content of each article? Could you suggest any improvements or revisions to ensure that our newsletter remains engaging for our subscribers?'}}]}]}. Got: 2 validation errors for ToolCalling
tool_name
  field required (type=value_error.missing)
arguments
  field required (type=value_error.missing)

stalled at this point. Could one of the other imports be fouling things up?

lvenkataraman commented 4 months ago

Quick question. If I am using different agents to accomplish different custom task executions how to make the Crew route to appropriate agent and get the answer and complete the execution. I tried to use Process.hierarchical thinking if I have multiple agents connected to the process then it will execute the agent and once it gets the answer it will come back. But it takes the output and calls the other agent which is the not the right behaviour in my case because it will get wrong answers.

If question a call Agent A; workflow done If question b call Agent B; workflow done if question c call Agent C; workflow done

In other words I need the Process to operate like a smart router based on the question. Is it possible in CrewAI?

MorphSeur commented 3 months ago

Hello @lvenkataraman,

Any additional info about your issue? I am facing the same error.

Thanks in advance!

github-actions[bot] commented 4 weeks ago

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.

github-actions[bot] commented 3 weeks ago

This issue was closed because it has been stalled for 5 days with no activity.