fix business_headline_sentiment.py example
Closed this issue · 1 comments
Description
running the business_headline_sentiment example returns a validation error (and when fixed just None)
controlflow version: 0.9.4
chat model: ChatGroq from langchain_groq
llm model: "llama3-70b-8192"
The Code
ControlFlow/examples/business_headline_sentiment.py
Lines 19 to 33 in d62e6b3
First Issue:
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Task
agent
Extra inputs are not permitted [type=extra_forbidden, input_value=Agent(id='f4744c26', name...8192', temperature=0.2)), input_type=Agent]
For further information visit https://errors.pydantic.dev/2.9/v/extra_forbidden
-> "agent" property not allowed: should be "agents" and a list
Second Issue
result of both tasks is just None
-> tasks are not invoked at all. At least the extractor_task needs to run (since it depends on the summarizer_task , this will also be invoked)
Proposed Fix
summarizer_task = cf.Task(
"Retrieve and summarize today's two top business headlines",
agents=[summarizer], # <--
result_type=list[str],
)
extractor_task = cf.Task(
"Extract any fortune 500 companies mentioned in the headlines and whether the sentiment is positive, neutral, or negative",
agents=[extractor], # <--
depends_on=[summarizer_task],
)
extractor_task.run() # <--
Thank you! Coincidentally this morning I overhauled all the examples to match the ones in the documentation because I noticed (as you did) that a few were not using the current SDK - that was just merged so while I apologize this example is no longer there, the others should be running smoothly. If any aren't please open another issue and we'll get it corrected ASAP