Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Interpreter Multi-Agent Pipeline #469

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

zyzhang1130
Copy link
Contributor

@zyzhang1130 zyzhang1130 commented Oct 21, 2024


name: Pull Request
about: Create a pull request

Description

An example to demonstrate the problem-solving capability of multiagent LLMs with adaptive planning on various tasks.

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has passed all tests
  • Docstrings have been added/updated in Google Style
  • Documentation has been updated
  • Code is ready for review

update

update

update

updated

Update di_multiagent.py

update

update

Create README.md

Update README.md

undo unnecessary changes

undo unnecessary changes

Update .pre-commit-config.yaml

Update .pre-commit-config.yaml

Update common.py

remove changes in other files

Update README.md

update

updated README and directory name

remove

Update di_multiagent.py
@zyzhang1130 zyzhang1130 force-pushed the data_interpreter_multiagent branch from b01b066 to 83edd23 Compare November 20, 2024 03:53
@zyzhang1130 zyzhang1130 marked this pull request as ready for review November 20, 2024 04:03
@zyzhang1130 zyzhang1130 changed the title [WIP] Data interpreter multiagent pipeline Data interpreter multiagent pipeline Nov 20, 2024
@zyzhang1130 zyzhang1130 changed the title Data interpreter multiagent pipeline Data Interpreter Multi-Agent Pipeline Nov 20, 2024
Slight modification to the format_instruction to improve the success rate of `RegexTaggedContentParser` parsing the model API output.
Copy link
Collaborator

@DavdGao DavdGao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! My only concern is the modification within the react agent. Please see inline comments for details.

@@ -109,7 +109,7 @@ def __init__(

# Initialize a parser object to formulate the response from the model
self.parser = RegexTaggedContentParser(
format_instruction="""Respond with specific tags as outlined below:
format_instruction="""Respond with specific tags as outlined below in json format:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to add the requirement "in json format" here?

For string type, the json format is

<thought>'this is a test'</thought>

while the non-json format is

<thought>this is a test</thought>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my testing, without adding 'in json format', RegexTaggedContentParser cannot successfully parse boolean variables or None (will treat them as strings) and hence cannot be recognized correctly by tools like 'execute_python_code'. E.g., if the RegexTaggedContentParser returns a string None, if use_docker is None will be false.

Copy link
Contributor Author

@zyzhang1130 zyzhang1130 Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: I have modified my PR to override RegexTaggedContentParser's format_instruction within my example. I would caution against using RegexTaggedContentParser when try_parse_json=True without explicit instruction of adhering the arguments of interest to JSON format in format_instruction, since LLMs will likely output contents in other formats and cause json.loads to fail.


This step enables the executed code by the agents to perform required operations that are otherwise restricted by default. Ensure you understand the security implications of modifying these restrictions.

- Comment out the following in `src/agentscope/utils/common.py`:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we have specific working directory here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original create_tempdir creates a temporary directory and changes the current working directory to it; however, it does not persist across different runs of code execution. My solution is to use the current directory for executing code and preserving the execution results.

from agentscope.service.service_status import ServiceExecStatus


def read_csv_file(file_path: str) -> ServiceResponse:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Group this read_csv_file with the one in di_multiagent.py into a util.py file?

Copy link
Contributor Author

@zyzhang1130 zyzhang1130 Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up not using read_csv_file and write_csv_file (the agent is able to use code to achieve the same result), and I observed that giving the agent too many tools can have a detrimental effect on choosing the correct tool to use, so I have removed read_csv_file and write_csv_file from both scripts.

"dependent_task_ids": list[str] = "ids of tasks prerequisite to this task",
"instruction": "what you should do in this task, one short phrase or sentence",
"task_type": "type of this task, should be one of Available Task Types",
"task_type": "type of this task, should be one of Available Task Types",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Duplicate lines?
  2. what are the Available Task Types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Duplicates removed.
  2. Since this framework is designed to be generic, there are actually no pre-defined Available Task Types. task_type is optional since its only purpose at the moment is to give the solver a high-level idea of what kind of tool to employ. I have corrected the relevant prompts.

"dependent_task_ids": list[str] = "ids of tasks prerequisite to this task",
"instruction": "what you should do in this task, one short phrase or sentence",
"task_type": "type of this task, should be one of Available Task Types",
"task_type": "type of this task, should be one of Available Task Types",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same questions as in the comment above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the above

"dependent_task_ids": list[str] = "ids of tasks prerequisite to this task",
"instruction": "what you should do in this task, one short phrase or sentence",
"task_type": "type of this task, should be one of Available Task Types",
"task_type": "type of this task, should be one of Available Task Types",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same questions as the comments above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the above

)


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why here need to have load_dotenv?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line locates the .env file and load_dotenv() reads the .env file and updates os.environ. Without it the API keys won't be loaded properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants