mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-02 07:42:40 +00:00
update basetool dependencies to use root crewai repo
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
import os
|
||||
from typing import Any, Optional, Type
|
||||
from pydantic import BaseModel
|
||||
from ..base_tool import BaseTool
|
||||
from distutils.util import strtobool
|
||||
from typing import Any, Optional, Type
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class FileWriterToolInput(BaseModel):
|
||||
filename: str
|
||||
filename: str
|
||||
directory: Optional[str] = "./"
|
||||
overwrite: str = "False"
|
||||
content: str
|
||||
|
||||
|
||||
|
||||
class FileWriterTool(BaseTool):
|
||||
name: str = "File Writer Tool"
|
||||
description: str = (
|
||||
@@ -26,7 +28,7 @@ class FileWriterTool(BaseTool):
|
||||
|
||||
# Construct the full path
|
||||
filepath = os.path.join(kwargs.get("directory") or "", kwargs["filename"])
|
||||
|
||||
|
||||
# Convert overwrite to boolean
|
||||
kwargs["overwrite"] = bool(strtobool(kwargs["overwrite"]))
|
||||
|
||||
@@ -46,4 +48,4 @@ class FileWriterTool(BaseTool):
|
||||
except KeyError as e:
|
||||
return f"An error occurred while accessing key: {str(e)}"
|
||||
except Exception as e:
|
||||
return f"An error occurred while writing to the file: {str(e)}"
|
||||
return f"An error occurred while writing to the file: {str(e)}"
|
||||
|
||||
Reference in New Issue
Block a user