更新时间:2024-08-27 GMT+08:00
分享

调用Agent

功能介绍

调用用户发布的Agent。

URI

POST /v1/routes/open/{id}/execute

表1 路径参数

参数

是否必选

参数类型

描述

id

String

Agent在数据库中保存的UUID。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

Authorization

String

鉴权信息,填写租户管理员已创建的API Key,前缀加Bearer与空格。

表3 请求Body参数

参数

是否必选

参数类型

描述

query

String

输入问题。

memory

Array of memory objects

包含迄今为止历史对话的消息列表。

表4 memory

参数

是否必选

参数类型

描述

role

String

角色,一般为user或assistant。

content

String

内容。

响应参数

状态码: 200

表5 响应Body参数

参数

参数类型

描述

data

Object

不同响应类型的响应体中包含不同的参数,见示例。

状态码: 400

表6 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误描述。

状态码: 500

表7 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误描述。

请求示例

{
  "query" : "查询北京天气",
  "memory" : [ {
    "role" : "user",
    "content" : "你是谁"
  }, {
    "role" : "assistant",
    "content" : "我是盘古大模型"
  }, {
    "role" : "user",
    "content" : "南京天气"
  }, {
    "role" : "assistant",
    "tool_calls" : [ {
      "id" : "efd6ff92-422c-4ba4-b531-ac1991af7c1a",
      "type" : "function",
      "function" : {
        "name" : "查询当前天气 查询当前天气",
        "arguments" : "{\"city\":\"320100\",\"extensions\":\"all\"}"
      }
    } ]
  }, {
    "role" : "tool",
    "tool_call_id" : "efd6ff92-422c-4ba4-b531-ac1991af7c1a",
    "content" : "{\"data\":{\"status\":\"1\",\"count\":\"1\",\"info\":\"OK\",\"infocode\":\"10000\",\"forecasts\":[{\"city\":\"南京市\",\"adcode\":\"320100\",\"province\":\"江苏\",\"reporttime\":\"2024-08-20 16:32:01\",\"casts\":[{\"date\":\"2024-08-20\",\"week\":\"2\",\"dayweather\":\"中雨\",\"nightweather\":\"中雨\",\"daytemp\":\"32\",\"nighttemp\":\"26\",\"daywind\":\"西北\",\"nightwind\":\"西北\",\"daypower\":\"1-3\",\"nightpower\":\"1-3\",\"daytemp_float\":\"32.0\",\"nighttemp_float\":\"26.0\"}]}]}}"
  } ]
}

响应示例

状态码: 200

请求被服务所理解,正常调用。data的type表示响应的类型,包括knowledge知识库,tool工具,workflow工作流,message大模型,hint用于提示接下来使用knowledge,tool或workflow进行响应。下面的示例代表4类返回,所有实际返回类型均为data,示例中的数字仅为区分。第1个返回type为hint,tool_type为workflow,提示接下来要调用儿科问答这个工作流。第2个返回type为workflow,代表调用workflow的返回,返回内容在response下的data下的responseBody中。后续非message的返回同理,先返回hint提示调用类型,再返回真正的响应。最后的message类型是大模型的响应。

{
  "data1" : {
    "request_id" : "0c49061f4bfc48c7acae871ff3612a13",
    "type" : "hint",
    "id" : "b6dbf1a6-f374-4d44-96fb-45726f7fa7f0",
    "name" : "儿科问答",
    "tool_type" : "workflow"
  },
  "data2" : {
    "request_id" : "0c49061f4bfc48c7acae871ff3612a13",
    "type" : "workflow",
    "id" : "b6dbf1a6-f374-4d44-96fb-45726f7fa7f0",
    "name" : "儿科问答",
    "status" : "SUCCESS",
    "request" : {
      "query" : "婴儿肥胖怎么办"
    },
    "response" : {
      "data" : {
        "responseBody" : "{\"result\":\"问题分析:主要控制儿童饮食,合理饮食不喝酒,不吃油炸食物意见和建议:建议孩子们多锻炼一点,每天至少锻炼一到两个小时,而且他们必须坚持锻炼。他们也应该少吃油和脂肪,多吃水果和蔬菜。我认为我们应该在一段时间后恢复正常。就食疗而言,父母必须参与其中,并被要求掌握一些相关知识,如不允许孩子吃得太多或太多,不给予高糖、高脂肪、高热量的饮食。治疗节食中的儿童并让他们挨饿也很困难。因此,在进行饮食控制之前,有必要耐心而详细地告诉儿童肥胖的危害、\"}",
        "responseHeaders" : {
          "Server" : "api-gateway",
          "X-Request-Id" : "6701c75b8f23102a659e63a3cc5a20d6",
          "X-Content-Type-Options" : "nosniff",
          "Connection" : "keep-alive",
          "X-Download-Options" : "noopen",
          "Date" : "Tue, 20 Aug 2024 08:37:27 GMT",
          "Referrer-Policy" : "no-referrer",
          "X-Frame-Options" : "SAMEORIGIN",
          "Strict-Transport-Security" : "max-age=31536000; includeSubdomains;",
          "lubanops-nenv-id" : "28164",
          "Content-Length" : "660",
          "X-XSS-Protection" : "1; mode=block;",
          "Content-Type" : "application/json"
        },
        "statusCode" : 200
      }
    }
  },
  "data3" : {
    "request_id" : "a5b70890778f489e83bfa83c3f83fb4c",
    "type" : "hint",
    "id" : "0333eb58-0914-4842-ad97-b0a42fe22dc9",
    "name" : "航班信息 航班信息",
    "tool_type" : "tool"
  },
  "data4" : {
    "request_id" : "a5b70890778f489e83bfa83c3f83fb4c",
    "type" : "tool",
    "id" : "0333eb58-0914-4842-ad97-b0a42fe22dc9",
    "name" : "航班信息 航班信息",
    "status" : "SUCCESS",
    "request" : {
      "city" : "南京",
      "endcity" : "大理",
      "date" : "2024-08-24"
    },
    "response" : {
      "data" : {
        "status" : 0,
        "msg" : "ok",
        "result" : {
          "city" : "NKG",
          "endcity" : "DLU",
          "date" : "2024-08-24",
          "list" : [ {
            "flightno" : "ZH2010",
            "airline" : "深圳航空",
            "realflightno" : "TV6026",
            "departportcode" : "NKG",
            "departport" : "禄口国际机场",
            "arrivalportcode" : "DLU",
            "arrivalport" : "大理荒草坝机场",
            "departterminal" : "T1",
            "arrivalterminal" : "",
            "departdate" : "2024-08-24",
            "arrivaldate" : "2024-08-24",
            "departtime" : "16:35",
            "arrivaltime" : "19:40",
            "departdateadd" : 0,
            "arrivaldateadd" : 0,
            "craft" : "19N",
            "stopnum" : "0",
            "costtime" : "03:05",
            "punctualrate" : "95",
            "pricelist" : [ ],
            "minprice" : "0",
            "airporttax" : "50",
            "fueltax" : "50",
            "food" : "1,",
            "isasr" : "1,",
            "iseticket" : "1,",
            "iscodeshare" : 1
          } ]
        }
      }
    }
  },
  "data5" : {
    "request_id" : "5d6f77817dc7451d8443f79dd05d0209",
    "type" : "hint",
    "id" : "00e7ebb2-c52d-46ec-b7e9-62c53b1f6f47",
    "name" : "华西医院肠息肉",
    "tool_type" : "knowledge"
  },
  "data6" : {
    "request_id" : "5d6f77817dc7451d8443f79dd05d0209",
    "type" : "hint",
    "id" : "00e7ebb2-c52d-46ec-b7e9-62c53b1f6f47",
    "name" : "华西医院肠息肉",
    "status" : "SUCCESS",
    "request" : {
      "query" : "肠息肉怎么办"
    },
    "response" : "结直肠息肉应该怎么办?\n结直肠息肉是什么\n结肠息肉需不需要切除\n"
  },
  "data7" : {
    "request_id" : "5d6f77817dc7451d8443f79dd05d0209",
    "type" : "message",
    "id" : "202408152054415174033b6a6544a1",
    "content" : "查询",
    "url" : null,
    "raw" : {
      "role" : "assistant",
      "content" : "查询"
    }
  }
}

状态码: 400

缺少请求体。

{
  "error_code" : "AIAE.00001400",
  "error_msg" : "Request body is missing"
}

状态码: 500

服务器内部错误或三方服务器内部错误。

{
  "error_code" : "AIAE.00001500",
  "error_msg" : "Internal Server Error."
}

状态码

状态码

描述

200

请求被服务所理解,正常调用。data的type表示响应的类型,包括knowledge知识库,tool工具,workflow工作流,message大模型,hint用于提示接下来使用knowledge,tool或workflow进行响应。下面的示例代表4类返回,所有实际返回类型均为data,示例中的数字仅为区分。第1个返回type为hint,tool_type为workflow,提示接下来要调用儿科问答这个工作流。第2个返回type为workflow,代表调用workflow的返回,返回内容在response下的data下的responseBody中。后续非message的返回同理,先返回hint提示调用类型,再返回真正的响应。最后的message类型是大模型的响应。

400

缺少请求体。

500

服务器内部错误或三方服务器内部错误。

错误码

请参见错误码

相关文档