Update Q&A Knowledge Document
Update Q&A Knowledge Document
This interface allows you to update an existing Q&A knowledge document in an Agent's knowledge base. It supports two update methods: replacing Q&A text content and updating the Q&A file.
Request Method
PUT
Request URL
https://api.gptbots.ai/v1/bot/doc/qa/update
Authentication
For details, please refer to the authentication instructions in API Overview.
Request
Request Examples
Update via Q&A Text:
curl -X PUT https://api.gptbots.ai/v1/bot/doc/qa/update \
-H 'Authorization: Bearer your_apikey' \
-H 'Content-Type: application/json' \
-d '{
"doc_id": "680d1a2b3c4d5e6f7a8b9c0d",
"knowledge_base_id": "673af861ed69656ac0895b07",
"qaList": [
{
"question": "How to register an account?",
"answer": "Visit the official website, click the register button in the top right corner, fill in your email, set a password, and complete the email verification."
},
{
"question": "How to reset the password?",
"answer": "Click the forgot password link on the login page, enter your registered email, and follow the instructions in the email to reset it."
}
]
}'
curl -X PUT https://api.gptbots.ai/v1/bot/doc/qa/update \
-H 'Authorization: Bearer your_apikey' \
-H 'Content-Type: application/json' \
-d '{
"doc_id": "680d1a2b3c4d5e6f7a8b9c0d",
"knowledge_base_id": "673af861ed69656ac0895b07",
"qaList": [
{
"question": "How to register an account?",
"answer": "Visit the official website, click the register button in the top right corner, fill in your email, set a password, and complete the email verification."
},
{
"question": "How to reset the password?",
"answer": "Click the forgot password link on the login page, enter your registered email, and follow the instructions in the email to reset it."
}
]
}'
Ce bloc de code dans la fenêtre flottante
Update via Q&A File:
curl -X PUT https://api.gptbots.ai/v1/bot/doc/qa/update \
-H 'Authorization: Bearer your_apikey' \
-H 'Content-Type: application/json' \
-d '{
"knowledge_base_id": "673af861ed69656ac0895b07",
"files": [
{
"doc_id": "680d1a2b3c4d5e6f7a8b9c0d",
"source_url": "https://example.com/qa_updated.csv",
"file_name": "qa_data_v2.csv"
}
]
}'
curl -X PUT https://api.gptbots.ai/v1/bot/doc/qa/update \
-H 'Authorization: Bearer your_apikey' \
-H 'Content-Type: application/json' \
-d '{
"knowledge_base_id": "673af861ed69656ac0895b07",
"files": [
{
"doc_id": "680d1a2b3c4d5e6f7a8b9c0d",
"source_url": "https://example.com/qa_updated.csv",
"file_name": "qa_data_v2.csv"
}
]
}'
Ce bloc de code dans la fenêtre flottante
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 | Conditional | Document ID, required when updating via qaList. |
| knowledge_base_id | string | No | Knowledge base ID. |
| qaList | list | Conditional | A list of Q&A pairs. Providing this will completely replace all Q&A pairs in the document. Choose either qaList or files. |
| question | string | Yes | The content of the question. |
| answer | string | Yes | The content of the answer. |
| files | list | Conditional | A list of files, up to 20. Choose either qaList or files. |
| doc_id | string | No | Document ID. |
| source_url | string | Yes | The source URL of the file. |
| file_name | string | Yes | The name of the file. |
| file_url | string | No | The URL of the file. |
| file_base64 | string | No | The base64 encoded content of the file. |
| header_row | int | No | The header row number. |
| chunk_token | int | No | The number of tokens per chunk, default is 600. |
| splitter | string | No | The separator. |
When updating with
qaList, all existing Q&A pairs in the target document will be completely replaced. Please ensure you provide the complete list of Q&A pairs.
You must provide eitherqaListorfiles; they cannot both be empty.
Response
Response Example
{
"doc": [
{
"doc_id": "680d1a2b3c4d5e6f7a8b9c0d",
"doc_name": "Frequently Asked Questions"
}
],
"failed": []
}
{
"doc": [
{
"doc_id": "680d1a2b3c4d5e6f7a8b9c0d",
"doc_name": "Frequently Asked Questions"
}
],
"failed": []
}
Ce bloc de code dans la fenêtre flottante
Success Response
| Field | Type | Description |
|---|---|---|
| doc | list | A list of successfully updated documents. |
| doc_id | string | Document ID. |
| doc_name | string | Document name. |
| failed | list | A list of file names that failed to update. |
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 |
