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

Ensure agent action is correct #12

Merged
merged 14 commits into from
Jul 28, 2024
Merged

Conversation

GloriaXimingLu
Copy link
Collaborator

@GloriaXimingLu GloriaXimingLu commented Jul 15, 2024

Closes #1

📑 Description

Ensure that the agent's action follow the required format and implemented a rewrite mechanism to ensure the generated action fits into the required API calls before sending it out

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed
  • Branch name follows type/descript (e.g. feature/add-llm-agents)
  • Ready for code review

ℹ Additional Information

@XuhuiZhou XuhuiZhou self-requested a review July 15, 2024 18:01
Copy link
Owner

@XuhuiZhou XuhuiZhou left a comment

Choose a reason for hiding this comment

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

Great first pull request! Yay; Just left a few comments :)

.idea/.gitignore Outdated
Copy link
Owner

Choose a reason for hiding this comment

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

Please .gitignore the files in .idea and .vscode

@@ -1,5 +1,6 @@
from .llm_agent import LLMAgentX
from .llm_agent import LLMAgentX, LLMAgentY
Copy link
Owner

Choose a reason for hiding this comment

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

I know I started with the LLMAgentX haha, but imo we need better naming here:
maybe
LLMAgentX -> LLMAgentHuman
LLMAgentY -> LLMAgentToolcalling ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sounds good! I'll make the name more informative

@@ -110,3 +122,96 @@ async def aact(self, obs: Observation) -> AgentAction:
f"{current_agent} said: ", ""
)
return action


def format_bad_output_tool(
Copy link
Owner

Choose a reason for hiding this comment

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

Why not directly import from Sotopia repo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The format_bad_output from Sotopia requires an argument format_instructions to indicate the correct format for tools. Initially there's not a unified format for all the tools, so I wrote a function to skip this argument, but now we can pass in the format from the tool_parser.py you implemented as the format_instructions to format_bad_output from Sotopia

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah! Sounds great!

)
if action.action_type == "action":
try:
json.loads(action.argument)
Copy link
Owner

Choose a reason for hiding this comment

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

I am wondering, besides checking whether the action.argument can be loaded as a JSON object, it could worthwhile to check whether the input fits the tool argument or not:

Maybe you can borrow the function here:

def validate_inputs(parameters: List[ArgParameter], inputs: Dict[str, Any]):

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll rewrite this!

@XuhuiZhou
Copy link
Owner

XuhuiZhou commented Jul 15, 2024

@GloriaXimingLu One more thing, any chance you can merge main and make the pytest pass? (the pytest at github should be working correctly now)

@GloriaXimingLu
Copy link
Collaborator Author

for sure! I thought I pulled from the latest main before I created my branch, but I'll double check to make sure my branch syn with the current main.

@GloriaXimingLu
Copy link
Collaborator Author

I've updated the branch. The the main update is to add a function validate_agentAction to make sure the agent's action can be parsed into a LangchainAgentAction. I also changed the naming of LLMAgentX and LLMAgentY to be more informative.

@XuhuiZhou XuhuiZhou self-requested a review July 28, 2024 19:42
@XuhuiZhou XuhuiZhou merged commit 0575361 into main Jul 28, 2024
5 checks passed
@XuhuiZhou XuhuiZhou deleted the feature/ensure_agent_action_ximing branch August 12, 2024 03:19
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.

Ensure agent action is correct
2 participants