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

Updating generic agent to use the new goal_object #21

Closed
wants to merge 15 commits into from

Conversation

ThibaultLSDC
Copy link
Collaborator

@ThibaultLSDC ThibaultLSDC commented Sep 10, 2024

This will be necessary if we want to run our agent on VWA.
It slightly alters the behavior of the original generic_agent, we might want to look into it.

},
{
"type": "image_url",
"image_url": {"url": image["base64"]},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

add image detail

@ThibaultLSDC
Copy link
Collaborator Author

image
The prompt and xray now looks like this, the goal images are given right after the goal.

@gasse gasse changed the title updating generic agent to accept goal_images Updating generic agent to use the new goal_object Oct 11, 2024
Comment on lines +128 to +136

res = []
for m in messages:
if isinstance(m, list):
assert all(el["type"] == "text" for el in m)
res.append("\n".join(el["content"] for el in m))
else:
res.append(m["content"])
return "\n".join(res)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@recursix could we get your opinion there ?

@@ -74,10 +74,15 @@ def obs_preprocessor(self, obs: dict) -> dict:
@cost_tracker_decorator
def get_action(self, obs):

goal_object = obs.pop("goal_object", [])
if len(goal_object) == 0:
Copy link
Collaborator

Choose a reason for hiding this comment

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

just remove [] and let the error raise itself

Comment on lines +131 to +135
if isinstance(m, list):
assert all(el["type"] == "text" for el in m)
res.append("\n".join(el["content"] for el in m))
else:
res.append(m["content"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

make a generic function prompt_obj_to_str in llm_util.py that can be reused here and in e.g. fit-token

@@ -150,3 +159,11 @@ def parser(response: str) -> tuple[dict, bool, str]:

def experiment_config():
return exp_args
Copy link
Collaborator

@recursix recursix Oct 15, 2024

Choose a reason for hiding this comment

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

oops... copilot?

]
self._prompt = self._update_detail(self._prompt)

def _update_detail(self, prompt):
Copy link
Collaborator

Choose a reason for hiding this comment

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

no need to pass self._prompt

msg = msg.get("content", "No Content")
if isinstance(msg, str):
msg = [{"type": "text", "text": msg}]
messages.append(f"# Message {i}\n")
Copy link
Collaborator

Choose a reason for hiding this comment

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

this codes makes me feel like a lot of this code should be encapsulated in a prompt object.

@@ -7,6 +7,13 @@
from agentlab.agents.generic_agent.generic_agent_prompt import GenericPromptFlags, MainPrompt
from agentlab.llm.llm_utils import count_tokens


def merge_texts(texts):
Copy link
Collaborator

Choose a reason for hiding this comment

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

have a single one of this in llm utils

@ThibaultLSDC ThibaultLSDC changed the base branch from main to dev October 15, 2024 18:54
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.

2 participants