Skip to content

Commit

Permalink
mindeeapi.py aktualisieren
Browse files Browse the repository at this point in the history
Added synchronous parameter
  • Loading branch information
DrRSatzteil authored Jan 6, 2024
1 parent df6732f commit bf4b204
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mayanmindee/mindeeapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ def ocr_standard(pdf_bytes, document_name, document_type):
return parsed_doc


def ocr_custom(pdf_bytes, document_name, account_name, endpoint_name):
def ocr_custom(pdf_bytes, document_name, account_name, endpoint_name, synchronous=False):
client = Client(api_key=os.getenv("MINDEE_API_KEY"))
custom_endpoint = client.create_endpoint(
account_name=account_name,
endpoint_name=endpoint_name,
)
doc = client.source_from_bytes(pdf_bytes, document_name)
parsed_doc = client.enqueue_and_parse(product.CustomV1, input_source=doc, include_words=True, endpoint=custom_endpoint)
if synchronous:
parsed_doc = client.parse(product.CustomV1, input_source=doc, endpoint=custom_endpoint)
else:
parsed_doc = client.enqueue_and_parse(product.CustomV1, input_source=doc, include_words=True, endpoint=custom_endpoint)
return parsed_doc

0 comments on commit bf4b204

Please sign in to comment.