m8chaa commited on
Commit
e9922e5
โ€ข
1 Parent(s): a5cf43f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -126
app.py CHANGED
@@ -198,7 +198,10 @@ async def request_gpt4o_completion(image_id: str, user_credit: int):
198
  #Guideline
199
  -strictly adhere to the given content of OCR text.
200
  -it could be of receipt(s) or business card(s) but not both
201
- -any other info that couldn't be classified is sorted into "๊ธฐํƒ€"
 
 
 
202
 
203
  #Example
204
  ##Receipts
@@ -243,17 +246,17 @@ async def request_gpt4o_completion(image_id: str, user_credit: int):
243
  2502230078357
244
 
245
  Output
246
- -๋ฐœํ–‰์ผ: 2024/02/23 20:10
247
- -์ƒํ˜ธ: ์€์„ฑ๋งˆ์ผ“
248
- -์‚ฌ์—…์ž๋ฒˆํ˜ธ: 727-27-01455
249
- -ํ•ฉ๊ณ„๊ธˆ์•ก: 2,800
250
- -๋‚ด์—ญ:
251
  ๋Šํƒ€๋ฆฌ๋ฒ„์„ฏ 1,000์› 1๊ฐœ
252
  ์–‘๋ฐฐ์ถ” 1,800์› 1๊ฐœ
253
- -์นด๋“œ๋ฒˆํ˜ธ: 4673-09**-****-515*
254
- -์นด๋“œ์ข…๋ฅ˜: KB๊ตญ๋ฏผ์ฒดํฌ
255
- -์Šน์ธ๋ฒˆํ˜ธ: 30014507
256
- -๊ธฐํƒ€: ๋Œ€ํ‘œ์ž: ํ—ˆ์œ ์„ฑ, ์ฃผ์†Œ: ๊ฒฝ๊ธฐ ์‹œํฅ์‹œ ๋ฐฐ๊ณง3๋กœ 96, ์ „ํ™” ๋ฒˆํ˜ธ: 031-431-1544, ๋ฉด์„ธ๋ฌผํ’ˆ: 2,800, ํ•ฉ๊ณ„: 2,800, ์‹ ์šฉ์นด๋“œ์ง€๋ถˆ:2,800, ์ „ํ‘œNo:201036, ์ œ์ถœ VAN: JTNET-๋ฆฌ๋”๊ธฐ, ๊ฑฐ๋ž˜NO:0223007835 ๊ณ„์‚ฐ์›: ๊ด€๋ฆฌ์ž(001)
257
 
258
  ##Business Cards
259
  Input
@@ -270,16 +273,16 @@ async def request_gpt4o_completion(image_id: str, user_credit: int):
270
  www.iprima.com
271
 
272
  Output
273
- -์ด๋ฆ„: ๋ฐ•์žฅ์›
274
- -ํšŒ์‚ฌ๋ช…: ์•„์ดํ”„๋ฆฌ๋งˆ
275
- -์†Œ์† ๋ฐ ์ง์œ„: ํŒ€์žฅ/์ •์ฑ…์‚ฌ์—…ํŒ€ R&D์‚ฌ์—…์‹ค
276
- -์ฃผ์†Œ: ๊ฒฝ๊ธฐ๋„ ํ™”์„ฑ์‹œ ์ •๋‚จ๋ฉด ๋งŒ๋…„๋กœ 98๋ฒˆ๊ธธ 55 (์šฐํŽธ๋ฒˆํ˜ธ) 18523
277
- -์ „ํ™”: (031) 000-0000
278
- -ํœด๋Œ€ํฐ: (031) 000-0000
279
- -ํŒฉ์Šค: 010-0000-0000
280
- -e-mail: iprima@gmail.com
281
- -ํ™ˆํŽ˜์ด์ง€: www.iprima.com
282
- -๊ธฐํƒ€: Over the MIRACLE
283
 
284
  Image content: {extracted_text}
285
  '''
@@ -343,112 +346,6 @@ async def move_file_to_folder(file_id, current_parents, new_parents):
343
  except Exception as e:
344
  logging.error(f"Failed to move file {file_id} to new folders: {e}")
345
 
346
-
347
- # async def update_user_sheet(spreadsheet_id:str, sheet_id:int, sheet_name, data: List[List[str]], is_reset: Optional[bool] = False):
348
- # print(f"Spreadsheet ID: {spreadsheet_id}, Sheet ID: {sheet_id}, sheet name: {sheet_name}, Data: {data}")
349
- # # first identify the area to insert the data
350
- # no_of_rows = len(data)
351
- # no_of_cols = len(data[0])
352
-
353
- # if is_reset:
354
- # # sheet_name = f"{sheet_name} {datetime.now(kst).strftime("%Y-%m-%d %H:%M:%S")}"
355
- # sheet_name = f"{sheet_name} {datetime.now(kst).strftime('%Y-%m-%d %H:%M')}"
356
- # duplicate_requests = [{
357
- # "duplicateSheet": {
358
- # "sourceSheetId": contacts_ss,
359
- # "newSheetName": sheet_name
360
- # }
361
- # }]
362
- # duplicate_response = sheet_service.spreadsheets().batchUpdate(
363
- # spreadsheetId=spreadsheet_id,
364
- # body={
365
- # 'requests': duplicate_requests
366
- # }
367
- # ).execute()
368
- # sheet_id = duplicate_response['replies'][0]['duplicateSheet']['properties']['sheetId']
369
-
370
- # # Insert new rows
371
- # requests = [
372
- # {
373
- # "updateSheetProperties": {
374
- # "properties": {
375
- # "sheetId": sheet_id,
376
- # "hidden": False
377
- # },
378
- # "fields": "hidden"
379
- # }
380
- # },
381
- # {
382
- # "insertDimension": {
383
- # "range": {
384
- # "sheetId": sheet_id,
385
- # "dimension": "ROWS",
386
- # "startIndex": 1,
387
- # "endIndex": no_of_rows + 1
388
- # },
389
- # "inheritFromBefore": False,
390
- # }
391
- # }]
392
-
393
-
394
- # response = sheet_service.spreadsheets().batchUpdate(
395
- # spreadsheetId=spreadsheet_id,
396
- # body={
397
- # 'requests': requests
398
- # }
399
- # ).execute()
400
-
401
- # update_body = {
402
- # 'values': data
403
- # }
404
- # start_column = 'A'
405
- # end_column = chr(ord(start_column) + no_of_cols - 1)
406
- # range_to_update = f'{sheet_name}!{start_column}2:{end_column}{no_of_rows + 1}'
407
-
408
- # result = sheet_service.spreadsheets().values().update(
409
- # spreadsheetId=spreadsheet_id,
410
- # range=range_to_update,
411
- # valueInputOption='USER_ENTERED',
412
- # body=update_body
413
- # ).execute()
414
-
415
- # # Format the cells
416
- # for row_index, row in enumerate(data):
417
- # for col_index, cell_value in enumerate(row):
418
- # if cell_value.startswith('=HYPERLINK'):
419
- # color = {"red": 0, "green": 0, "blue": 1} # Blue for hyperlinks
420
- # else:
421
- # color = {"red": 0, "green": 0, "blue": 0} # Black for other text
422
-
423
- # requests = [
424
- # {
425
- # "repeatCell": {
426
- # "range": {
427
- # "sheetId": sheet_id,
428
- # "startRowIndex": row_index + 1,
429
- # "endRowIndex": row_index + 2,
430
- # "startColumnIndex": col_index,
431
- # "endColumnIndex": col_index + 1
432
- # },
433
- # "cell": {
434
- # "userEnteredFormat": {
435
- # "textFormat": {
436
- # "foregroundColor": color
437
- # }
438
- # }
439
- # },
440
- # "fields": "userEnteredFormat.textFormat.foregroundColor"
441
- # }
442
- # }
443
- # ]
444
-
445
- # response = sheet_service.spreadsheets().batchUpdate(
446
- # spreadsheetId=spreadsheet_id,
447
- # body={
448
- # 'requests': requests
449
- # }
450
- # ).execute()
451
-
452
  async def update_user_sheet(spreadsheet_id:str, sheet_name:str, data: List[List[str]], is_reset: Optional[bool] = False):
453
  print(f"Spreadsheet ID: {spreadsheet_id}, Sheet Name: {sheet_name}, Data: {data}")
454
 
 
198
  #Guideline
199
  -strictly adhere to the given content of OCR text.
200
  -it could be of receipt(s) or business card(s) but not both
201
+ -sort any other info that couldn't be classified as "๊ธฐํƒ€"
202
+ -format the extracted information as a JSON object with two main keys: 'receipts' and 'busi_cards'.
203
+ -ensure the total number of receipts and business cards combined does not exceed 500.
204
+
205
 
206
  #Example
207
  ##Receipts
 
246
  2502230078357
247
 
248
  Output
249
+ ๋ฐœํ–‰์ผ: 2024/02/23 20:10
250
+ ์ƒํ˜ธ: ์€์„ฑ๋งˆ์ผ“
251
+ ์‚ฌ์—…์ž๋ฒˆํ˜ธ: 727-27-01455
252
+ ํ•ฉ๊ณ„๊ธˆ์•ก: 2,800
253
+ ๋‚ด์—ญ:
254
  ๋Šํƒ€๋ฆฌ๋ฒ„์„ฏ 1,000์› 1๊ฐœ
255
  ์–‘๋ฐฐ์ถ” 1,800์› 1๊ฐœ
256
+ ์นด๋“œ๋ฒˆํ˜ธ: 4673-09**-****-515*
257
+ ์นด๋“œ์ข…๋ฅ˜: KB๊ตญ๋ฏผ์ฒดํฌ
258
+ ์Šน์ธ๋ฒˆํ˜ธ: 30014507
259
+ ๊ธฐํƒ€: ๋Œ€ํ‘œ์ž: ํ—ˆ์œ ์„ฑ, ์ฃผ์†Œ: ๊ฒฝ๊ธฐ ์‹œํฅ์‹œ ๋ฐฐ๊ณง3๋กœ 96, ์ „ํ™” ๋ฒˆํ˜ธ: 031-431-1544, ๋ฉด์„ธ๋ฌผํ’ˆ: 2,800, ํ•ฉ๊ณ„: 2,800, ์‹ ์šฉ์นด๋“œ์ง€๋ถˆ:2,800, ์ „ํ‘œNo:201036, ์ œ์ถœ VAN: JTNET-๋ฆฌ๋”๊ธฐ, ๊ฑฐ๋ž˜NO:0223007835 ๊ณ„์‚ฐ์›: ๊ด€๋ฆฌ์ž(001)
260
 
261
  ##Business Cards
262
  Input
 
273
  www.iprima.com
274
 
275
  Output
276
+ ์ด๋ฆ„: ๋ฐ•์žฅ์›
277
+ ํšŒ์‚ฌ๋ช…: ์•„์ดํ”„๋ฆฌ๋งˆ
278
+ ์†Œ์† ๋ฐ ์ง์œ„: ํŒ€์žฅ/์ •์ฑ…์‚ฌ์—…ํŒ€ R&D์‚ฌ์—…์‹ค
279
+ ์ฃผ์†Œ: ๊ฒฝ๊ธฐ๋„ ํ™”์„ฑ์‹œ ์ •๋‚จ๋ฉด ๋งŒ๋…„๋กœ 98๋ฒˆ๊ธธ 55 (์šฐํŽธ๋ฒˆํ˜ธ) 18523
280
+ ์ „ํ™”: (031) 000-0000
281
+ ํœด๋Œ€ํฐ: (031) 000-0000
282
+ ํŒฉ์Šค: 010-0000-0000
283
+ e-mail: iprima@gmail.com
284
+ ํ™ˆํŽ˜์ด์ง€: www.iprima.com
285
+ ๊ธฐํƒ€: Over the MIRACLE
286
 
287
  Image content: {extracted_text}
288
  '''
 
346
  except Exception as e:
347
  logging.error(f"Failed to move file {file_id} to new folders: {e}")
348
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  async def update_user_sheet(spreadsheet_id:str, sheet_name:str, data: List[List[str]], is_reset: Optional[bool] = False):
350
  print(f"Spreadsheet ID: {spreadsheet_id}, Sheet Name: {sheet_name}, Data: {data}")
351