cppowboy commited on
Commit
11e7cde
1 Parent(s): 9d824ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -25,17 +25,20 @@ def respond( _question, _chat_bot,_app_cfg):
25
  img.save(buffered, format="JPEG")
26
  img_str = base64.b64encode(buffered.getvalue()).decode('utf-8')
27
  url = os.environ['SERVICE_URL']
28
- _answer = requests.post(url, headers={
29
  "X-Model-Best-Model": "viscpm-chat-balance",
30
  "X-Model-Best-Trace-ID": "test-trace",
31
  }, json={
32
  "image": img_str,
33
  "question": _question,
34
- }).json()
35
- _answer = _answer['data']['response']
 
36
  print(f'question: {_question}, answer: {_answer}')
37
  except Exception as e:
38
  print(traceback.format_exc())
 
 
39
  _answer = "请求失败"
40
  _chat_bot.append((_question, _answer))
41
  _context = _app_cfg['ctx'] + '\n' + _question + '\n' + _answer + '\n'
 
25
  img.save(buffered, format="JPEG")
26
  img_str = base64.b64encode(buffered.getvalue()).decode('utf-8')
27
  url = os.environ['SERVICE_URL']
28
+ resp = requests.post(url, headers={
29
  "X-Model-Best-Model": "viscpm-chat-balance",
30
  "X-Model-Best-Trace-ID": "test-trace",
31
  }, json={
32
  "image": img_str,
33
  "question": _question,
34
+ })
35
+ resp = resp.json()
36
+ _answer = resp['data']['response']
37
  print(f'question: {_question}, answer: {_answer}')
38
  except Exception as e:
39
  print(traceback.format_exc())
40
+ if resp is not None:
41
+ print(resp.content)
42
  _answer = "请求失败"
43
  _chat_bot.append((_question, _answer))
44
  _context = _app_cfg['ctx'] + '\n' + _question + '\n' + _answer + '\n'