diff --git a/libertai_client/commands/agent.py b/libertai_client/commands/agent.py index 8280514..074f06a 100644 --- a/libertai_client/commands/agent.py +++ b/libertai_client/commands/agent.py @@ -10,7 +10,7 @@ from libertai_client.config import config from libertai_client.interfaces.agent import DockerCommand, UpdateAgentResponse -from libertai_client.utils.agent import parse_agent_config_env +from libertai_client.utils.agent import parse_agent_config_env, get_vm_host_url from libertai_client.utils.rich import TaskOfTotalColumn, TEXT_PROGRESS_FORMAT from libertai_client.utils.system import get_full_path @@ -111,4 +111,4 @@ def deploy(path: Annotated[str, typer.Option(help="Path to the root of your repo if agent_result is not None: agent_data = UpdateAgentResponse(**json.loads(agent_result)) - print(f"Agent successfully deployed on https://aleph.sh/vm/{agent_data.vm_hash}") + print(f"Agent successfully deployed on {get_vm_host_url(agent_data.vm_hash)}") diff --git a/libertai_client/utils/agent.py b/libertai_client/utils/agent.py index 84dd497..63ff1e0 100644 --- a/libertai_client/utils/agent.py +++ b/libertai_client/utils/agent.py @@ -1,3 +1,5 @@ +from base64 import b32encode, b16decode + from libertai_client.interfaces.agent import AgentConfig @@ -10,3 +12,8 @@ def parse_agent_config_env(env: dict[str, str | None]) -> AgentConfig: f"Missing {'LIBERTAI_AGENT_ID' if agent_id is None else 'LIBERTAI_AGENT_SECRET'} variable in your project's .env.libertai") return AgentConfig(id=agent_id, secret=agent_secret) + +def get_vm_host_url(item_hash: str) -> str: + # From aleph-client + hash_base32 = b32encode(b16decode(item_hash.upper())).strip(b"=").lower().decode() + return f"https://{hash_base32}.aleph.sh" \ No newline at end of file