|
| 1 | +# Copyright(C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved. |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +"""Shared "agent wheel not installed" messaging. |
| 4 | +
|
| 5 | +The ``gaia-agent-*`` wheels (chat, email, code, sd, docker, ...) are built |
| 6 | +and packaged (``hub/agents/python/<id>/``) but publishing them to PyPI is |
| 7 | +still paused (see ``.github/workflows/publish_agents.yml``, tracked by |
| 8 | +#1179 / #1513). Until that lands, ``pip install gaia-agent-<id>`` and |
| 9 | +``pip install "amd-gaia[agents]"`` both fail on a clean environment (#2240) |
| 10 | +-- so every call site that used to recommend them needs to point at the one |
| 11 | +install path that actually resolves today: pip installing straight from the |
| 12 | +package's subdirectory in this repo. |
| 13 | +""" |
| 14 | + |
| 15 | +# hub/agents/python/<subdir> for each wheel this module has a hint for. Keep |
| 16 | +# in sync with the directories under hub/agents/python/ (ls hub/agents/python/). |
| 17 | +_AGENT_SOURCE_SUBDIRS = { |
| 18 | + "gaia-agent-analyst": "analyst", |
| 19 | + "gaia-agent-blender": "blender", |
| 20 | + "gaia-agent-browser": "browser", |
| 21 | + "gaia-agent-chat": "chat", |
| 22 | + "gaia-agent-code": "code", |
| 23 | + "gaia-agent-connectors-demo": "connectors-demo", |
| 24 | + "gaia-agent-docker": "docker", |
| 25 | + "gaia-agent-docqa": "docqa", |
| 26 | + "gaia-agent-email": "email", |
| 27 | + "gaia-agent-emr": "emr", |
| 28 | + "gaia-agent-fileio": "fileio", |
| 29 | + "gaia-agent-jira": "jira", |
| 30 | + "gaia-agent-routing": "routing", |
| 31 | + "gaia-agent-sd": "sd", |
| 32 | + "gaia-agent-summarize": "summarize", |
| 33 | +} |
| 34 | + |
| 35 | +_REPO_URL = "https://github.com/amd/gaia.git" |
| 36 | + |
| 37 | + |
| 38 | +def source_install_command(wheel: str) -> str: |
| 39 | + """Return the pip command that installs ``wheel`` straight from source. |
| 40 | +
|
| 41 | + Raises ``KeyError`` if ``wheel`` isn't a known ``gaia-agent-*`` package -- |
| 42 | + that's a bug at the call site (a typo'd wheel name), not a runtime |
| 43 | + condition to swallow. |
| 44 | + """ |
| 45 | + subdir = _AGENT_SOURCE_SUBDIRS[wheel] |
| 46 | + return ( |
| 47 | + f'uv pip install "{wheel} @ git+{_REPO_URL}#subdirectory=' |
| 48 | + f'hub/agents/python/{subdir}"' |
| 49 | + ) |
| 50 | + |
| 51 | + |
| 52 | +def agent_not_installed_message( |
| 53 | + subject: str, wheel: str, *, next_step: str = "" |
| 54 | +) -> str: |
| 55 | + """Build the standard "agent not installed" error text for ``wheel``. |
| 56 | +
|
| 57 | + ``subject`` is the complete first sentence, without a trailing period, |
| 58 | + e.g. ``"The chat agent is not installed"`` or ``"The drafting eval needs |
| 59 | + the email agent"``. ``next_step`` is an optional trailing instruction, |
| 60 | + e.g. ``"Then re-run `gaia chat`."``. |
| 61 | +
|
| 62 | + The ``gaia-agent-*`` wheels aren't on PyPI yet (#2240), so this |
| 63 | + deliberately does NOT recommend ``pip install gaia-agent-<id>`` or |
| 64 | + ``pip install "amd-gaia[agents]"`` -- both fail on a clean environment. |
| 65 | + It points at the verified working install instead: pip installing |
| 66 | + straight from this repo's subdirectory. |
| 67 | + """ |
| 68 | + command = source_install_command(wheel) |
| 69 | + message = ( |
| 70 | + f"{subject}. The `{wheel}` package isn't published yet " |
| 71 | + f"(see https://github.com/amd/gaia/issues/2240); install it from " |
| 72 | + f"source instead:\n`{command}`" |
| 73 | + ) |
| 74 | + if next_step: |
| 75 | + message = f"{message} {next_step}" |
| 76 | + return message |
0 commit comments