vinhngba2704 commited on
Commit
e1ca76a
·
1 Parent(s): 1ab2315

Adding function format_date to ensure date is in format dd/mm/yyyy

Browse files
modules/audio_process.py CHANGED
@@ -9,6 +9,7 @@ import re
9
 
10
  # Initialized Modules
11
  from modules.mapping import mapping_employee, mapping_merchant, mapping_product, mapping_unit
 
12
 
13
  load_dotenv()
14
  # Trancribe Model: Whisper
@@ -63,6 +64,12 @@ def parse_audio_text(text, extract_model):
63
  if match:
64
  json_str = match.group(0)
65
  extracted_json = json.loads(json_str)
 
 
 
 
 
 
66
  return list(extracted_json.values()) # List of orders
67
  else:
68
  raise ValueError("No valid JSON found in Gemini output")
 
9
 
10
  # Initialized Modules
11
  from modules.mapping import mapping_employee, mapping_merchant, mapping_product, mapping_unit
12
+ from modules.formatting import format_date
13
 
14
  load_dotenv()
15
  # Trancribe Model: Whisper
 
64
  if match:
65
  json_str = match.group(0)
66
  extracted_json = json.loads(json_str)
67
+
68
+ # Format the date string
69
+ for order in extracted_json.values():
70
+ if "order_date" in order:
71
+ order["order_date"] = format_date(date_str= order["order_date"])
72
+
73
  return list(extracted_json.values()) # List of orders
74
  else:
75
  raise ValueError("No valid JSON found in Gemini output")
modules/image_process.py CHANGED
@@ -9,6 +9,7 @@ import re
9
 
10
  # Initialized Modules
11
  from modules.mapping import mapping_employee, mapping_merchant, mapping_product, mapping_unit
 
12
 
13
  load_dotenv()
14
  # Load the credential for Cloud-Vision-API model
@@ -75,6 +76,12 @@ def parse_image_text(text, extract_model):
75
  if match:
76
  json_str = match.group(0)
77
  extracted_json = json.loads(json_str)
 
 
 
 
 
 
78
  return list(extracted_json.values()) # List of orders
79
  else:
80
  raise ValueError("No valid JSON found in Gemini output")
 
9
 
10
  # Initialized Modules
11
  from modules.mapping import mapping_employee, mapping_merchant, mapping_product, mapping_unit
12
+ from modules.formatting import format_date
13
 
14
  load_dotenv()
15
  # Load the credential for Cloud-Vision-API model
 
76
  if match:
77
  json_str = match.group(0)
78
  extracted_json = json.loads(json_str)
79
+
80
+ # Format the date string
81
+ for order in extracted_json.values():
82
+ if "order_date" in order:
83
+ order["order_date"] = format_date(date_str= order["order_date"])
84
+
85
  return list(extracted_json.values()) # List of orders
86
  else:
87
  raise ValueError("No valid JSON found in Gemini output")