The llm’s output is correct, however it still have validation error:
Thought: I need to create the CompanyOverview.js file in the correct directory.
Action: FileWriterTool
Action Input: {“content”: “import React from ‘react’;\nimport { Pie } from ‘@ant-design/plots’;\n\nconst CompanyOverview = () => {\n const data = [\n { type: ‘餐饮外卖’, value: 50 },\n { type: ‘到店及酒旅’, value: 23 },\n { type: ‘新业务及其他’, value: 27 },\n ];\n\n const config = {\n appendPadding: 10,\n data,\n angleField: ‘value’,\n colorField: ‘type’,\n radius: 0.8,\n label: {\n type: ‘outer’,\n content: ‘{name} {percentage}’,\n },\n interactions: [{ type: ‘element-active’ }],\n };\n\n return (\n <div className="company-overview">\n
美团公司概况
\n美团是一家科技零售公司,成立于2010年3月。公司以"零售+科技"的战略践行"帮大家吃得更好,生活更好"的使命。
\n业务收入占比
\n <Pie {…config} />\n \n );\n};\n\nexport default CompanyOverview;”, “file_path”: “./meituan-analysis/src/components/CompanyOverview.js”}I encountered an error while trying to use the tool. This was the error: 1 validation error for FileToolsSchema
file_path
field required (type=value_error.missing).
Tool FileWriterTool accepts these inputs: FileWriterTool(content: ‘string’, file_path: ‘string’) - Useful to write content to a file.
This is the tool I defined:
from crewai_tools import BaseTool
class FileTools(BaseTool):
name: str = "FileWriterTool"
description: str = "Useful to write content to a file."
def _run(self, content: str, file_path: str) -> str:
"""Useful to write content to a file.
The input to this tool should be a text representing the content,
and the path of the file.
"""
try:
if not file_path.startswith("./meituan-analysis"):
file_path = f"./meituan-analysis/{file_path}"
with open(file_path, "w") as f:
f.write(content)
return f"File written to {file_path}."
except Exception as e:
print(e)
return "Error with the input format for the tool."