Elasticsearch:如何在 workflow 里调用一个 agent

在 AI Agent Builder 里,我们可以创建一个 workflow 的工具从而达到调用 workflow 的目的。我们是不是也可以在 workflow 里调用 AI Agent Builder 里所创建的 Agent 呢?答案是肯定的。下面我们来用一个简单的例子来进行展示。

创建一个 agent

我们创建的一个 agent 的名字叫做 generate_audio_product_json。它是用来解析我们的输入,并提区我们所需要的信息。它的创建非常融, 我们甚至不需要使用任何的工具。

Custom Instructions

复制代码
  Extract audio product information from this description.
        Return raw JSON only. Do NOT use markdown, backticks, or code blocks.
         Extract audio product information from this description.
        Return raw JSON only. Do NOT use markdown, backticks, or code blocks.

        Fields:
        - category (string, one of: Headphones/Earbuds/Speakers/Microphones/Accessories)
        - features (array of strings from: wireless, noise_cancellation, long_battery, waterproof, voice_assistant, fast_charging, portable, surround_sound)
        - use_case (string, one of: Travel/Office/Home/Fitness/Gaming/Studio)

我使用一个简单的例子来进行展示:

复制代码
Premium wireless Bluetooth headphones with active noise cancellation, 30-hour battery life, and premium leather ear cushions. Perfect for travel and office use.

创建一个 workflow 并调用 agent

我们在 workflow 里创建一个如下的 workflow:

复制代码
version: "1"
name: invoke_audio_product_agent
description: Extract structured product data using an AI agent
enabled: true

triggers:
  - type: manual

inputs:
  - name: product_info
    type: string
    required: true
    description: product descriptions

steps:
  # Step 1: Log input (optional but recommended)
  - name: log_input
    type: console
    with:
      message: "Incoming product info: {{ inputs.product_info }}"

  # Step 2: Invoke your agent
  - name: generate_product_json
    type: ai.agent
    with:
      agent_id: "generate_audio_product_json"
      message: |
        Extract structured product data from the following input.

        Input:
        {{ inputs.product_info }}

        Return ONLY valid JSON.

  # Step 3: Print the result
  - name: print_result
    type: console
    with:
      message: "{{ steps.generate_product_json.output }}"
复制代码
Premium wireless Bluetooth headphones with active noise cancellation, 30-hour battery life, and premium leather ear cushions. Perfect for travel and office use.

格式化输出

我们也可以在 agent 调用的时候加入数据输出的格式:

复制代码
version: "1"
name: invoke_agent_example2
description: Shows a way to invoke an agent and return JSON safely
enabled: true

triggers:
  - type: manual

inputs:
  - name: query
    type: string
    default: What is the cheapest air ticket price from China to US and what are the cities?
    required: true
    description: Query a flight index

steps:
  - name: query_flight
    type: ai.agent
    with:
      agent_id: "find_the_cheapest_ticket_from_cn_us"
      message: |
        Query the flight info for this request:
        {{ inputs.query }}

        Return the result **as JSON only**, using this structure.
        Use real values if known, otherwise use null:

        {
          "price": <number or null>,
          "departure_city": "<string or null>",
          "arrival_city": "<string or null>"
        }

  - name: log_result
    type: console
    with:
      message: "Flight info JSON: {{ steps.query_flight.output }}"

如上所示,我们要求的格式是 JSON 输出:

复制代码
What is the cheapest air ticket price from China to US and what are the cities?

祝大家学习愉快!

相关推荐
其实防守也摸鱼几秒前
如何使用自动化教育SRC漏洞挖掘系统--AutoHunter
运维·网络·人工智能·学习·安全·web安全·自动化
微石科技1 分钟前
体征监测设备厂家怎么选?宁波市微石科技:专业级硬件,全品类可定制
大数据·人工智能·科技
泡干脆面就番茄3 分钟前
机器学习:TF-IDF
人工智能·机器学习·tf-idf
iori97king4 分钟前
织信开发日志 18:从 informat-skills 看织信如何把平台能力交给 AI Agent
人工智能·低代码·织信
daxiang_ipo4 分钟前
AI应用,正式步入质变跃迁期
人工智能·搜索引擎·百度
前沿在线5 分钟前
2026世界机器人大会主论坛大咖观点(一)
人工智能·ai·大模型
智搜广告6 分钟前
AI回答优化公司智搜广告让品牌成为推荐首选
大数据·人工智能·python·elasticsearch·geo
Three_ST6 分钟前
沐神-动手学习深度学习-习题 4.3. 多层感知机的简洁实现
人工智能·pytorch·python·深度学习·机器学习
必须会一定会7 分钟前
Agent Handoff M5 发布验收:`CHANGES.md`、`npm pack`、`release:check` 与干净环境安装验证
前端·人工智能·npm·node.js·ai编程
Allen_LVyingbo9 分钟前
面向电子病历的批量语义分析自动化工具:从设计到实战(上)
运维·人工智能·机器学习·语言模型·自然语言处理·自动化·健康医疗