Open hliuci opened 3 weeks ago
I don't know if it's related but I can't make the CodeInterpreterTool work either. That said, I don't want to hijack the OP, just maybe complete the debugging info.
For simplicity, I have everything in a single python file:
import os
from crewai import Agent, Task, Crew, Process, LLM
from crewai_tools import SerperDevTool, SeleniumScrapingTool, ScrapeWebsiteTool, FileReadTool, FileWriterTool, CodeInterpreterTool, ScrapeWebsiteTool
os.environ["SERPER_API_KEY"] = "XXXXX"
llm_researcher = LLM(model="ollama_chat/qwen2.5:32b-instruct-q4_K_M_11k", base_url="http://localhost:11434", temperature=0.05)
llm_journalist = LLM(model="ollama_chat/qwen2.5:32b-instruct-q4_K_M_11k", base_url="http://localhost:11434", temperature=0.05)
researcher = Agent(
role='Web Researcher',
goal='Find any information on the web.',
backstory="""You work at a leading web monitoring company.
You have a knack for dissecting complex data and presenting it.""",
verbose=True,
allow_delegation=False,
llm=llm_researcher,
tools=[SerperDevTool(), SeleniumScrapingTool(), FileWriterTool(), FileReadTool()]
)
coder = Agent(
role='Coder',
goal='Solve coding problems and automate tasks.',
backstory="""You are an experienced coder working at a leading BigTech company.
You have a knack for writing efficient code to solve complex data problems.""",
verbose=True,
allow_delegation=False,
llm=llm_researcher,
tools=[CodeInterpreterTool(), FileWriterTool(), FileReadTool()]
)
journalist = Agent(
role='Journalist',
goal="""Summarize any received text, regardless of what type it is.
Go in depth, detail everything.
Organize your summary using headings and subheadings, paragraphs, text styles, lists, quotes, or tables as needed to make the content easy to read.
Adapt the vocabulary so that it is accessible to anyone.""",
backstory="""You are a renowned rigorous journalist known for insightful and engaging articles. You excel at transforming complex concepts into compelling narratives.""",
verbose=True,
allow_delegation=False,
llm=llm_journalist,
tools=[FileWriterTool(), FileReadTool()]
)
task1 = Task(
description="Get the current date/time by executing a minimal python script.",
expected_output="""The current date.""",
agent=coder
)
task2 = Task(
description="Keeping in mind the current date obtained from task1, scrape the content from the second to most recent article on xxxx.",
expected_output="""The raw text of the article.""",
output_file="""article.txt""",
agent=researcher
)
task3 = Task(
description="""Provide a detailed summary of the article contained in article.md.""",
expected_output="""A summary (formatted in Markdown), along with the sources links which it could eventually contain.""",
output_file="""summary.md""",
agent=journalist
)
crew = Crew(
agents=[researcher, journalist],
tasks=[task1, task2, task3],
verbose=True,
#process = Process.hierarchical,
#manager_llm = LLM(model="ollama_chat/qwen2.5:32b-instruct-q4_K_M_11k, base_url="http://localhost:11434", temperature=0.05),
process = Process.sequential
)
result = crew.kickoff()
print("######################")
print(result)
And here is the error I keep on getting:
# Agent: Coder
## Task: Get the current date/time by executing a minimal python script.
I encountered an error while trying to use the tool. This was the error: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory')).
Tool Code Interpreter accepts these inputs: Tool Name: Code Interpreter
Tool Arguments: {'code': {'description': 'Python3 code used to be interpreted in the Docker container. ALWAYS PRINT the final result and the output of the code', 'type': 'str'}, 'libraries_used': {'description': 'List of libraries used in the code with proper installing names separated by commas. Example: numpy,pandas,beautifulsoup4', 'type': 'list[str]'}}
Tool Description: Interprets Python3 code strings with a final print statement.
# Agent: Coder
## Using tool: Code Interpreter
## Tool Input:
"{\"code\": \"from datetime import datetime\\nprint(datetime.now())\", \"libraries_used\": []}"
## Tool Output:
I encountered an error while trying to use the tool. This was the error: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory')).
Tool Code Interpreter accepts these inputs: Tool Name: Code Interpreter
Tool Arguments: {'code': {'description': 'Python3 code used to be interpreted in the Docker container. ALWAYS PRINT the final result and the output of the code', 'type': 'str'}, 'libraries_used': {'description': 'List of libraries used in the code with proper installing names separated by commas. Example: numpy,pandas,beautifulsoup4', 'type': 'list[str]'}}
Tool Description: Interprets Python3 code strings with a final print statement..
Moving on then. I MUST either use a tool (use one at time) OR give my best final answer not both at the same time. To Use the following format:
Thought: you should always think about what to do
Action: the action to take, should be one of [Code Interpreter, File Writer Tool, Read a file's content]
Action Input: the input to the action, dictionary enclosed in curly braces
Observation: the result of the action
... (this Thought/Action/Action Input/Result can repeat N times)
Thought: I now can give a great answer
Final Answer: Your final answer must be the great and the most complete as possible, it must be outcome described
I encountered an error while trying to use the tool. This was the error: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory')).
Tool Code Interpreter accepts these inputs: Tool Name: Code Interpreter
Tool Arguments: {'code': {'description': 'Python3 code used to be interpreted in the Docker container. ALWAYS PRINT the final result and the output of the code', 'type': 'str'}, 'libraries_used': {'description': 'List of libraries used in the code with proper installing names separated by commas. Example: numpy,pandas,beautifulsoup4', 'type': 'list[str]'}}
Tool Description: Interprets Python3 code strings with a final print statement.
I also tried qwen2.5-coder:32b-instruct-q4_K_M without any success. The other tools are working as intended.
I tried with LLM(model="groq/llama-3.1-70b-versatile", temperature=0.05)
but same result
I also need this solution. any one please help to resolve this.
Description
Hi, I am using
Crew AI
to set up an agent to convertJSON
data to anExcel
file and save it in the current directory. I usedCodeInterpreterTool
for the setup. When I run the agent, it showed (the same error exists even withunsafe
mode):And the final answer is:
It seems that the codes were not executed to generate an Excel file.
Steps to Reproduce
The error occured when running the codes below.
Expected behavior
An Excel file is generated and saved in the current directory.
Screenshots/Code snippets
Operating System
Windows 11
Python Version
3.10
crewAI Version
0.70.1
crewAI Tools Version
0.12.1
Virtual Environment
Venv
Evidence
Possible Solution
None
Additional context
NA