Skip to content

Commit

Permalink
removed write_csv_file
Browse files Browse the repository at this point in the history
unused
  • Loading branch information
zyzhang1130 committed Dec 21, 2024
1 parent 2f42284 commit 5ffb7d2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 67 deletions.
33 changes: 0 additions & 33 deletions examples/data_interpreter_mulit-agent/di_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"""
This script defines all the agents used in the data interpreter pipeline.
"""
import os
import csv
from typing import Any, Dict, List, Tuple, Optional, Union, Sequence
from agentscope.agents import ReActAgent
from agentscope.agents.agent import AgentBase
Expand All @@ -13,37 +11,6 @@
from agentscope.parsers import MarkdownJsonObjectParser
from agentscope.parsers import RegexTaggedContentParser
from agentscope.service import ServiceToolkit
from agentscope.service.service_response import ServiceResponse
from agentscope.service.service_status import ServiceExecStatus


def read_csv_file(file_path: str) -> ServiceResponse:
"""
Read and parse a CSV file.
Args:
file_path (`str`):
The path to the CSV file to be read.
Returns:
`ServiceResponse`: Where the boolean indicates success, the
Any is the parsed CSV content (typically a list of rows), and
the str contains an error message if any, including the error type.
"""
try:
with open(file_path, "r", encoding="utf-8") as file:
reader = csv.reader(file)
data: List[List[str]] = list(reader)
return ServiceResponse(
status=ServiceExecStatus.SUCCESS,
content=data,
)
except Exception as e:
error_message = f"{e.__class__.__name__}: {e}"
return ServiceResponse(
status=ServiceExecStatus.ERROR,
content=error_message,
)


class PlannerAgent(AgentBase):
Expand Down
34 changes: 0 additions & 34 deletions examples/data_interpreter_mulit-agent/di_multiagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
This script demonstrates task solving with a data interpreter pipeline
formed by multiple agents, each specialized in one aspect of problem solving.
"""
import csv
import os
import copy
from typing import Any, List, Dict, Optional
Expand All @@ -26,8 +25,6 @@
execute_shell_command,
)

from agentscope.service.service_response import ServiceResponse
from agentscope.service.service_status import ServiceExecStatus
from agentscope.parsers import RegexTaggedContentParser

# Global variables for agents with type annotations
Expand All @@ -41,37 +38,6 @@
total_failure_count = 0
max_total_failures = 3 # Adjust as needed


def read_csv_file(file_path: str) -> ServiceResponse:
"""
Read and parse a CSV file.
Args:
file_path (`str`):
The path to the CSV file to be read.
Returns:
`ServiceResponse`: Where the boolean indicates success, the
Any is the parsed CSV content (typically a list of rows),
and the str contains an error message if any, including
the error type.
"""
try:
with open(file_path, "r", encoding="utf-8") as file:
reader = csv.reader(file)
data: List[List[str]] = list(reader)
return ServiceResponse(
status=ServiceExecStatus.SUCCESS,
content=data,
)
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 5ffb7d2

Please sign in to comment.