Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -102,7 +102,7 @@ def get_run_steps(client, thread, run):
|
|
102 |
def get_run_step_details(run_steps):
|
103 |
for step in run_steps.data:
|
104 |
step_details = step.step_details
|
105 |
-
|
106 |
|
107 |
show_json("step_details", step_details)
|
108 |
|
@@ -116,15 +116,26 @@ def get_messages(client, thread):
|
|
116 |
return messages
|
117 |
|
118 |
#XXXXX
|
119 |
-
def
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
def extract_content_values(data):
|
130 |
content_values = []
|
|
|
102 |
def get_run_step_details(run_steps):
|
103 |
for step in run_steps.data:
|
104 |
step_details = step.step_details
|
105 |
+
extract_file_ids(step_details) #XXXXX
|
106 |
|
107 |
show_json("step_details", step_details)
|
108 |
|
|
|
116 |
return messages
|
117 |
|
118 |
#XXXXX
|
119 |
+
def extract_file_ids(data: Dict[str, Any]) -> List[str]:
|
120 |
+
file_ids = []
|
121 |
+
steps = data.get('data', [])
|
122 |
+
|
123 |
+
for step in steps:
|
124 |
+
step_details = step.get('step_details', {})
|
125 |
+
tool_calls = step_details.get('tool_calls', [])
|
126 |
+
|
127 |
+
for tool_call in tool_calls:
|
128 |
+
code_interpreter = tool_call.get('code_interpreter', {})
|
129 |
+
outputs = code_interpreter.get('outputs', [])
|
130 |
+
|
131 |
+
for output in outputs:
|
132 |
+
if 'image' in output:
|
133 |
+
file_id = output['image'].get('file_id')
|
134 |
+
if file_id:
|
135 |
+
file_ids.append(file_id)
|
136 |
+
print(f"\n\n\n\n\n{file_id}")
|
137 |
+
|
138 |
+
return file_ids
|
139 |
|
140 |
def extract_content_values(data):
|
141 |
content_values = []
|