You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Love crewai, but have a hard time making it work (it runs... but making it work...)
not so much an expert with python (using javascript/typescript mostly), but with the help of claude and gpt4o all works out well...
it tuns... and i like the dynamic setup of things. But there seems to be some 'configuration' options (or limitations i am not sure how to deal with) - perhaps using the wrong models or need to specify some prompt templates, but in all examples it works out of the box. And it did work for a short period of time better than now. so i messed up somehing...
hope the message and explanation is familiar and enough to give to some pointers :-)
Any feedback or tips are welcome. I am trying to create some crews that run locally with ollama (tried llama3:8b, mixtral, and some others)
here we go:
it seems the action input is nicely formatted (as a json...)
but it seems the "delegation tool" is being 'called' with (or expects?) something else, so validation seems to fail.
Here is the terminal output:
Entering new CrewAgentExecutor chain...
Thought: To create a comprehensive AI newsletter, I'll need to gather information about the top 5 AI news stories from the past 24 hours. This requires me to delegate tasks to coworkers.
Action: Delegate work to coworker
Action Input: { "task": "fetch top 5 ai news stories", "context": "Please provide a list of the top 5 AI news stories from the past 24 hours, including headlines, summaries, and sources.", "coworker": "NewsFetcher"
I encountered an error while trying to use the tool. This was the error: 3 validation errors for Delegate work to coworkerSchema
task
str type expected (type=type_error.str)
context
str type expected (type=type_error.str)
coworker
str type expected (type=type_error.str).
Tool Delegate work to coworker accepts these inputs: Delegate a specific task to one of the following coworkers: NewsFetcher, NewsAnalyzer, NewsletterCompiler
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.
// extra log on agent step callback:
Agent Step Callback: Agent
Output: [(AgentAction(tool='Delegate work to coworker', tool_input='{"task": "fetch top 5 ai news stories", "context": "Please provide a list of the top 5 AI news stories from the past 24 hours, including headlines, summaries, and sources.", "coworker": "NewsFetcher"}', log='Thought: To create a comprehensive AI newsletter, I'll need to gather information about the top 5 AI news stories from the past 24 hours. This requires me to delegate tasks to coworkers.\n\nAction: Delegate work to coworker\n\nAction Input: { "task": "fetch top 5 ai news stories", "context": "Please provide a list of the top 5 AI news stories from the past 24 hours, including headlines, summaries, and sources.", "coworker": "NewsFetcher"'), "\nI encountered an error while trying to use the tool. This was the error: 3 validation errors for Delegate work to coworkerSchema\ntask\n str type expected (type=type_error.str)\ncontext\n str type expected (type=type_error.str)\ncoworker\n str type expected (type=type_error.str).\n Tool Delegate work to coworker accepts these inputs: Delegate a specific task to one of the following coworkers: NewsFetcher, NewsAnalyzer, NewsletterCompiler\nThe 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..\nMoving on then. I MUST either use a tool (use one at time) OR give my best final answer. To Use the following format:\n\nThought: you should always think about what to do\nAction: the action to take, should be one of [Delegate work to coworker, Ask question to coworker]\nAction Input: the input to the action, dictionary enclosed in curly braces\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now can give a great answer\nFinal Answer: my best complete final answer to the task.\nYour final answer must be the great and the most complete as possible, it must be outcome described\n\n ")]
"""Newsletter crew module for AI newsletter generation."""
from typing import List
from file_io import save_markdown
from models.newsletter_models import NewsletterContent
from models.output import TaskOutput
from schemas import AgentResponse
from tools.search_tools import SearchTools
from crews.base_crew import BaseCrew
from crewai import Agent, Process, Task, Crew
from crewai.project import agent, task, crew
from crewai.agent import BaseAgent
from llm import creative_llm, instructional_llm, tool_llm
class NewsletterCrew(BaseCrew):
"""Crew for generating AI newsletters."""
editor:
role: Editor
goal: Oversee the creation of the AI Newsletter and return the full final compiled formatted newsletter.
backstory: With a keen eye for detail and a passion for storytelling, you ensure that the newsletter not only informs but also engages and inspires the readers.
allow_delegation: True
verbose: True
news_fetcher:
role: NewsFetcher
goal: Fetch the top AI news stories for the day
backstory: As a digital sleuth, you scour the internet for the latest and most impactful developments in the world of AI, ensuring that our readers are always in the know.
allow_delegation: True
verbose: True
news_analyzer:
role: NewsAnalyzer
goal: Analyze each news story and generate a detailed markdown summary
backstory: With a critical eye and a knack for distilling complex information, you provide insightful analyses of AI news stories, making them accessible and engaging for our audience.
allow_delegation: True
verbose: True
newsletter_compiler:
role: NewsletterCompiler
goal: Compile the analyzed news stories into a final newsletter format
backstory: As the final architect of the newsletter, you meticulously arrange and format the content, ensuring a coherent and visually appealing presentation that captivates our readers.
allow_delegation: True
verbose: True
tasks.yaml
project_task:
description: >
Create a newsletter with the top 5 AI news stories from the past 24 hours.
Make sure to include a rundown, detailed bullet points, and a "Why it matters" section for each story.
If you do your BEST WORK, I'll give you a $10,000 commission!
expected_output: >
A complete newsletter in specific markdown format, with a consistent style and layout.
fetch_news_task:
description: >
Fetch top AI news stories from the past 24 hours.
The current time is {current_time}.
If you do your BEST WORK, I'll give you a $10,000 commission!
expected_output: >
A list of top AI news story titles, URLs,
and a brief summary for each story from the past 24 hours.
Example Output:
[
{
'title': 'AI takes spotlight in Super Bowl commercials',
'url': 'https://example.com/story1',
'summary': 'AI made a splash in this year\'s Super Bowl commercials...'
},
{...}
]
analyze_news_task:
description: >
Analyze each news story and ensure there are at least 5 well-formatted articles.
Compile the newsletter from the analyzed news stories.
The final answer must be the full newsletter in markdown format,
only the content of the newsletter and nothing else.
If you do your BEST WORK, I'll give you a $10,000 commission!
expected_output: >
A complete newsletter in markdown format, with a consistent style and layout.
Each article should include a rundown, detailed bullet points, and a "Why it matters" section.
Example Output:
# Top stories in AI today:
- AI takes spotlight in Super Bowl commercials
- Altman seeks TRILLIONS for global AI chip initiative
## AI takes spotlight in Super Bowl commercials
**The Rundown:** AI made a splash in this year's Super Bowl commercials...
**The details:**
- Microsoft's Copilot spot showcased its AI assistant...
**Why it matters:** While AI-related ads have been rampant over the last year,
its Super Bowl presence is a big mainstream moment.
**Sources:**
- [Link to source 1](https://example.com/source1)
- [Link to source 2](https://example.com/source2)
compile_newsletter_task:
description: >
Compile the newsletter from the analyzed news stories.
The final answer must be the full newsletter in markdown format,
only the content of the newsletter and nothing else.
If you do your BEST WORK, I'll give you a $10,000 commission!
expected_output: >
A complete newsletter in markdown format, with a consistent style and layout.
Example Output:
'# Top stories in AI today:
- AI takes spotlight in Super Bowl commercials
- Altman seeks TRILLIONS for global AI chip initiative
## AI takes spotlight in Super Bowl commercials\\n\\n
**The Rundown:** AI made a splash in this year\'s Super Bowl commercials...
**The details:**...
**Why it matters::**...
**Sources:**
- [Link to source 1](https://example.com/source1)
- [Link to source 2](https://example.com/source2)
## Altman seeks TRILLIONS for global AI chip initiative
**The Rundown:** OpenAI CEO Sam Altman is reportedly angling
to raise TRILLIONS of dollars...
**The details:**...
**Why it matters::**...
**Sources:**
- [Link to source 3](https://example.com/source3)
- [Link to source 4](https://example.com/source4)
newsletter_models
"""Models for the AI newsletter content."""
from typing import List
from pydantic import BaseModel, Field
class NewsItem(BaseModel):
"""Represents a single news item in the newsletter."""
title: str = Field(..., description="Title of the news item")
content: str = Field(..., description="Content of the news item")
source: str = Field(..., description="Source of the news item")
class NewsletterContent(BaseModel):
"""Represents the full content of the newsletter."""
title: str = Field(..., description="Title of the newsletter")
introduction: str = Field(
..., description="Introduction paragraph for the newsletter"
)
news_items: List[NewsItem] = Field(
..., description="List of news items in the newsletter"
)
conclusion: str = Field(..., description="Concluding paragraph for the newsletter")
crewai llama model:
FROM llama3:8b
PARAMETER temperature 0.8
PARAMETER stop Result
SYSTEM """"""
main:
def main():
"""Main function to run the AI newsletter generation process."""
Love crewai, but have a hard time making it work (it runs... but making it work...)
not so much an expert with python (using javascript/typescript mostly), but with the help of claude and gpt4o all works out well...
it tuns... and i like the dynamic setup of things. But there seems to be some 'configuration' options (or limitations i am not sure how to deal with) - perhaps using the wrong models or need to specify some prompt templates, but in all examples it works out of the box. And it did work for a short period of time better than now. so i messed up somehing...
hope the message and explanation is familiar and enough to give to some pointers :-)
Any feedback or tips are welcome. I am trying to create some crews that run locally with ollama (tried llama3:8b, mixtral, and some others)
here we go:
it seems the action input is nicely formatted (as a json...)
but it seems the "delegation tool" is being 'called' with (or expects?) something else, so validation seems to fail.
Here is the terminal output:
Action: Delegate work to coworker
Action Input: { "task": "fetch top 5 ai news stories", "context": "Please provide a list of the top 5 AI news stories from the past 24 hours, including headlines, summaries, and sources.", "coworker": "NewsFetcher"
I encountered an error while trying to use the tool. This was the error: 3 validation errors for Delegate work to coworkerSchema
task
str type expected (type=type_error.str)
context
str type expected (type=type_error.str)
coworker
str type expected (type=type_error.str).
Tool Delegate work to coworker accepts these inputs: Delegate a specific task to one of the following coworkers: NewsFetcher, NewsAnalyzer, NewsletterCompiler
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.
// extra log on agent step callback:
Agent Step Callback: Agent
Output: [(AgentAction(tool='Delegate work to coworker', tool_input='{"task": "fetch top 5 ai news stories", "context": "Please provide a list of the top 5 AI news stories from the past 24 hours, including headlines, summaries, and sources.", "coworker": "NewsFetcher"}', log='Thought: To create a comprehensive AI newsletter, I'll need to gather information about the top 5 AI news stories from the past 24 hours. This requires me to delegate tasks to coworkers.\n\nAction: Delegate work to coworker\n\nAction Input: { "task": "fetch top 5 ai news stories", "context": "Please provide a list of the top 5 AI news stories from the past 24 hours, including headlines, summaries, and sources.", "coworker": "NewsFetcher"'), "\nI encountered an error while trying to use the tool. This was the error: 3 validation errors for Delegate work to coworkerSchema\ntask\n str type expected (type=type_error.str)\ncontext\n str type expected (type=type_error.str)\ncoworker\n str type expected (type=type_error.str).\n Tool Delegate work to coworker accepts these inputs: Delegate a specific task to one of the following coworkers: NewsFetcher, NewsAnalyzer, NewsletterCompiler\nThe 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..\nMoving on then. I MUST either use a tool (use one at time) OR give my best final answer. To Use the following format:\n\nThought: you should always think about what to do\nAction: the action to take, should be one of [Delegate work to coworker, Ask question to coworker]\nAction Input: the input to the action, dictionary enclosed in curly braces\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now can give a great answer\nFinal Answer: my best complete final answer to the task.\nYour final answer must be the great and the most complete as possible, it must be outcome described\n\n ")]
[tool.poetry.dependencies]
python = ">=3.10,<=3.13"
crewai = {version = "^0.41.1", extras = ["tools"]}
pydantic = "^2.8.2"
requests = "^2.32.3"
langchain-community = "^0.2.9"
python-dotenv = "^1.0.1"
langchain = "^0.2.10"
crewai-tools = "^0.4.26"
"""Newsletter crew module for AI newsletter generation."""
from typing import List
from file_io import save_markdown
from models.newsletter_models import NewsletterContent
from models.output import TaskOutput
from schemas import AgentResponse
from tools.search_tools import SearchTools
from crews.base_crew import BaseCrew
from crewai import Agent, Process, Task, Crew
from crewai.project import agent, task, crew
from crewai.agent import BaseAgent
from llm import creative_llm, instructional_llm, tool_llm
class NewsletterCrew(BaseCrew):
"""Crew for generating AI newsletters."""
agents.yaml
editor:
role: Editor
goal: Oversee the creation of the AI Newsletter and return the full final compiled formatted newsletter.
backstory: With a keen eye for detail and a passion for storytelling, you ensure that the newsletter not only informs but also engages and inspires the readers.
allow_delegation: True
verbose: True
news_fetcher:
role: NewsFetcher
goal: Fetch the top AI news stories for the day
backstory: As a digital sleuth, you scour the internet for the latest and most impactful developments in the world of AI, ensuring that our readers are always in the know.
allow_delegation: True
verbose: True
news_analyzer:
role: NewsAnalyzer
goal: Analyze each news story and generate a detailed markdown summary
backstory: With a critical eye and a knack for distilling complex information, you provide insightful analyses of AI news stories, making them accessible and engaging for our audience.
allow_delegation: True
verbose: True
newsletter_compiler:
role: NewsletterCompiler
goal: Compile the analyzed news stories into a final newsletter format
backstory: As the final architect of the newsletter, you meticulously arrange and format the content, ensuring a coherent and visually appealing presentation that captivates our readers.
allow_delegation: True
verbose: True
tasks.yaml
project_task:
description: >
Create a newsletter with the top 5 AI news stories from the past 24 hours.
Make sure to include a rundown, detailed bullet points, and a "Why it matters" section for each story.
expected_output: >
A complete newsletter in specific markdown format, with a consistent style and layout.
fetch_news_task:
description: >
Fetch top AI news stories from the past 24 hours.
The current time is {current_time}.
expected_output: >
A list of top AI news story titles, URLs,
and a brief summary for each story from the past 24 hours.
analyze_news_task:
description: >
Analyze each news story and ensure there are at least 5 well-formatted articles.
Compile the newsletter from the analyzed news stories.
The final answer must be the full newsletter in markdown format,
only the content of the newsletter and nothing else.
expected_output: >
A complete newsletter in markdown format, with a consistent style and layout.
Each article should include a rundown, detailed bullet points, and a "Why it matters" section.
compile_newsletter_task:
description: >
Compile the newsletter from the analyzed news stories.
The final answer must be the full newsletter in markdown format,
only the content of the newsletter and nothing else.
expected_output: >
A complete newsletter in markdown format, with a consistent style and layout.
newsletter_models
"""Models for the AI newsletter content."""
from typing import List
from pydantic import BaseModel, Field
class NewsItem(BaseModel):
"""Represents a single news item in the newsletter."""
class NewsletterContent(BaseModel):
"""Represents the full content of the newsletter."""
crewai llama model:
FROM llama3:8b
PARAMETER temperature 0.8
PARAMETER stop Result
SYSTEM """"""
main:
def main():
"""Main function to run the AI newsletter generation process."""
thanks in advance!
The text was updated successfully, but these errors were encountered: