From 9e81ab47be9407aeb5c6aad03364cb393eb24a2f Mon Sep 17 00:00:00 2001 From: Leonid Kuligin Date: Thu, 12 Oct 2023 03:43:40 +0200 Subject: [PATCH] Added a better error description if processor name is wrong. (#11488) Replace this entire comment with: - **Description:** added a better error description for this error - **Issue:** #11407 @baskaryan --- .../langchain/document_loaders/parsers/docai.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/langchain/langchain/document_loaders/parsers/docai.py b/libs/langchain/langchain/document_loaders/parsers/docai.py index 8bdfce1176b..32f9d9122c3 100644 --- a/libs/langchain/langchain/document_loaders/parsers/docai.py +++ b/libs/langchain/langchain/document_loaders/parsers/docai.py @@ -64,6 +64,15 @@ class DocAIParser(BaseBlobParser): "a client." ) + if processor_name and not processor_name.isalnum(): + raise ValueError( + f"Processor name {processor_name} has a wrong format. Use only ID from" + "the `Basic information` section on the GCP console. E.g., if your " + "prediction endpoint looks like https://us-documentai.googleapis.com" + "/v1/projects/PROJECT_ID/locations/us/processors/PROCESSOR_ID:process" + ", use only PROCESSOR_ID part." + ) + self._gcs_output_path = gcs_output_path self._processor_name = processor_name if client: