Solicitar revisão humana de um documento
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Envia uma solicitação de revisão humana ad hoc de um documento processado.
Mais informações
Para ver a documentação detalhada que inclui este exemplo de código, consulte:
Exemplo de código
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis code sample demonstrates how to send a request for human review of a document that has been processed by Document AI.\u003c/p\u003e\n"],["\u003cp\u003eThe code utilizes the Document AI Python API to interact with the service, requiring the setup of Application Default Credentials for authentication.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves creating a Document AI client, processing a document, then creating a request for review, which includes the human review config.\u003c/p\u003e\n"],["\u003cp\u003eThe human review request can be prioritized and sent with an inline document to the Document AI service, with the status of the request being accessible through the returned operation name.\u003c/p\u003e\n"]]],[],null,["# Request Human Review of a document\n\nSends a request for ad-hoc human review of a processed document.\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Request Human Review of a Document](/document-ai/docs/hitl/request-review)\n\nCode sample\n-----------\n\n### Python\n\n\nFor more information, see the\n[Document AI Python API\nreference documentation](/python/docs/reference/documentai/latest).\n\n\nTo authenticate to Document AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n from google.api_core.client_options import ClientOptions\n from google.cloud import documentai # type: ignore\n\n # TODO(developer): Uncomment these variables before running the sample.\n # project_id = 'YOUR_PROJECT_ID'\n # location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'\n # processor_id = 'YOUR_PROCESSOR_ID' # Create processor before running sample\n # file_path = '/path/to/local/pdf'\n # mime_type = 'application/pdf' # https://cloud.google.com/document-ai/docs/file-types\n\n\n def review_document_sample(\n project_id: str, location: str, processor_id: str, file_path: str, mime_type: str\n ) -\u003e None:\n # You must set the api_endpoint if you use a location other than 'us'.\n opts = ClientOptions(api_endpoint=f\"{location}-documentai.googleapis.com\")\n\n # Create a client\n client = documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html(client_options=opts)\n\n # Make Processing Request\n inline_document = process_document(\n project_id, location, processor_id, file_path, mime_type\n )\n\n # Get the full resource name of the human review config, e.g.:\n # projects/project_id/locations/location/processor/processor_id/humanReviewConfig\n human_review_config = client.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html#google_cloud_documentai_v1_services_document_processor_service_DocumentProcessorServiceClient_human_review_config_path(\n project_id, location, processor_id\n )\n\n # Options are DEFAULT, URGENT\n priority = documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.types.ReviewDocumentRequest.html.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.types.ReviewDocumentRequest.Priority.html.DEFAULT\n\n # Configure the human review request\n request = documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.types.ReviewDocumentRequest.html(\n inline_document=inline_document,\n human_review_config=human_review_config,\n enable_schema_validation=False,\n priority=priority,\n )\n\n # Make a request for human review of the processed document\n operation = client.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html#google_cloud_documentai_v1_services_document_processor_service_DocumentProcessorServiceClient_review_document(request=request)\n\n # Print operation name, can be used to check status of the request\n print(operation.operation.name)\n\n\n def process_document(\n project_id: str, location: str, processor_id: str, file_path: str, mime_type: str\n ) -\u003e documentai.Document:\n # You must set the api_endpoint if you use a location other than 'us'.\n opts = ClientOptions(api_endpoint=f\"{location}-documentai.googleapis.com\")\n\n client = documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html(client_options=opts)\n\n # The full resource name of the processor, e.g.:\n # projects/project_id/locations/location/processor/processor_id\n name = client.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html#google_cloud_documentai_v1_services_document_processor_service_DocumentProcessorServiceClient_processor_path(project_id, location, processor_id)\n\n # Read the file into memory\n with open(file_path, \"rb\") as image:\n image_content = image.read()\n\n # Load Binary Data into Document AI RawDocument Object\n raw_document = documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.types.RawDocument.html(content=image_content, mime_type=mime_type)\n\n # Configure the process request\n request = documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.types.ProcessRequest.html(name=name, raw_document=raw_document)\n\n result = client.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html#google_cloud_documentai_v1_services_document_processor_service_DocumentProcessorServiceClient_process_document(request=request)\n\n return result.https://cloud.google.com/python/docs/reference/documentai-toolbox/latest/google.cloud.documentai_toolbox.wrappers.document.html\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=documentai)."]]