-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
}, | ||
{ | ||
"type": "image_url", | ||
"image_url": {"url": image["base64"]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add image detail
84646f8
to
3a68405
Compare
|
||
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) |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
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"]) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
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.