crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
20.59k stars 2.85k forks source link

[BUG] 'InstructorToolCalling' object is not subscriptable #1515

Open nkeilar opened 3 days ago

nkeilar commented 3 days ago

Description

Saving files tool doesn't seem to work

'InstructorToolCalling' object is not subscriptable

# Agent: Existing Website Analyst
## Thought: Let me create a properly formatted CSV content that analyzes the main content pages and their keywords from the Webflow website.
Thought: I'll create a CSV with headers for Page URL, Page Title, and Primary Keywords based on the content I observed. I need to ensure proper CSV formatting with commas and escaping where needed.
## Using tool: File Writer Tool
## Tool Input: 
"{\"filename\": \"site_analysis.csv\", \"content\": \"Page URL,Page Title,Primary Keywords\\n\\\"/\\\",\\\"Homepage\\\",\\\"website builder, visual website builder, custom website\\\"\\n\\\"/platform/build\\\",\\\"Build Platform\\\",\\\"design, HTML, CSS, JavaScript, visual canvas\\\"\\n\\\"/platform/cms\\\",\\\"CMS Platform\\\",\\\"content management, visual editing, dynamic content\\\"\\n\\\"/platform/hosting\\\",\\\"Hosting Platform\\\",\\\"web hosting, security, scaling\\\"\\n\\\"/platform/analyze\\\",\\\"Analytics Platform\\\",\\\"site performance, visitor behavior, data analysis\\\"\\n\\\"/platform/optimize\\\",\\\"Optimization Platform\\\",\\\"A/B testing, personalization, conversion optimization\\\"\\n\\\"/enterprise\\\",\\\"Enterprise Solutions\\\",\\\"enterprise website, large organizations, scalability\\\"\\n\\\"/for-agencies\\\",\\\"Agency Solutions\\\",\\\"agency tools, client websites, professional development\\\"\\n\\\"/for-freelancers\\\",\\\"Freelancer Solutions\\\",\\\"freelance web design, client projects, professional tools\\\"\\n\\\"/university\\\",\\\"Webflow University\\\",\\\"web design learning, tutorials, education\\\"\\n\\\"/templates\\\",\\\"Templates\\\",\\\"website templates, design templates, customizable layouts\\\"\", \"overwrite\": true}"
## Tool Output: 
I encountered an error: 'InstructorToolCalling' object is not subscriptable
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:

tasks.py

def analyse_website(self, agent):
        writer = FileWriterTool()
        return Task(
            description=dedent(f"""
                Use the website analysis tool to audit the website and identify content areas already covered. Make sure to check the homepage, and sitemap.xml file. You may need to enumaerate the sitemap.xml to get a list of all the pages on the website. Do not read the privacy policy, terms of service, or other non-content pages. Use the File Writer Tool to save the CSV as site_analysis.csv and the Directory tool to validate the file was saved.

                Instructions:
                - Use the FileWriterTool with these parameters:
                    * filename: 'site_analysis.csv'
                    * directory: '{self.output_dir}'
                    * content: <your CSV content>
                    * overwrite: True <- Case sensitive must be capital "True"
                ...
                """),
            expected_output="A CSV formated list of page slugs, and keywords or each page on the website. ",
            agent=agent,
            tools=[writer, self.directory_read_tool]
        )

Steps to Reproduce

Setup task as outlined, try to have it save the contents to a file

Expected behavior

File would be saved

Screenshots/Code snippets

NA

Operating System

Ubuntu 22.04

Python Version

3.10

crewAI Version

crewai==0.65.2

crewAI Tools Version

crewai-tools==0.12.1

Virtual Environment

Poetry

Evidence

Agent: Existing Website Analyst

Thought: Let me create a properly formatted CSV content that analyzes the main content pages and their keywords from the Webflow website.

Thought: I'll create a CSV with headers for Page URL, Page Title, and Primary Keywords based on the content I observed. I need to ensure proper CSV formatting with commas and escaping where needed.

Using tool: File Writer Tool

Tool Input:

"{\"filename\": \"site_analysis.csv\", \"content\": \"Page URL,Page Title,Primary Keywords\n\\"/\\",\\"Homepage\\",\\"website builder, visual website builder, custom website\\"\n\\"/platform/build\\",\\"Build Platform\\",\\"design, HTML, CSS, JavaScript, visual canvas\\"\n\\"/platform/cms\\",\\"CMS Platform\\",\\"content management, visual editing, dynamic content\\"\n\\"/platform/hosting\\",\\"Hosting Platform\\",\\"web hosting, security, scaling\\"\n\\"/platform/analyze\\",\\"Analytics Platform\\",\\"site performance, visitor behavior, data analysis\\"\n\\"/platform/optimize\\",\\"Optimization Platform\\",\\"A/B testing, personalization, conversion optimization\\"\n\\"/enterprise\\",\\"Enterprise Solutions\\",\\"enterprise website, large organizations, scalability\\"\n\\"/for-agencies\\",\\"Agency Solutions\\",\\"agency tools, client websites, professional development\\"\n\\"/for-freelancers\\",\\"Freelancer Solutions\\",\\"freelance web design, client projects, professional tools\\"\n\\"/university\\",\\"Webflow University\\",\\"web design learning, tutorials, education\\"\n\\"/templates\\",\\"Templates\\",\\"website templates, design templates, customizable layouts\\"\", \"overwrite\": true}"

Tool Output:

I encountered an error: 'InstructorToolCalling' object is not subscriptable 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 [Read website content, Search the internet, 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

Possible Solution

Clarify what I'm doing wrong - been at this for about 8 hours and can't for the life of me get the filesaving tool to work.

Additional context

NA

bhancockio commented 9 hours ago

Hey @nkeilar! You aren't doing anything wrong.

We are cutting a new version tonight that will fix this tool calling issue.

In the meantime, try using gpt-4o instead of the default gpt-4o-mini.

I'll drop a comment in here and close out this issue as soon as the new version drops.