POST
/
agent
/
chat
curl --request POST \
  --url https://geekai.co/api/v1/agent/chat \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "uuid": "29db255d-211c-4fc6-8fbe-af97fa59cafa",
  "question": "要办理XXX怎么做",
  "messages": [
    {
      "text": "你们的产品质保多久?",
      "role": "human"
    },
    {
      "text": "我们的产品标准质保期是一年",
      "role": "ai"
    }
  ],
  "stream": false,
  "sess_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}'
{
  "message_id": "msg_123456789",
  "content": "我们的退换货政策如下:...",
  "reference": [
    {
      "content": "<string>",
      "source": "<string>",
      "confidence": 123
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}

智能体训练完成后(status=done),就可以通过对话接口向它提问了。

响应数据根据是否是流式响应而变化,可以参考下面的请求示例进行判断:

cURL 请求示例

curl --location --request POST 'https://geekai.co/api/v1/agent/chat' \
--header 'Authorization: Bearer {YOUR_GEEKAI_API_KEY}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "uuid": "智能体ID",
    "question": "用户问题",
    "messages": [
        {
            "text": "历史问题1",
            "role": "human"
        },
        {
            "text": "历史回答1",
            "role": "ai"
        }
    ],
    "stream": true
}'

Postman 请求流式响应示例

Postman 请求非流式响应示例

Authorizations

Authorization
string
header
required

JWT认证token

Body

application/json
uuid
string
required

智能体ID

Example:

"29db255d-211c-4fc6-8fbe-af97fa59cafa"

question
string
required

用户问题

Example:

"要办理XXX怎么做"

messages
object[]

历史消息列表

Example:
[
  { "text": "你们的产品质保多久?", "role": "human" },
  { "text": "我们的产品标准质保期是一年", "role": "ai" }
]
stream
boolean
default:false

是否返回流式响应,设置为true返回流式响应

Example:

false

sess_id
string

第三方应用自行实现的会话ID,用于将有关联的多个对话串联起来

Response

200
application/json
成功响应
message_id
string
required

消息唯一标识

Example:

"msg_123456789"

content
string
required

回答内容

Example:

"我们的退换货政策如下:..."

reference
object[]

引用的知识库内容

usage
object

token使用统计