Skip to content

Commit

Permalink
removed write_csv_file
Browse files Browse the repository at this point in the history
unused tool
  • Loading branch information
zyzhang1130 committed Dec 21, 2024
1 parent f940eb9 commit 2f42284
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 83 deletions.
42 changes: 0 additions & 42 deletions examples/data_interpreter_mulit-agent/di_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,48 +46,6 @@ def read_csv_file(file_path: str) -> ServiceResponse:
)


def write_csv_file(
file_path: str,
data: List[List[Any]],
overwrite: bool = False,
) -> ServiceResponse:
"""
Write data to a CSV file.
Args:
file_path (`str`):
The path to the file where the CSV data will be written.
data (`List[List[Any]]`):
The data to write to the CSV file
(each inner list represents a row).
overwrite (`bool`):
Whether to overwrite the file if it already exists.
Returns:
`ServiceResponse`: where the boolean indicates success, and the
str contains an error message if any, including the error type.
"""
if not overwrite and os.path.exists(file_path):
return ServiceResponse(
status=ServiceExecStatus.ERROR,
content="FileExistsError: The file already exists.",
)
try:
with open(file_path, "w", encoding="utf-8", newline="") as file:
writer = csv.writer(file)
writer.writerows(data)
return ServiceResponse(
status=ServiceExecStatus.SUCCESS,
content="Success",
)
except Exception as e:
error_message = f"{e.__class__.__name__}: {e}"
return ServiceResponse(
status=ServiceExecStatus.ERROR,
content=error_message,
)


class PlannerAgent(AgentBase):
"""
PlannerAgent is responsible for decomposing complex tasks into manageable
Expand Down
41 changes: 0 additions & 41 deletions examples/data_interpreter_mulit-agent/di_multiagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,47 +72,6 @@ def read_csv_file(file_path: str) -> ServiceResponse:
)


def write_csv_file(
file_path: str,
data: List[List[Any]],
overwrite: bool = False,
) -> ServiceResponse:
"""
Write data to a CSV file.
Args:
file_path (`str`):
The path to the file where the CSV data will be written.
data (`List[List[Any]]`):
The data to write to the CSV file (each inner list represents a row).
overwrite (`bool`):
Whether to overwrite the file if it already exists.
Returns:
`ServiceResponse`: where the boolean indicates success, and the
str contains an error message if any, including the error type.
"""
if not overwrite and os.path.exists(file_path):
return ServiceResponse(
status=ServiceExecStatus.ERROR,
content="FileExistsError: The file already exists.",
)
try:
with open(file_path, "w", encoding="utf-8", newline="") as file:
writer = csv.writer(file)
writer.writerows(data)
return ServiceResponse(
status=ServiceExecStatus.SUCCESS,
content="Success",
)
except Exception as e:
error_message = f"{e.__class__.__name__}: {e}"
return ServiceResponse(
status=ServiceExecStatus.ERROR,
content=error_message,
)


_ = load_dotenv(find_dotenv()) # read local .env file

openai_api_key = os.getenv("OPENAI_API_KEY")
Expand Down

0 comments on commit 2f42284

Please sign in to comment.