Hello @Roberto Araujo Filho , I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.
Issue: Azure Custom Classification Model - How to set "split mode
" with Python
?
Solution:
The public preview version of Document Intelligence client libraries default to REST API version 2023-10-31-preview. Starting with the
2023-10-31-preview
API, analyzing documents with the custom classification model won't split documents by default. You need to explicitly set thesplitMode
property to auto to preserve the behavior from previous releases. The default forsplitMode
isnone
. If your input file contains multiple documents, you need to enable splitting by setting thesplitMode
toauto
. https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/concept-custom-classifier?view=doc-intel-4.0.0
Make sure you are using the latest SDK version and python>=3.8.
python -m pip install azure-ai-documentintelligence
This table shows the relationship between SDK versions and supported API service versions: Here is the sample code: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/samples/sample_classify_document.py
The sample SDK code to set 'split' mode using new SDK V4.0 (1.0.0b1 (preview))
:
# new code
from azure.ai.documentintelligence import DocumentIntelligenceClient
document_analysis_client = DocumentIntelligenceClient(
endpoint=endpoint, credential=AzureKeyCredential(key)
)
with open(each_file, "rb") as f:
poller = document_analysis_client.begin_classify_document(
classifier_id, classify_request=f, split="none", content_type="application/octet-stream"
)
result = poller.result()
If you have any other questions or are still running into more issues, please let me know.
Thank you again for your time and patience throughout this issue.
Regards,
Vasavi
Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.