Closed dc-vin closed 2 months ago
To resolve the issue where the "answer" field cannot be updated correctly when calling the API to update segments in Dify version 0.6.9 (self-hosted using Docker), ensure that the API call for updating segments is correctly formatted and that the necessary fields are included in the request. Here is an example of how to update a segment:
curl --location --request PATCH 'https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"content": "Updated content",
"answer": "Updated answer",
"keywords": ["Updated", "Keywords"]
}'
Replace {dataset_id}
, {document_id}
, and {segment_id}
with the actual IDs of your dataset, document, and segment, and {api_key}
with your actual API key. This should correctly update the segment, including the "answer" field.
Additionally, ensure that the user making the request has the necessary permissions (admin, owner, or editor) and that the dataset and document exist. The backend code validates these conditions and updates the segment accordingly.
If the issue persists, it might be related to the validation logic in the backend. According to the SegmentService
class in api/services/dataset_service.py
, the segment_create_args_validate
method checks if the "answer" field is present and not empty when the document's doc_form
is 'qa_model'. Ensure that the "answer" field is correctly populated and not empty in your request payload [1][2][3].
To continue talking to Dosu, mention @dosu.
What is your knowledge base mode? QA or Normal?
What is your knowledge base mode? QA or Normal?
QA model
It should be resolved in v0.7.1
Self Checks
Dify version
0.6.9
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
When calling the API to update segments, the answer field cannot be updated correctly.
✔️ Expected Behavior
No response
❌ Actual Behavior
No response