Hi All,
I am trying to get the flows routines running - I installed the local env using virtualenv all good.
The code is exactly as per the course:
from crewai.flow.flow import Flow, listen, start
from dotenv import load_dotenv
from litellm import completion
load_dotenv()
class ExampleFlow(Flow):
model = “gpt-4o-mini”
@start()
def generate_city(self):
print("Starting flow")
response = completion(
model=self.model,
messages=[
{
"role": "user",
"content": "Return the name of a random city in the world.",
},
],
)
random_city = response["choices"][0]["message"]["content"]
print(f"Random City: {random_city}")
return random_city
@listen(generate_city)
def generate_fun_fact(self, random_city):
print("Received random city:", random_city)
response = completion(
model=self.model,
messages=[
{
"role": "user",
"content": f"Tell me a fun fact about {random_city}",
},
],
)
fun_fact = response["choices"][0]["message"]["content"]
return fun_fact
print(“Start”)
flow = ExampleFlow()
result = flow.kickoff()
print(f"Generated fun fact: {result}")
When I run it I get the following error:
(crewai-flows) (base) a_shipley@ShipleyAI:~/Conda_env/crewai-flows-crash-course$ /home/a_shipley/anaconda3/envs/crewai-flows/bin/python /home/a_shipley/Conda_env/crewai-flows-crash-course/1_basic_flow/basic_flow.py
Start
Generated fun fact: <coroutine object Flow.kickoff at 0x7fa0bccd43c0>
sys:1: RuntimeWarning: coroutine ‘Flow.kickoff’ was never awaited
I have searched the error and I get that the routine needs an await but this is the original course code so I am not sure why it is failing?
Any help or pointers would be greatly appreciated!
Thanks
Alan.