ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

10个核心命令玩转AgentField af CLI:搭建本地AI Agent开发环境完整指南

10个核心命令玩转AgentField af CLI:搭建本地AI Agent开发环境完整指南 10个核心命令玩转AgentField af CLI搭建本地AI Agent开发环境完整指南【免费下载链接】agentfieldBuild, run and scale AI agents like API and microservices项目地址: https://gitcode.com/gh_mirrors/ag/agentfieldAgentField 是一个将 AI Agent 像 API 和微服务一样构建、运行和扩展的开源 AI Agent 平台。它的af命令行工具是搭建本地 AI Agent 开发环境的核心入口一条命令完成环境体检、项目初始化、节点安装、启动、调用与排障。本文将带你用 10 个核心命令快速搭好属于你自己的 AgentField 本地环境 先认识一下 af CLI 的 10 个核心命令AgentField 的 af CLI 入口定义在 control-plane/cmd/af/main.go命令注册逻辑位于 control-plane/internal/cli/root.go。对新手来说掌握下表 10 个命令即可覆盖完整的本地开发链路命令作用一句话记忆af doctor环境体检开工前先看体检报告af init初始化新项目3 步生成 Agent 项目骨架af install安装 Agent 节点包装包 装微服务af run后台启动 Agent 节点一键启动并自动注册af list查看已安装的包看看谁在服役af config配置环境变量给节点喂 API Keyaf call调用 reasoner像 curl 一样调 AI 接口af stop停止节点优雅下线af logs查看运行日志出问题先看它af version查看版本信息确认装对了第1步af doctor —— 先做本地环境体检在动手之前先让 CLI 帮你扫一遍开发环境。af doctor会检测 Python、Node、Docker、各模型服务商 API Key 是否就绪并给出推荐方案af doctor # 人类可读的体检报告 af doctor --json # 机器可读输出方便脚本集成 af doctor --probe # 额外对编码 harness 做一次真实连通探测它的检测逻辑与报告结构定义在 control-plane/internal/cli/doctor.go。如果某项缺失报告里的 Notes 会直接告诉你缺什么、该怎么补。第2步af init —— 交互式创建 Agent 项目af init会以交互向导的方式引导你输入项目名称、选择语言Python / Go / TypeScript、填写作者信息然后生成一个可直接运行的 Agent 项目骨架af init my-agent交互式流程实现于 control-plane/internal/cli/init.go项目模板位于 control-plane/internal/templates/。第3步af install —— 安装 Agent 节点包Agent 在 AgentField 中被称为节点包node package。af install支持三种来源本地目录、Git 仓库地址可带版本与子目录或注册表包名af install ./my-agent # 本地目录 af install git-urlv1.0.0 --path go # Git 仓库中的子目录 af install my-agent-name # 注册表中的包名想先看某个包需要哪些环境变量再决定是否安装用af show-requirements 包路径。命令实现见 control-plane/internal/cli/commands/install.go。第4步af run —— 一键启动你的 AI Agentaf run my-agent # 后台启动自动分配空闲端口并注册到控制面 af run my-agent --port 8005 # 指定端口 af run my-agent --detachfalse # 前台运行便于观察输出af run会启动节点进程、分配端口并在控制面可用时自动完成注册实现见 control-plane/internal/cli/commands/run.go。第5步af list —— 查看已安装节点与运行状态af list # 表格视图名称、版本、状态running/stopped、端口 af list --json # 机器可读输出它是日常开发中最高频的仪表盘状态读取逻辑位于 control-plane/internal/cli/list.go。第6步af config —— 为节点配置环境变量大多数 Agent 节点需要模型服务商的 API Key 等配置。af config让你在安装后、启动前为指定包设置环境变量af config my-agent配置项解析机制位于 control-plane/internal/packages/env_resolver.go完整环境变量清单见 docs/ENVIRONMENT_VARIABLES.md。第7步af call —— 像调 API 一样触发 AI Agent这是整个工作流的高光时刻 ✅。af call按节点.推理器格式调用指定 Agent支持内联 JSON、文件输入、异步执行与字段提取af call my-agent.answer_schema # 先看输入结构 af call my-agent.summarize --in {text: ...} af call my-agent.summarize --in input.yaml --async af call my-agent.report -o json --field .findings[0].score命令实现见 control-plane/internal/cli/call.go接口契约文档在 docs/api/EXECUTE.md。第8~10步af stop / af logs / af version —— 收尾三件套af stop停止指定节点逻辑在 control-plane/internal/cli/stop.goaf logs查看节点日志排障第一选择支持实时 tailcontrol-plane/internal/cli/logs.goaf version确认版本与构建信息control-plane/internal/cli/version.go。快速上手5 分钟走通全流程af doctor # 1. 环境体检 git clone https://gitcode.com/gh_mirrors/ag/agentfield # 2. 获取源码 af init demo-agent # 3. 初始化项目 af install ./demo-agent # 4. 安装节点包 af config demo-agent # 5. 配置 API Key af run demo-agent # 6. 启动 af call demo-agent.hello # 7. 调用 af logs demo-agent # 8. 查看日志 af stop demo-agent # 9. 停止小贴士每个命令都支持--json方便接入脚本命令出错时终端会提示af agent help—— 那是专为编码 Agent 优化的结构化 JSON 命令参考完整架构说明见 docs/ARCHITECTURE.md本地开发指南见 docs/DEVELOPMENT.md三种语言的 SDK 分别位于 sdk/python/、sdk/go/、sdk/typescript/节点示例见 examples/默认配置文件模板在 control-plane/config/agentfield.yaml。掌握这 10 个命令你就已经拥有了一个完整的本地 AI Agent 开发环境。建议先从install → run → call三步走通闭环再逐步探索doctor、logs等排障利器让 Agent 真正像微服务一样在你的机器上跑起来 【免费下载链接】agentfieldBuild, run and scale AI agents like API and microservices项目地址: https://gitcode.com/gh_mirrors/ag/agentfield创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表