senel commited on
Commit
6fd8676
·
verified ·
1 Parent(s): aa4e6da

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +8 -3
api.py CHANGED
@@ -92,7 +92,7 @@ async def process_images(image_data_list: List[ImageData]):
92
  df, company_name, invoice_number, invoice_date = extractData(img)
93
 
94
  if df.empty:
95
- table_data = "not detected" # Eğer tablo tespit edilmediyse 'not detected' döndür
96
  else:
97
  table_data = df.to_dict(orient='records')
98
 
@@ -102,11 +102,16 @@ async def process_images(image_data_list: List[ImageData]):
102
  invoice_date=invoice_date,
103
  table_data=table_data
104
  )
105
- results.append(response_data.model_dump()) # Use model_dump instead of dict
 
 
 
 
 
 
106
 
107
  return JSONResponse(content=results)
108
 
109
-
110
  @app.post("/save-invoice")
111
  async def save_invoice(invoice: Invoice, request: Request):
112
  try:
 
92
  df, company_name, invoice_number, invoice_date = extractData(img)
93
 
94
  if df.empty:
95
+ table_data = [] # Ensure table_data is an empty list if "not detected"
96
  else:
97
  table_data = df.to_dict(orient='records')
98
 
 
102
  invoice_date=invoice_date,
103
  table_data=table_data
104
  )
105
+
106
+ try:
107
+ results.append(response_data.model_dump()) # Use model_dump instead of dict
108
+ except ValidationError as e:
109
+ # Log the validation error
110
+ print(f"Validation Error: {e}")
111
+ # Continue with the loop or add default/error information if needed
112
 
113
  return JSONResponse(content=results)
114
 
 
115
  @app.post("/save-invoice")
116
  async def save_invoice(invoice: Invoice, request: Request):
117
  try: