vkumartr commited on
Commit
3fb0bac
·
verified ·
1 Parent(s): ccdb2dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -114,6 +114,7 @@ def extract_invoice_data(file_data, content_type, json_schema):
114
  img.save(img_byte_arr, format="PNG", dpi=(300, 300))
115
  base64_encoded = base64.b64encode(img_byte_arr.getvalue()).decode('utf-8')
116
  base64_images.append(f"data:{content_type.lower()};base64,{base64_encoded}")
 
117
 
118
  except Exception as e:
119
  logger.error(f"Error converting PDF to image: {e}")
@@ -123,7 +124,7 @@ def extract_invoice_data(file_data, content_type, json_schema):
123
  # Handle direct image files
124
  base64_encoded = base64.b64encode(file_data).decode('utf-8')
125
  base64_images.append(f"data:{content_type.lower()};base64,{base64_encoded}")
126
- base64dataresp = f"data:{content_type.lower()};base64,{base64_encoded}"
127
 
128
  # Prepare OpenAI request
129
  openai_content = [{"type": "image_url", "image_url": {"url": img_base64}} for img_base64 in base64_images]
 
114
  img.save(img_byte_arr, format="PNG", dpi=(300, 300))
115
  base64_encoded = base64.b64encode(img_byte_arr.getvalue()).decode('utf-8')
116
  base64_images.append(f"data:{content_type.lower()};base64,{base64_encoded}")
117
+ base64dataresp = f"data:{content_type.lower()};base64,{base64_encoded}"
118
 
119
  except Exception as e:
120
  logger.error(f"Error converting PDF to image: {e}")
 
124
  # Handle direct image files
125
  base64_encoded = base64.b64encode(file_data).decode('utf-8')
126
  base64_images.append(f"data:{content_type.lower()};base64,{base64_encoded}")
127
+ base64dataresp = f"data:{content_type.lower()};base64,{base64_encoded}"
128
 
129
  # Prepare OpenAI request
130
  openai_content = [{"type": "image_url", "image_url": {"url": img_base64}} for img_base64 in base64_images]