AI智能体
向智能体提问
与指定智能体进行对话交互,支持上下文对话和流式响应。
POST
/
agent
/
chat
Copy
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"
}'
Copy
{
"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 请求示例
Copy
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
JWT认证token
Body
application/json
Response
200
application/json
成功响应
The response is of type object
.
Copy
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"
}'
Copy
{
"message_id": "msg_123456789",
"content": "我们的退换货政策如下:...",
"reference": [
{
"content": "<string>",
"source": "<string>",
"confidence": 123
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}
助手
Responses are generated using AI and may contain mistakes.