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

Creating agents section of Core Concepts - Agents fails #401

Open
bw-matthew opened this issue Jan 20, 2025 · 0 comments
Open

Creating agents section of Core Concepts - Agents fails #401

bw-matthew opened this issue Jan 20, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@bw-matthew
Copy link

Description

The example for the more complex agent fails to run because the controlflow.tools.web module and controlflow.tools.code module are not imported correctly.
This is easy to miss because if you run two imports anywhere in your python environment then the example code will work.

The __init__.py file of the controlflow.tools module has the content:

from controlflow.tools.tools import tool, Tool, as_tools

There is no web or code here so the content of cf.tools is just

dir(cf.tools)

output:

['Tool',
 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 'as_tools',
 'input',
 'tool',
 'tools']

So when you evaluate the expression cf.tools.web.get_url it results in the error AttributeError: module 'controlflow.tools' has no attribute 'web'.
Equally if you evaluate the expression cf.tools.code.python it results in the error AttributeError: module 'controlflow.tools' has no attribute 'code'.

This should be fixed by adding the following imports to the example:

import controlflow.tools.web
import controlflow.tools.code

Example Code

import controlflow as cf

agent = cf.Agent(
    name="Data Analyst",
    description="An AI agent specialized in data analysis",
    instructions=(
        "Perform data analysis tasks efficiently and accurately. "
        "Browse the web for data and use Python to analyze it."
    ),
    tools=[cf.tools.web.get_url, cf.tools.code.python],
    model="openai/gpt-4o",
    interactive=True,
)

Version Information

ControlFlow version: 0.11.4
       Prefect version: 3.1.13
LangChain Core version: 0.3.30
        Python version: 3.12.7
              Platform: Linux-6.8.0-51-generic-x86_64-with-glibc2.39

Additional Context

No response

@bw-matthew bw-matthew added the bug Something isn't working label Jan 20, 2025
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