Refactor public API around environments
This commit is contained in:
parent
57dae52cc2
commit
5d5243df23
41 changed files with 1301 additions and 459 deletions
|
|
@ -32,7 +32,7 @@ TOOL_SPECS: Final[list[dict[str, Any]]] = [
|
|||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"profile": {"type": "string"},
|
||||
"environment": {"type": "string"},
|
||||
"command": {"type": "string"},
|
||||
"vcpu_count": {"type": "integer"},
|
||||
"mem_mib": {"type": "integer"},
|
||||
|
|
@ -40,7 +40,7 @@ TOOL_SPECS: Final[list[dict[str, Any]]] = [
|
|||
"ttl_seconds": {"type": "integer"},
|
||||
"network": {"type": "boolean"},
|
||||
},
|
||||
"required": ["profile", "command", "vcpu_count", "mem_mib"],
|
||||
"required": ["environment", "command", "vcpu_count", "mem_mib"],
|
||||
"additionalProperties": False,
|
||||
},
|
||||
},
|
||||
|
|
@ -48,8 +48,8 @@ TOOL_SPECS: Final[list[dict[str, Any]]] = [
|
|||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "vm_list_profiles",
|
||||
"description": "List standard VM environment profiles.",
|
||||
"name": "vm_list_environments",
|
||||
"description": "List curated Linux environments and installation status.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
|
|
@ -65,13 +65,13 @@ TOOL_SPECS: Final[list[dict[str, Any]]] = [
|
|||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"profile": {"type": "string"},
|
||||
"environment": {"type": "string"},
|
||||
"vcpu_count": {"type": "integer"},
|
||||
"mem_mib": {"type": "integer"},
|
||||
"ttl_seconds": {"type": "integer"},
|
||||
"network": {"type": "boolean"},
|
||||
},
|
||||
"required": ["profile", "vcpu_count", "mem_mib"],
|
||||
"required": ["environment", "vcpu_count", "mem_mib"],
|
||||
"additionalProperties": False,
|
||||
},
|
||||
},
|
||||
|
|
@ -206,7 +206,7 @@ def _dispatch_tool_call(
|
|||
ttl_seconds = arguments.get("ttl_seconds", 600)
|
||||
timeout_seconds = arguments.get("timeout_seconds", 30)
|
||||
return pyro.run_in_vm(
|
||||
profile=_require_str(arguments, "profile"),
|
||||
environment=_require_str(arguments, "environment"),
|
||||
command=_require_str(arguments, "command"),
|
||||
vcpu_count=_require_int(arguments, "vcpu_count"),
|
||||
mem_mib=_require_int(arguments, "mem_mib"),
|
||||
|
|
@ -214,12 +214,12 @@ def _dispatch_tool_call(
|
|||
ttl_seconds=_require_int({"ttl_seconds": ttl_seconds}, "ttl_seconds"),
|
||||
network=_require_bool(arguments, "network", default=False),
|
||||
)
|
||||
if tool_name == "vm_list_profiles":
|
||||
return {"profiles": pyro.list_profiles()}
|
||||
if tool_name == "vm_list_environments":
|
||||
return {"environments": pyro.list_environments()}
|
||||
if tool_name == "vm_create":
|
||||
ttl_seconds = arguments.get("ttl_seconds", 600)
|
||||
return pyro.create_vm(
|
||||
profile=_require_str(arguments, "profile"),
|
||||
environment=_require_str(arguments, "environment"),
|
||||
vcpu_count=_require_int(arguments, "vcpu_count"),
|
||||
mem_mib=_require_int(arguments, "mem_mib"),
|
||||
ttl_seconds=_require_int({"ttl_seconds": ttl_seconds}, "ttl_seconds"),
|
||||
|
|
@ -256,7 +256,7 @@ def _format_tool_error(tool_name: str, arguments: dict[str, Any], exc: Exception
|
|||
|
||||
def _run_direct_lifecycle_fallback(pyro: Pyro) -> dict[str, Any]:
|
||||
return pyro.run_in_vm(
|
||||
profile="debian-git",
|
||||
environment="debian:12",
|
||||
command=NETWORK_PROOF_COMMAND,
|
||||
vcpu_count=1,
|
||||
mem_mib=512,
|
||||
|
|
@ -326,7 +326,7 @@ def run_ollama_tool_demo(
|
|||
"content": (
|
||||
"Use the VM tools to prove outbound internet access in an ephemeral VM.\n"
|
||||
"Prefer `vm_run` unless a lower-level lifecycle step is strictly necessary.\n"
|
||||
"Use profile `debian-git`, choose adequate vCPU/memory, "
|
||||
"Use environment `debian:12`, choose adequate vCPU/memory, "
|
||||
"and set `network` to true.\n"
|
||||
f"Run this exact command: `{NETWORK_PROOF_COMMAND}`.\n"
|
||||
f"Success means the clone completes and the command prints `true`.\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue