fxmeng commited on
Commit
d25ad55
1 Parent(s): be1b457

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -36,7 +36,8 @@ def GenerateImageByCode(client, message, code_prompt):
36
  code = data['step_details']['tool_calls'][0]['code_interpreter']['input']
37
  if 'image' in data['step_details']['tool_calls'][0]['code_interpreter']['outputs'][0].keys():
38
  image_id = data['step_details']['tool_calls'][0]['code_interpreter']['outputs'][0]['image']['file_id']
39
- image_bytes = client.files.with_raw_response.content(image_id).content
 
40
  with open(f'{image_id}.png', 'wb') as f:
41
  f.write(image_bytes)
42
  base64_image = base64.b64encode(image_bytes).decode('utf-8')
 
36
  code = data['step_details']['tool_calls'][0]['code_interpreter']['input']
37
  if 'image' in data['step_details']['tool_calls'][0]['code_interpreter']['outputs'][0].keys():
38
  image_id = data['step_details']['tool_calls'][0]['code_interpreter']['outputs'][0]['image']['file_id']
39
+ assert image_id
40
+ image_bytes = client.files.with_raw_response.content(image_id).content
41
  with open(f'{image_id}.png', 'wb') as f:
42
  f.write(image_bytes)
43
  base64_image = base64.b64encode(image_bytes).decode('utf-8')