Issue with custom tool

Getting an error
I encountered an error while trying to use the tool. This was the error: extract_text_tool() missing 1 required positional argument: ‘file_path’.
Tool Extract Text Tool accepts these inputs: Tool Name: Extract Text Tool

@tool(“Extract Text Tool”)
def extract_text_tool(file_path):
“”“This tool reads an image file, converts it to Base64, and extracts text using GPT-4o.”“”
try:
# Step 1: Get file extension to determine MIME type
file_extension = os.path.splitext(file_path)[1].lower()
if file_extension == ‘.png’:
mime_type = ‘image/png’
elif file_extension in [‘.jpg’, ‘.jpeg’]:
mime_type = ‘image/jpeg’
else:
raise ValueError(“Unsupported image format. Only .png, .jpg, and .jpeg are supported.”)

    # Step 2: Convert the image to Base64 encoding
    with open(file_path, "rb") as img_file:
        image_base64 = base64.b64encode(img_file.read()).decode('utf-8')

    # Step 3: Prepare the message for GPT-4 Vision
    messages = HumanMessage(
        content=[
            {"type": "text", "text": "Extract Text from image:"},
            {"type": "image_url", "image_url": {"url": f"data:{mime_type};base64,{image_base64}"}}
        ]
    )
   
    # Step 4: Invoke the LLM client to get the response
    print("Processing image with GPT-4 Vision...")
    llm_client = LLM(  

    )  
    response = llm_client.invoke([messages])  # Ensure that llm_client is set up correctly
    print("LLM execution completed.")
   
    # Step 5: Extract and process the text from the response
    if 'content' in response:
        text = response['content']  # Adjust this based on the actual response structure from GPT-4 Vision
    else:
        print("No text found in the response.")
        text = ""

    return text

except Exception as e:
    print(f"Error processing the image: {e}")
    return "Error extracting text."

task
class ShoppingListTasks:
def init(self, user_input,user_preferences,file_path, extract_text_tool, text_extractor_agent, brand_quantity_agent ):
self.user_input =user_input
self.user_preferences = user_preferences
self.file_path = file_path
self.extract_text_tool = extract_text_tool
self.text_extractor_agent=text_extractor_agent
self.brand_quantity_agent = brand_quantity_agent

def extract_text_task(self):
    """Create a task to identify the user's shopping list and extract relevant details from the provided image."""
    extract_text_task= Task(
    description=(
       f"""Generate an image based on the shopping list in the provided file {self.file_path}. Extract the product names, quantities, and any additional notes, and display them in a clear, organized, and visually appealing layout."""
    ),
    expected_output="""A list of shopping list products extracted from the shopping list image {self.file_path}, including shopping list product names and any associated quantities or notes (if available).""",
    tools=[self.extract_text_tool],
    agent=self.text_extractor_agent,
    file_path=self.file_path )
    return extract_text_task

Please revise your post formatting so that the code is enclosed in three consecutive single backticks. Which represents a code block.
Is your tool located in \src<crew-folder>\tools\custom_tool.py?

Change your function like:

    @tool(“Extract Text Tool”)
    def extract_text_tool(file_path: str) -> str:

You are using the decorator, if this approach doesnt work try creating you tool by subclassing BaseTool. Create Custom Tools - CrewAI

Hope this helps somehow. I am new to crewai myself and also struggle with creating my own custom tool. :wink: