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

Fix docker + qemu #79

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "surfkit"
version = "0.1.218"
version = "0.1.219"
description = "A toolkit for building AI agents that use devices"
authors = ["Patrick Barker <[email protected]>"]
license = "MIT"
Expand Down
9 changes: 5 additions & 4 deletions surfkit/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,8 @@ def list_types():


@app.command("find")
def find():
def find(help="Find an agent"):
"""Find an agent"""
list_types()


Expand Down Expand Up @@ -1657,9 +1658,9 @@ def solve(
vm = vms[0]

if vm.provider and vm.provider.type == "qemu":
if agent_runtime != "process":
if agent_runtime != "process" and agent_runtime != "docker":
raise ValueError(
"Qemu desktop can only be used with the agent 'process' runtime"
"Qemu desktop can only be used with the agent 'process' or 'docker' runtime"
)
_device = Desktop.from_vm(vm)
v1device = _device.to_v1()
Expand Down Expand Up @@ -1818,7 +1819,7 @@ def solve(
pass


@app.command("eval", help="Evaluate an agent on a benchmark")
# @app.command("eval", help="Evaluate an agent on a benchmark") # TODO
def eval(
benchmark: str = typer.Argument(
help="Benchmark name",
Expand Down
17 changes: 17 additions & 0 deletions surfkit/runtime/agent/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,23 @@ def solve_task(
raise ValueError(f"No instances found for name '{name}'")
instance = instances[0]

# TODO: This is a hack to make the qemu desktops work with docker agents, should likely be reworked
if task.task.device and task.task.device.type.lower() == "desktop":
cfg = task.task.device.config
if hasattr(cfg, "agentd_url"):
agentd_url: str = cfg.agentd_url # type: ignore
if agentd_url.startswith("http://localhost"):
agentd_url = agentd_url.replace(
"http://localhost", "http://host.docker.internal"
)
task.task.device.config.agentd_url = agentd_url # type: ignore
logging.debug(f"replaced agentd url: {task.task.device.config}")

elif agentd_url.startswith("localhost"):
agentd_url = agentd_url.replace("localhost", "host.docker.internal")
task.task.device.config.agentd_url = agentd_url # type: ignore
logging.debug(f"replaced agentd url: {task.task.device.config}")

print(f"Container '{name}' found.")
response = requests.post(
f"http://localhost:{instance.port}/v1/tasks",
Expand Down
Loading