Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/generalagents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import httpx
from PIL import Image

from generalagents.action import Action
from generalagents.action import Action, ActionKind


class Session:
Expand All @@ -30,7 +30,12 @@ def __init__(
self.previous_actions = []
self.temperature = temperature

def plan(self, observation: Image.Image) -> Action:
def plan(
self,
observation: Image.Image,
*,
allowed_action_kinds: list[ActionKind] | None = None,
) -> Action:
buffer = BytesIO()
observation.save(buffer, format="WEBP")
image_url = f"data:image/webp;base64,{base64.b64encode(buffer.getvalue()).decode('utf8')}"
Expand All @@ -41,6 +46,7 @@ def plan(self, observation: Image.Image) -> Action:
"image_url": image_url,
"previous_actions": self.previous_actions[-self.max_previous_actions :],
"temperature": self.temperature,
"allowed_action_kinds": allowed_action_kinds,
}

res = self.client.post("/v1/control/predict", json=data)
Expand Down