linjieccc commited on
Commit
05f882f
1 Parent(s): 6542ea8
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -221,6 +221,12 @@ def process_upload(file):
221
  )
222
 
223
 
 
 
 
 
 
 
224
  def process_prompt(prompt, document, lang="ch"):
225
  if not prompt:
226
  prompt = "What is the total actual and/or obligated expenses of ECG Center?"
@@ -231,7 +237,7 @@ def process_prompt(prompt, document, lang="ch"):
231
 
232
  url = f"https://aip.baidubce.com/rpc/2.0/nlp-itec/poc/docprompt?access_token={access_token}"
233
 
234
- r = requests.post(url, json={"doc": document, "prompt": [prompt], "lang": lang})
235
  response = r.json()
236
 
237
  predictions = response['result']
 
221
  )
222
 
223
 
224
+ def img_base64(img_path):
225
+ with open(img_path, "rb") as f:
226
+ base64_str = base64.b64encode(f.read())
227
+ return base64_str
228
+
229
+
230
  def process_prompt(prompt, document, lang="ch"):
231
  if not prompt:
232
  prompt = "What is the total actual and/or obligated expenses of ECG Center?"
 
237
 
238
  url = f"https://aip.baidubce.com/rpc/2.0/nlp-itec/poc/docprompt?access_token={access_token}"
239
 
240
+ r = requests.post(url, json={"doc": img_base64(document), "prompt": [prompt], "lang": lang})
241
  response = r.json()
242
 
243
  predictions = response['result']