From 0181aed5685dc79d99a86f0e6b1a5f528c389d38 Mon Sep 17 00:00:00 2001 From: ebc5802 Date: Wed, 1 May 2024 12:08:07 -0400 Subject: [PATCH] added item uuid --- machine-learning-client/main.py | 3 ++- machine-learning-client/requirements.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/machine-learning-client/main.py b/machine-learning-client/main.py index d88147b..a8c50d8 100644 --- a/machine-learning-client/main.py +++ b/machine-learning-client/main.py @@ -7,6 +7,7 @@ from dotenv import load_dotenv from bson import ObjectId from mindee import Client, PredictResponse, product # To access mindee OCR API +import uuid import logging @@ -82,7 +83,7 @@ def pretdict_endpoint(): receipt_data = { 'receipt_name': receipt['supplier_name']['raw_value'], 'currency': receipt['locale']['currency'], - 'items': [{'description': item['description'], 'amount': item['total_amount'], 'quantity': item['quantity']} for item in receipt['line_items']], + 'items': [{'description': item['description'], 'amount': item['amount'], '_id': str(uuid.uuid4())} for item in receipt['items']],# generate a unique ID for each item 'total': receipt['total_amount']['value'], 'tax': receipt['total_tax']['value'], 'tip': receipt['tip']['value'], diff --git a/machine-learning-client/requirements.txt b/machine-learning-client/requirements.txt index c116578..a36a3e9 100644 --- a/machine-learning-client/requirements.txt +++ b/machine-learning-client/requirements.txt @@ -4,4 +4,5 @@ black requests Flask python-dotenv -mindee \ No newline at end of file +mindee +uuid \ No newline at end of file