- 使用 ComfyUI 和 Z Image Turbo 生成图像
- 使用 LM Studio 运行并提供 LLM 服务
- 使用 n8n 和本地 LLM 自动化工作流
- 使用 VS Code 和 Qwen3-Coder 进行本地 LLM 编码
- 基于 AMD ROCm™ 软件在 PyTorch 上运行 LLM
- AMD Ryzen™ AI NPU 本地计算机视觉
- Lemonade 入门指南
- Ollama 入门
- OpenHands 与本地 LLM 入门指南
- Ryzen AI Halo(代号 Project Zenith)入门指南
- Ryzen™ AI Halo 双机通过 RPC 集群
- vLLM 入门指南
- 两台 Ryzen™ AI Halo 的 RCCL 集群
- 使用 AMD Sync 进行远程开发
- 使用 ds4 运行 DeepSeek V4 Flash
- 使用 GAIA 构建你的第一个智能体
- 使用 Lemonade Server 在本地运行 OpenClaw
- 使用 LLaMA-Factory 微调 LLM
- 使用 PyTorch 和 AMD ROCm™ 构建自定义 GPU 内核
- 使用 PyTorch 和 AMD ROCm™ 软件微调大语言模型
- 使用 Unsloth 微调 LLM
- 使用智能体画布构建 GitHub 到 Slack 的开发摘要
- 四台 Ryzen™ AI Halo 的 RCCL 集群
- 在 Open WebUI 中与大语言模型聊天
- 在本地通过 Lemonade Server 运行 Hermes 智能体
- 实时语音到语音翻译
- 集群化四台 Ryzen™ AI Halo
| AMD GPU Driver | 来自 Ryzen AI Developer Center 的最新版本 |
| Lemonade | 11.8 |
| GAIA | 0.22.0 |
| AMD GPU Driver | 26.8.1 (from Ryzen AI Developer Center) |
| Lemonade | 11.7 |
| GAIA | 0.22.0 |
| AMD GPU Driver | Latest inbox driver |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
| AMD GPU Driver | Adrenalin 26.10.1 |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
| AMD GPU Driver | Latest inbox driver |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
| AMD GPU Driver | Adrenalin 26.10.1 |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
| AMD GPU Driver | Latest inbox driver |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
| AMD GPU Driver | Adrenalin 26.10.1 |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
| AMD GPU Driver | RSL 26.14 |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
| AMD GPU Driver | Adrenalin 26.10.1 |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
| AMD GPU Driver | RSL 26.14 |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
| AMD GPU Driver | Adrenalin 26.10.1 |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
| AMD GPU Driver | RSL 26.14 |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
| AMD GPU Driver | Adrenalin 26.10.1 |
| Lemonade | 最新版本 |
| GAIA | 最新版本 |
使用 GAIA 构建你的第一个智能体
构建 100% 本地化的 AI 智能体 —— 无需云端 API。使用 GAIA SDK 创建一个硬件顾问。
概述
GAIA 智能体是使用本地 LLM 进行推理并调用你定义的工具的 AI 助手——就像可以采取行动的聊天机器人。它们100% 本地运行,无需云 API,没有数据离开你的机器,也不需要 API 密钥。
在本教程中,你将构建一个硬件顾问智能体,用于检测你系统的 RAM、GPU 和 NPU,查询本地模型目录,并推荐你的机器可以运行哪些 LLM。这是对 GAIA Agent SDK 的实用入门介绍,可以立即产生有用的成果。
你将学到什么
- 如何创建一个带有自定义工具的 GAIA 智能体
- 使用 LemonadeClient SDK 查询系统信息和模型目录
- 特定平台的 GPU/NPU 检测(Windows PowerShell 和 Linux lspci)
- 基于内存的模型大小计算(70% 规则)
- 构建用于自然语言硬件查询的交互式 CLI
设置内存配置
对于 Ryzen AI Halo,专用 GPU 内存默认为 64GB,这对大多数工作负载来说已经足够。对于更大的模型或更长的上下文,将其增加到 96GB 可能会有所帮助。要进行调整,请打开 AMD Software: Adrenalin Edition™,并导航到 Performance → Tuning → AMD Variable Graphics Memory。重启后更改才会生效。

要更改专用 GPU 内存值,请打开 AMD Software: Adrenalin Edition™,并导航到 Performance → Tuning → AMD Variable Graphics Memory。重启后更改才会生效。

在 Linux 上,要运行更大的模型,请增加 GPU 可用的共享内存池。这可能需要将 BIOS 中的专用 GPU 内存设置为最小值,以便最大化共享内存池。
对于 AMD Ryzen™ AI Halo,默认为 96GB 共享内存。要修改此设置,请打开 AMD Ryzen™ AI Developer Center,然后转到设置(Settings)选项卡。在图形性能设置(Graphics Performance Settings)下,增加共享视频内存(Shared Video Memory)滑块,然后单击应用更改(Apply Changes),并重启以使更改生效。

通过更改内核的转换表管理器(Translation Table Manager,TTM)页面设置来增加共享内存池。AMD 建议在 BIOS 中将最小专用 VRAM 设置为(0.5 GB),以便最大数量可用作共享内存。
-
安装
pipx工具,并将 pipx 安装的 wheel 的路径添加到系统搜索路径中:Terminal window sudo apt install pipxpipx ensurepath -
从 PyPI 安装
amd-debug-toolswheel:Terminal window pipx install amd-debug-tools -
查询当前的共享内存设置:
Terminal window amd-ttm -
增加共享内存分配(单位为 GB):
Terminal window amd-ttm --set <NUM> -
重启后更改才会生效。
检查软件更新
注意:如果未安装 VS Code,你可以通过 Ryzen AI Developer Center 进行安装。
在开始之前,请确保你的 Ryzen AI Halo 已安装最新软件。打开 AMD Ryzen™ AI Developer Center,检查应用本身以及其他软件是否有可用更新。
进入 Updates 选项卡。如果有可用更新,请安装并重启后再继续。

进入 Manage 选项卡。如果有可用更新,请安装并重启后再继续。

安装软件先决条件
AMD GPU 驱动程序
使用 AMD Software: Adrenalin Edition™ 更新到最新的 AMD GPU 驱动程序。
- 从开始菜单或系统托盘打开
AMD Software: Adrenalin Edition。 - 导航到驱动程序和软件,点击管理更新。
- 如果有可用的更新,请按照提示下载并安装。
AMD GPU 驱动程序
使用适用于 Linux 的 Radeon 软件(RSL)流程安装 AMD GPU 驱动程序(amdgpu)。有关适用于你所使用发行版的说明,请参阅安装内核驱动程序。
Lemonade
安装 Lemonade
从 lemonade-server.ai 下载最新安装程序,并运行 .msi 文件。
安装后:
lemonadeCLI 会自动添加到系统 PATH- Lemonade server 预期会自动在后台运行
你也可以通过命令行静默安装:
msiexec /i lemonade-server-minimal.msi /qnUbuntu:
sudo add-apt-repository ppa:lemonade-team/stablesudo apt install lemonade-serverArch Linux (AUR):
yay -S lemonade-server对于其他发行版,或需要从源码安装,请参阅完整安装选项。
验证 Lemonade 安装
打开终端并运行:
lemonade --version你应该会看到类似输出:
lemonade version x.y.z如果能看到版本号,说明 Lemonade 已正确安装并可开始使用。
下面是常用 Lemonade CLI 命令,便于快速参考:
| 命令 | 作用 |
|---|---|
lemonade --help | 显示所有可用命令和参数。 |
lemonade --version | 输出已安装的 Lemonade 版本。 |
lemonade status | 确认 Lemonade server 是否正在运行且可访问。默认兼容 OpenAI 的 API base URL 为 http://localhost:13305/api/v1。 |
lemonade list | 列出当前 Lemonade 设置中可用的模型。 |
lemonade pull <MODEL_NAME> | 下载模型,但不启动模型。 |
lemonade run <MODEL_NAME> | 如有需要先下载模型,然后启动模型进行推理/聊天。 |
lemonade run <MODEL_NAME> --llamacpp rocm | 使用 ROCm 后端启动 llama.cpp 模型。 |
lemonade run <MODEL_NAME> --llamacpp vulkan | 使用 Vulkan 后端启动 llama.cpp 模型。 |
lemonade config | 显示当前 Lemonade 配置值。 |
lemonade config set llamacpp.backend=rocm | 将默认 llama.cpp 后端设置为 ROCm。 |
有关最新 Lemonade server 选项或故障排除,请参阅 Lemonade 官方文档。
GAIA
GAIA 是 AMD 的开源框架,用于构建在搭载 Ryzen AI 加速功能的 AMD 硬件上本地运行的 AI 智能体。
安装 GAIA
- 在 Windows 上,在你选择的目录中打开终端,并按照以下命令创建 venv。
python -m venv gaia-env --system-site-packagesgaia-env\Scripts\activate- 然后,使用
pip安装 Gaia
pip install amd-gaia- 在 Linux 上,在你选择的目录中打开终端,并按照以下命令创建 venv。
sudo apt updatesudo apt install -y python3-venvpython3 -m venv gaia-env --system-site-packagessource gaia-env/bin/activate- 然后,使用
pip安装 Gaia
pip install amd-gaia- 在 Windows 上,在你选择的目录中打开终端,并按照以下命令创建 venv。
python -m venv gaia-envgaia-env\Scripts\activate- 然后,使用
pip安装 Gaia
pip install amd-gaia- 在 Linux 上,在你选择的目录中打开终端,并按照以下命令创建 venv。
sudo apt updatesudo apt install -y python3-venvpython3 -m venv gaia-envsource gaia-env/bin/activate- 然后,使用
pip安装 Gaia
pip install amd-gaia- 初始化 GAIA
安装完成后,运行 gaia init 以设置 Lemonade Server 并下载模型:
gaia init这将安装 Lemonade Server、下载默认模型,并验证设置是否正确。
验证安装
验证是否已安装 GAIA v0.16.2 或更高版本:
gaia --version重要提示:在使用 GAIA 之前,请确保 Lemonade Server 正在运行。GAIA 需要手动启动 Lemonade Server。
有关更多信息,请参阅 GAIA 文档。
开始使用
先运行已完成的智能体,看看你要构建的内容。然后,我们将逐步讲解代码。
运行预构建示例
本教程包含完整的 。将其下载到你选择的目录,并运行它以查看完成后的智能体的运行效果:
python hardware_advisor_agent.py尝试询问: “What size LLM can I run?”
预期输出:
============================================================Hardware Advisor Agent============================================================
Hi! I can help you figure out what size LLM your system can run.
Agent ready!
You: What size LLM can I run?
Agent: Great news! With 32 GB RAM and a 24 GB GPU, you can run:- 30B parameter models (like Qwen3-Coder-30B)- Most 7B-14B models comfortably- NPU acceleration available for smaller models恭喜 —— 你已经构建了一个智能体!
本教程的剩余部分将解释脚本每个部分的工作原理,以便你从头开始理解它。
理解架构
硬件顾问智能体结合了三个组件:
- LemonadeClient SDK —— 系统信息和模型目录 API
- 特定平台检测 —— Windows PowerShell / Linux lspci 用于 GPU 信息
- 内存计算 —— 70% 规则用于安全的模型大小计算
数据按以下顺序流动:用户查询 → 智能体选择一个工具 → 工具调用 LemonadeClient + 操作系统检测 → 智能体将结果综合为一条推荐。
LemonadeClient SDK
LemonadeClient 提供了用于系统检测、NPU/GPU 可用性和模型目录查询的统一 API。
导入并初始化:
from gaia.llm.lemonade_client import LemonadeClient
client = LemonadeClient(keep_alive=True)get_system_info() —— 返回操作系统、CPU、RAM 和设备可用性:
info = client.get_system_info(){ "OS Version": "Windows 11 Pro", "Processor": "AMD Ryzen 9 7950X", "Physical Memory": "32.0 GB", "devices": { "cpu": {"name": "...", "available": True}, "amd_igpu": {"name": "...", "memory": 8192, "available": True}, "amd_npu": {"name": "Ryzen AI NPU", "available": True} }}{ "OS Version": "Ubuntu 24.04 LTS", "Processor": "AMD Ryzen 9 7950X", "Physical Memory": "32.0 GB", "devices": { "cpu": {"name": "...", "available": True}, "amd_igpu": {"name": "...", "memory": 8192, "available": True}, "amd_npu": {"name": "Not detected", "available": False} }}list_models(show_all=True) —— 返回完整的模型目录:
response = client.list_models(show_all=True)
{ "data": [ { "id": "Qwen3-0.6B-GGUF", "name": "Qwen3 0.6B", "downloaded": True, "labels": ["hot", "cpu", "small"] } ]}get_model_info(model_id) —— 返回特定模型的大小估算:
model_info = client.get_model_info("Qwen3-Coder-30B-A3B-Instruct-GGUF")
{ "id": "Qwen3-Coder-30B-A3B-Instruct-GGUF", "name": "Qwen3 Coder 30B", "size_gb": 18.5, "downloaded": False}特定平台 GPU 检测
该智能体使用操作系统原生命令而不是 PyTorch 进行 GPU 检测。这样即使未安装 GPU 驱动程序也能正常工作,可以检测所有 GPU(不仅仅是支持 CUDA 的 GPU),并避免了繁重的库导入。
在 Windows 上,智能体使用 PowerShell 查询 WMI:
ps_command = ( "Get-WmiObject Win32_VideoController | " "Select-Object Name,AdapterRAM | " "ConvertTo-Csv -NoTypeInformation")result = subprocess.run( ["powershell", "-Command", ps_command], capture_output=True, text=True, timeout=5)# Parse CSV output for GPU name and VRAM在 Linux 上,智能体使用 lspci:
result = subprocess.run( ["lspci"], capture_output=True, text=True, timeout=5)# Parse output for "VGA compatible controller" lines# Note: Memory not available via lspci70% 内存规则
规则: 模型大小应小于可用 RAM 的 70%,以便为推理操作(KV 缓存、批处理缓冲区、运行时内存峰值)留出 30% 的开销。
System: 32 GB RAMMax safe model size: 32 x 0.7 = 22.4 GB30B model (~18.5 GB): Fits safely70B model (~42 GB): Too large逐步编写智能体代码(可选)
你将创建一个文件,名为 hardware_advisor_agent.py,并逐步添加功能。每一步都建立在前一步的基础上。
步骤 1:智能体骨架
从一个最小的智能体结构开始——仅包含类和基本的系统提示词。此时智能体还没有工具。
from gaia import Agentfrom gaia.llm.lemonade_client import LemonadeClient
class HardwareAdvisorAgent(Agent): """Agent that advises on LLM capabilities based on your hardware."""
def __init__(self, **kwargs): self.client = LemonadeClient(keep_alive=True) super().__init__(**kwargs)
def _get_system_prompt(self) -> str: return "You are a hardware advisor for running local LLMs on AMD systems."
def _register_tools(self): # Tools will be added in the next steps pass
if __name__ == "__main__": agent = HardwareAdvisorAgent() print("Agent created successfully!")运行它以验证:
python hardware_advisor_agent.py预期输出:
Agent created successfully!步骤 2:GPU 和硬件检测
添加 _get_gpu_info() 辅助方法和 get_hardware_info() 工具。这会使智能体具有交互性——现在你可以查询它关于系统规格的信息。
更新文件顶部的导入:
from typing import Any, Dict
from gaia import Agent, toolfrom gaia.llm.lemonade_client import LemonadeClient在 _get_system_prompt() 方法之后添加 _get_gpu_info() 辅助方法:
def _get_gpu_info(self) -> Dict[str, Any]: """Detect GPU using OS-native commands.""" import platform import subprocess
system = platform.system()
try: if system == "Windows": ps_command = ( "Get-WmiObject Win32_VideoController | " "Select-Object Name,AdapterRAM | " "ConvertTo-Csv -NoTypeInformation" ) result = subprocess.run( ["powershell", "-Command", ps_command], capture_output=True, text=True, timeout=5, ) if result.returncode == 0: lines = [ l.strip() for l in result.stdout.strip().split("\n") if l.strip() ] # Skip virtual/remote adapters that aren't real GPUs skip_keywords = [ "microsoft remote display", "microsoft basic display", "remote desktop", ] # Collect all valid GPUs and pick the one with the most VRAM candidates = [] for line in lines[1:]: # Skip header line = line.replace('"', "") parts = line.split(",") if len(parts) >= 2: try: name = parts[0].strip() adapter_ram = ( int(parts[1]) if parts[1].strip().isdigit() else 0 ) if name and len(name) > 0: if any(k in name.lower() for k in skip_keywords): continue candidates.append({ "name": name, "memory_mb": ( adapter_ram // (1024 * 1024) if adapter_ram > 0 else 0 ), }) except (ValueError, IndexError): continue if candidates: return max(candidates, key=lambda g: g["memory_mb"])
elif system == "Linux": result = subprocess.run( ["lspci"], capture_output=True, text=True, timeout=5 ) if result.returncode == 0: candidates = [] for line in result.stdout.split("\n"): if "VGA compatible controller" in line: parts = line.split(":", 2) if len(parts) >= 3: candidates.append({ "name": parts[2].strip(), "memory_mb": 0, }) if candidates: # Prefer AMD GPUs if present, otherwise return first amd_gpus = [g for g in candidates if "amd" in g["name"].lower() or "radeon" in g["name"].lower()] return amd_gpus[0] if amd_gpus else candidates[0]
except Exception as e: print(f"GPU detection error: {e}")
return {"name": "Not detected", "memory_mb": 0}将 _register_tools() 方法替换为 get_hardware_info 工具:
def _register_tools(self): client = self.client agent = self
@tool(atomic=True) def get_hardware_info() -> Dict[str, Any]: """Get detailed system hardware information including RAM, GPU, and NPU.""" try: info = client.get_system_info()
# Parse RAM (format: "32.0 GB") ram_str = info.get("Physical Memory", "0 GB") ram_gb = float(ram_str.split()[0]) if ram_str else 0
# Detect GPU gpu_info = agent._get_gpu_info() gpu_name = gpu_info.get("name", "Not detected") gpu_available = gpu_name != "Not detected" gpu_memory_mb = gpu_info.get("memory_mb", 0) gpu_memory_gb = ( round(gpu_memory_mb / 1024, 2) if gpu_memory_mb > 0 else 0 )
# Get NPU information from Lemonade devices = info.get("devices", {}) npu_info = devices.get("amd_npu", {}) npu_available = npu_info.get("available", False) npu_name = ( npu_info.get("name", "Not detected") if npu_available else "Not detected" )
return { "success": True, "os": info.get("OS Version", "Unknown"), "processor": info.get("Processor", "Unknown"), "ram_gb": ram_gb, "amd_igpu": { "name": gpu_name, "memory_mb": gpu_memory_mb, "memory_gb": gpu_memory_gb, "available": gpu_available, }, "amd_npu": {"name": npu_name, "available": npu_available}, } except Exception as e: return { "success": False, "error": str(e), "message": "Failed to get hardware information from Lemonade Server", }更新 __main__ 代码块以启用交互式测试:
if __name__ == "__main__": agent = HardwareAdvisorAgent() print("Hardware Advisor Agent (Ctrl+C to exit)") print("Try: 'Show me my system specs'\n")
while True: try: query = input("You: ").strip() if query: agent.process_query(query) print() except KeyboardInterrupt: print("\nGoodbye!") break运行并尝试询问”Show me my system specs”:
python hardware_advisor_agent.py输出示例:
You: Show me my system specs
Agent: Your system has excellent specs for running LLMs locally!- 32 GB RAM- AMD Radeon RX 7900 XTX with 24 GB VRAM- Ryzen AI NPU for accelerated inference步骤 3:模型目录
在 _register_tools() 内部、get_hardware_info 函数之后,添加 list_available_models() 工具。现在智能体可以告诉你有哪些可用的模型。
@tool(atomic=True) def list_available_models() -> Dict[str, Any]: """List all models available in the catalog with their sizes and download status.""" try: response = client.list_models(show_all=True) models_data = response.get("data", [])
enriched_models = [] for model in models_data: model_id = model.get("id", "") model_info = client.get_model_info(model_id) size_gb = model_info.get("size_gb", 0)
enriched_models.append( { "id": model_id, "name": model.get("name", model_id), "size_gb": size_gb, "downloaded": model.get("downloaded", False), "labels": model.get("labels", []), } )
enriched_models.sort(key=lambda m: m["size_gb"], reverse=True)
return { "success": True, "models": enriched_models, "count": len(enriched_models), "message": f"Found {len(enriched_models)} models in catalog", } except Exception as e: return { "success": False, "error": str(e), "message": "Failed to fetch models from Lemonade Server", }运行并尝试询问”What models are available?”:
python hardware_advisor_agent.py输出示例:
You: What models are available?
Agent: I found 15 models in the catalog:- Qwen3-Coder-30B (18.5 GB) [hot, coding] - Not downloaded- Llama-3.1-8B (4.7 GB) [general] - Downloaded- Qwen3-0.6B (0.4 GB) [hot, cpu, small] - Downloaded步骤 4:智能推荐
在 _register_tools() 内部、list_available_models 之后,添加 recommend_models() 工具。智能体现在可以使用 70% 规则计算哪些模型适合你系统的内存。
@tool(atomic=True) def recommend_models(ram_gb: float, gpu_memory_mb: int = 0) -> Dict[str, Any]: """Recommend models based on available system memory.
Args: ram_gb: Available system RAM in GB gpu_memory_mb: Available GPU memory in MB (0 if no GPU)
Returns: Dictionary with model recommendations that fit in available memory """ try: models_result = list_available_models() if not models_result.get("success"): return models_result
all_models = models_result.get("models", [])
# 70% rule: leave 30% overhead for inference max_model_size_gb = ram_gb * 0.7
fitting_models = [ model for model in all_models if model["size_gb"] <= max_model_size_gb and model["size_gb"] > 0 ]
for model in fitting_models: model["estimated_runtime_gb"] = round(model["size_gb"] * 1.3, 2) model["fits_in_ram"] = model["estimated_runtime_gb"] <= ram_gb
if gpu_memory_mb > 0: gpu_memory_gb = gpu_memory_mb / 1024 model["fits_in_gpu"] = model["size_gb"] <= (gpu_memory_gb * 0.9)
fitting_models.sort(key=lambda m: m["size_gb"], reverse=True)
return { "success": True, "recommendations": fitting_models, "total_fitting_models": len(fitting_models), "constraints": { "available_ram_gb": ram_gb, "available_gpu_mb": gpu_memory_mb, "max_model_size_gb": round(max_model_size_gb, 2), "safety_margin_percent": 30, }, } except Exception as e: return { "success": False, "error": str(e), "message": "Failed to generate model recommendations", }运行并尝试询问”What size LLM can I run?”:
python hardware_advisor_agent.py输出示例:
You: What size LLM can I run?
Agent: With 32 GB RAM and 24 GB GPU, you can safely run models up to 22.4 GB!
Top recommendations:1. Qwen3-Coder-30B (18.5 GB) - Fits in RAM and GPU2. Llama-3.1-8B (4.7 GB) - Fits in RAM and GPU步骤 5:生产级 CLI
将简单的 __main__ 代码块替换为一个精致的交互式 CLI。这会添加一个横幅、退出命令和更好的错误处理。
将整个 if __name__ == "__main__": 代码块替换为:
def main(): """Run the Hardware Advisor Agent interactively.""" print("=" * 60) print("Hardware Advisor Agent") print("=" * 60) print("\nHi! I can help you figure out what size LLM your system can run.") print("\nTry asking:") print(" - 'What size LLM can I run?'") print(" - 'Show me my system specs'") print(" - 'What models are available?'") print(" - 'Can I run a 30B model?'") print("\nType 'quit', 'exit', or 'q' to stop.\n")
try: agent = HardwareAdvisorAgent() print("Hardware Advisor Agent (Ctrl+C to exit)") except Exception as e: print(f"Error initializing agent: {e}") print("\nMake sure Lemonade Server is running before using GAIA.") return
while True: try: user_input = input("You: ").strip()
if not user_input: continue
if user_input.lower() in ("quit", "exit", "q"): print("Goodbye!") break
agent.process_query(user_input) print()
except KeyboardInterrupt: print("\nGoodbye!") break except Exception as e: print(f"\nError: {e}\n")
if __name__ == "__main__": main()最终验证
现在,你的 hardware_advisor_agent.py 应包含以下所有组件:
- 导入:
from typing import Any, Dict和from gaia import Agent, tool - 带有
__init__和系统提示词的HardwareAdvisorAgent类 -
_get_gpu_info()辅助函数(Windows PowerShell + Linux lspci) - 包含 GPU、NPU 和 OS 字段的
get_hardware_info()工具 - 带有标签和容量增强的
list_available_models()工具 - 带有 70% 规则、fits_in_ram、fits_in_gpu 的
recommend_models()工具 - 带有交互式 CLI 的
main()函数
测试以下查询以确认一切正常:
- “What size LLM can I run?”
- “Show me my system specs”
- “What models are available?”
- “Can I run a 30B model?”
提示:完整实现可在 中找到。
后续步骤
- 探索 LemonadeClient API — 在 LemonadeClient SDK 文档 中发现更多系统和模型管理功能
- 添加语音交互 — 集成 Whisper ASR 和 Kokoro TTS,让用户可以通过语音询问硬件问题。参见 Talk 指南
- 添加 MCP 支持 — 将硬件顾问暴露为 MCP 服务器,以便其他工具可以查询它。参见 MCP 指南
- 扩展推荐引擎 — 考虑 GPU 显存以进行层卸载,或添加基准测试以估算每秒处理的词元数
- 构建多智能体系统 — 使用 Routing Agent 将硬件顾问与代码智能体或聊天智能体结合起来
需要有关此操作手册的帮助?
遇到问题或有疑问?请创建 GitHub issue,我们的团队会跟进处理。