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
I'm building a multi-agent workflow using crewAi that consists of two main parts:
SQL Query Generation:
I have one agent that uses custom SQL tools (based on crewAi) to generate SQL queries. For example, I use tools like these:
@tool("list_tables")deflist_tables() ->str:
"""List the available tables in the database"""returnListSQLDatabaseTool(db=db).invoke("")
@tool("tables_schema")deftables_schema(tables: str) ->str:
""" Input: a comma-separated list of tables. Output: the schema and sample rows for those tables. """tool_instance=InfoSQLDatabaseTool(db=db)
returntool_instance.invoke(tables)
@tool("execute_sql")defexecute_sql(sql_query: str) ->str:
"""Execute a SQL query against the database and return the result."""returnQuerySQLDataBaseTool(db=db).invoke(sql_query)
@tool("check_sql")defcheck_sql(sql_query: str) ->str:
""" Check the SQL query for common errors before executing it. Input: a string containing the SQL query. """returnQuerySQLCheckerTool(db=db, llm=LLM).invoke({"query": sql_query})
Data Analysis and Graph Generation:
I then have a separate Python Code Interpreter Agent to analyze the SQL results and generate graphs. I get the SQL query from the previous agent and do the analysis using python.
I instantiate the agent like this:
coding_agent=Agent(
role="Python Code Interpreter Agent",
goal="Run code to achieve a task given by the user",
backstory="You are an agent that helps users run Python code.",
allow_code_execution=True,
llm=LLM,
)
My local MySQL database is running with the connection string:
ModuleNotFoundError:
When executing code within the Code Interpreter Agent, I encounter the following error:
ModuleNotFoundError: No module named 'MySQLdb'
It appears that the CrewAi Code Interpreter's Docker image does not have the MySQLdb
Database Connection:
I want the crewAi code interpreter to connect to my local running DB.
Is there a recommended way to install the required MySQLdb module (or mysqlclient) in the Code Interpreter's Docker image? What steps should I take to modify the image or the environment to support this module?
Alternatively, is it better to way to accomplish this task (Analyze DB using user query)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm building a multi-agent workflow using crewAi that consists of two main parts:
SQL Query Generation:
I have one agent that uses custom SQL tools (based on crewAi) to generate SQL queries. For example, I use tools like these:
Data Analysis and Graph Generation:
I then have a separate Python Code Interpreter Agent to analyze the SQL results and generate graphs. I get the SQL query from the previous agent and do the analysis using python.
I instantiate the agent like this:
My local MySQL database is running with the connection string:
Issues
When executing code within the Code Interpreter Agent, I encounter the following error:
It appears that the CrewAi Code Interpreter's Docker image does not have the
MySQLdb
I want the crewAi code interpreter to connect to my local running DB.
Is there a recommended way to install the required
MySQLdb
module (ormysqlclient
) in the Code Interpreter's Docker image? What steps should I take to modify the image or the environment to support this module?Alternatively, is it better to way to accomplish this task (Analyze DB using user query)
Beta Was this translation helpful? Give feedback.
All reactions