bstraehle commited on
Commit
b845de7
1 Parent(s): 6e6e7d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -117,14 +117,16 @@ def get_messages(client, thread):
117
 
118
  #XXXXX
119
  def extract_file_id(data):
120
- for step in data["data"]:
121
- if "step_details" in step and "tool_calls" in step["step_details"]:
122
- for tool_call in step["step_details"]["tool_calls"]:
123
- if "code_interpreter" in tool_call and "outputs" in tool_call["code_interpreter"]:
124
- for output in tool_call["code_interpreter"]["outputs"]:
125
- if "image" in output and "file_id" in output["image"]:
126
- file_id = output["image"]["file_id"]
127
- print(f"#########################################Found file_id: {file_id}")
 
 
128
 
129
  def extract_content_values(data):
130
  content_values = []
 
117
 
118
  #XXXXX
119
  def extract_file_id(data):
120
+ data = json.loads(data)
121
+
122
+ for step in data['data']:
123
+ if hasattr(step['step_details'], 'tool_calls'):
124
+ for tool_call in step['step_details'].tool_calls:
125
+ if hasattr(tool_call, 'code_interpreter') and hasattr(tool_call.code_interpreter, 'outputs'):
126
+ for output in tool_call.code_interpreter.outputs:
127
+ if hasattr(output, 'image') and hasattr(output.image, 'file_id'):
128
+ file_id = output.image.file_id
129
+ print(f"#############################################3Found file_id: {file_id}")
130
 
131
  def extract_content_values(data):
132
  content_values = []