Add Q&A Chunks
Add Q&A Chunks
This interface allows you to append Q&A chunks (knowledge blocks) to an existing Q&A knowledge document. It supports batch additions, and each chunk can have custom keywords.
Request Method
POST
Request URL
https://api.gptbots.ai/v1/bot/doc/qa/chunks/add
Authentication
For details, please refer to the authentication instructions in API Overview.
Request
Request Example
curl -X POST https://api.gptbots.ai/v1/bot/doc/qa/chunks/add \
-H 'Authorization: Bearer your_apikey' \
-H 'Content-Type: application/json' \
-d '{
"doc_id": "680d1a2b3c4d5e6f7a8b9c0d",
"chunks": [
{
"question": "How to contact customer service?",
"answer": "You can contact us via the online customer service button at the bottom right of the official website. Our working hours are Monday to Friday, 9:00-18:00.",
"keywords": ["customer service", "contact info", "online support"]
},
{
"question": "What is the refund process?",
"answer": "After logging into your account, go to the order management page, select the order you want to refund, click on apply for a refund, and fill in the reason.",
"keywords": ["refund", "return", "order"]
}
]
}'
curl -X POST https://api.gptbots.ai/v1/bot/doc/qa/chunks/add \
-H 'Authorization: Bearer your_apikey' \
-H 'Content-Type: application/json' \
-d '{
"doc_id": "680d1a2b3c4d5e6f7a8b9c0d",
"chunks": [
{
"question": "How to contact customer service?",
"answer": "You can contact us via the online customer service button at the bottom right of the official website. Our working hours are Monday to Friday, 9:00-18:00.",
"keywords": ["customer service", "contact info", "online support"]
},
{
"question": "What is the refund process?",
"answer": "After logging into your account, go to the order management page, select the order you want to refund, click on apply for a refund, and fill in the reason.",
"keywords": ["refund", "return", "order"]
}
]
}'
Este bloque de código en una ventana flotante
Request Headers
| Field | Type | Description |
|---|---|---|
| Authorization | Bearer ${token} | Use Authorization: Bearer ${token} for authentication. Obtain your key from the API Key page to use as the token. |
| Content-Type | application/json | Data type, must be application/json. |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| doc_id | string | Yes | The ID of the target Q&A knowledge document. The document type must be qa or qafile. |
| chunks | list | Yes | A list of Q&A chunks, cannot be empty. |
| question | string | Yes | The content of the question. |
| answer | string | Yes | The content of the answer. |
| keywords | list | No | A list of keywords, up to 50 per chunk. |
The
chunkslist cannot be empty.questionandanswerfor each chunk are required.
Each chunk supports a maximum of 50keywords. Exceeding this limit will result in an error.
Response
Response Example
{
"code": 0,
"message": "OK"
}
{
"code": 0,
"message": "OK"
}
Este bloque de código en una ventana flotante
Success Response
| Field | Type | Description |
|---|---|---|
| code | int | Status code, 0 indicates success. |
| message | string | Status message. |
Failure Response
| Field | Type | Description |
|---|---|---|
| code | int | Error code. |
| message | string | Error description message. |
Error Codes
| Code | Message |
|---|---|
| 40000 | Parameter error |
| 50000 | Internal system error |
