Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cf.run_tasks() does not create a flow #361

Open
discdiver opened this issue Oct 23, 2024 · 0 comments
Open

cf.run_tasks() does not create a flow #361

discdiver opened this issue Oct 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@discdiver
Copy link
Collaborator

discdiver commented Oct 23, 2024

Description

Running Tasks docs say that with cf.run_tasks() "All of the tasks will be run as part of the same flow (if you are not already operating in a flow context), ..."

I'm not observing that behavior with the code snippet below.

A flow run is created if you use the @cf.flow decorator.

Example Code

import controlflow as cf
from langchain_community.tools import DuckDuckGoSearchRun


summarizer = cf.Agent(
    name="Headline Summarizer",
    instructions="An AI agent that fetches and summarizes current events",
    tools=[DuckDuckGoSearchRun()],
)

extractor = cf.Agent(
    name="Entity Extractor",
    instructions="An AI agent that does named entity recognition",
)


# @cf.flow() # uncomment and the flow is created
def get_headlines():

    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],
    )

    results = cf.run_tasks([summarizer_task, extractor_task])
    return results


if __name__ == "__main__":
    results = get_headlines()
    print(results)

Version Information

ControlFlow version: 0.11.0                                              
       Prefect version: 3.0.10                                              
LangChain Core version: 0.3.12                                              
        Python version: 3.12.2                                              
              Platform: macOS-15.0.1-arm64-arm-64bit                        
                  Path: /opt/homebrew/Caskroom/miniforge/base/lib/python3.12


### Additional Context

_No response_
@discdiver discdiver added the bug Something isn't working label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant