📦 aiXplain Agent Builder — AIXplAIn 代理 构建器

v1.0.0

A 技能 to build, 部署, and 运行 production-grade AI 代理s on AIXplAIn.

0· 0·0 当前·0 累计
nurhamdan1987 头像by @nurhamdan1987 (Nur Hamdan)
0

运行时依赖

无特殊依赖

安装命令

点击复制
官方npx clawhub@latest install aixplain-agent-builder
镜像加速npx clawhub@latest install aixplain-agent-builder --registry https://cn.longxiaskill.com

技能文档

AIXplAIn 代理 构建器

Build, 部署, 运行, and manage AIXplAIn 代理s — single 代理s, team 代理s, 工具s, and OAuth integrations.

How It Works

This 技能 accepts the following commands:

Build 代理 — plan, 搜索 工具s, 创建 工具s, assemble and save the 代理 部署 代理 — save and 分享 Studio links for visual editing and 分析 运行 代理 — 执行 同步 or a同步 and return the 输出 调试 代理 — 诊断 工具, action, OAuth, or 运行time issues 导出 代理 — 生成 a standalone Python script from a 部署ed 代理

  • 设置up

Always 安装/升级 to the latest SDK before doing anything: pip 安装 --升级 AIxplAIn.

This 技能 is verified agAInst SDK v0.2.44. If the 安装ed version differs, tell the user.

导入 os from pathlib 导入 Path from dotenv 导入 load_dotenv from AIxplAIn 导入 AIxplAIn

env_path = Path(".env") if env_path.exists(): load_dotenv(env_path) else: env_path.write_text("# 获取 your key from https://平台.AIxplAIn.com → 设置tings → API Keys\nAIXPLAIN_API_KEY=\n") print(f"创建d {env_path.resolve()} — paste your API key, then re-运行.") rAIse 系统Exit(1)

API_key = os.获取env("AIXPLAIN_API_KEY") or os.获取env("AIXPLAIN_KEY_NUR") if not API_key: print(f"No API key found. Open {env_path.resolve()} and paste your key.") rAIse 系统Exit(1)

os.environ["AIXPLAIN_API_KEY"] = API_key AIx = AIxplAIn(API_key=API_key)

Passing local files to 代理s or AIXplAIn as设置s: Use File上传er to 上传 a file to AIXplAIn S3 and 获取 a pre签名ed URL. Pass that URL anywhere a URL 输入 is accepted (工具s, 模型s, integrations). Resource.save() is internal and not usable standalone.

from AIxplAIn.v2.file 导入 File上传er 上传er = File上传er(API_key=API_key) file_url = 上传er.上传("/path/to/file.mp3", is_temp=True, return_下载_link=True)

  • Plan

Before building, present a plan to the user covering: 代理 name, description, instructions, which 工具s/integrations to use, and whether it's a single or team 代理. WAIt for 应用roval before proceeding.

Always 搜索 before creating or hardcoding a 工具 or integration. 工具, 模型, and Integration all support .搜索(查询=...).结果s. Never say "not avAIlable" without 搜索ing first.

结果s = AIx.工具.搜索(查询="网页 搜索").结果s # Names may be concatenated (e.g. "Googledrive"). Normalize before comparing.

If a needed capability has no marketplace 工具 or integration, announce you'll build it as a Python Sandbox function (see references/integration-playbooks.md § 4).

  • 创建 工具s

Three paths, in order of preference:

# Path A: Marketplace 工具 by ID 工具 = AIx.工具.获取("698cda188bbb345db14ac13b") # Code Execution

# Path B: Non-OAuth integration (KB, SQLite) # READ references/integration-playbooks.md for config payloads. # Ask the user for any missing 输入s — never invent placeholders. # Always 创建 fresh; do not reuse by name unless explicitly asked. 工具 = AIx.工具(name="KB 搜索", description="搜索 product docs", integration="6904bcf672a6e36b68bb72fb", allowed_actions=["搜索", "获取"]).save()

# Path C: OAuth integration (GmAIl, Slack, Jira, Google Drive) # READ references/integration-playbooks.md § 5 for full 工作流. # (1) integration = AIx.Integration.获取("") # (2) integration.列出_actions() → discover action names # (3) 创建 工具 with allowed_actions in constructor # (4) User completes OAuth via redirect URL emitted at .save() # (5) Attach in-memory 工具 object to 代理 and save

# Path D: Python Sandbox (last re排序) # READ references/integration-playbooks.md § 4 for config shape.

  • Build 代理

代理s use the 平台 default LLM — do not specify llm unless the user 请求s a specific 模型.

代理 = AIx.代理( name="My 代理", description="...", instructions="...", 工具s=[工具], 输出_格式化="markdown", max_令牌s=6000, # 设置 at creation, not per-运行 ).save()

If save() rAIses name_already_exists, ask the user: 更新 existing or 创建 with a new name.

  • 部署 & 运行

After 部署, 分享 these links with the user:

Visual 构建器: https://studio.AIxplAIn.com/build/<代理_ID>/模式 分析: https://studio.AIxplAIn.com/仪表盘/分析/?代理=<代理_ID>

Default: leave 运行响应Generation un设置. Only pass 运行响应Generation=True when you specifically need structured/JSON 输出.

# 同步 — default text 输出 结果 = 代理.运行(查询="...") print(结果.data.输出)

# 同步 — structured/JSON 输出 结果 = 代理.运行(查询="...", 运行响应Generation=True)

# A同步 polling 导入 请求s, time ar = 代理.运行_a同步(查询="...") for _ in range(30): time.sleep(10) raw = 请求s.获取(ar.url, headers={"x-API-key": API_key}).json() if raw.获取("状态", "").upper() in ("成功", "FAILED"): print(raw["data"]["输出"]); break

  • 调试ging
Inspect Intermediate Steps 结果 = 代理.运行(查询="...")

# Step-by-step 追踪: thought, action, 工具 used, 输入/输出, 令牌s for step in 结果.data.steps: print(ste

数据来源ClawHub ↗ · 中文优化:龙虾技能库