Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -105,8 +105,10 @@ def get_run_step_details(run_steps):
|
|
105 |
|
106 |
show_json("step_details", step_details)
|
107 |
|
108 |
-
|
109 |
-
|
|
|
|
|
110 |
|
111 |
def get_messages(client, thread):
|
112 |
messages = client.beta.threads.messages.list(
|
@@ -116,33 +118,6 @@ def get_messages(client, thread):
|
|
116 |
show_json("messages", messages)
|
117 |
|
118 |
return messages
|
119 |
-
|
120 |
-
#XXXXX
|
121 |
-
def extract_file_ids(step_details):
|
122 |
-
file_ids = []
|
123 |
-
|
124 |
-
print("\n\n")
|
125 |
-
print(step_details)
|
126 |
-
tool_calls = step_details.tool_calls
|
127 |
-
print("\n\n")
|
128 |
-
print(tool_calls)
|
129 |
-
|
130 |
-
for tool_call in tool_calls:
|
131 |
-
print("\n\n")
|
132 |
-
print(tool_calls)
|
133 |
-
code_interpreter = tool_call.code_interpreter
|
134 |
-
print("\n\n")
|
135 |
-
print(code_interpreter)
|
136 |
-
outputs = code_interpreter.outputs
|
137 |
-
|
138 |
-
for output in outputs:
|
139 |
-
if 'image' in output:
|
140 |
-
file_id = output['image'].get('file_id')
|
141 |
-
if file_id:
|
142 |
-
file_ids.append(file_id)
|
143 |
-
print(f"\n\n\n\n\n{file_id}")
|
144 |
-
|
145 |
-
return file_ids
|
146 |
|
147 |
def extract_content_values(data):
|
148 |
content_values = []
|
@@ -172,7 +147,7 @@ def chat(message, history):
|
|
172 |
run = wait_on_run(client, thread, run)
|
173 |
|
174 |
run_steps = get_run_steps(client, thread, run)
|
175 |
-
|
176 |
get_run_step_details(run_steps)
|
177 |
|
178 |
messages = get_messages(client, thread)
|
|
|
105 |
|
106 |
show_json("step_details", step_details)
|
107 |
|
108 |
+
if hasattr(step_details, "tool_calls"):
|
109 |
+
for tool_call in step_details.tool_calls:
|
110 |
+
print("\n\n")
|
111 |
+
show_json("tool_call", tool_call)
|
112 |
|
113 |
def get_messages(client, thread):
|
114 |
messages = client.beta.threads.messages.list(
|
|
|
118 |
show_json("messages", messages)
|
119 |
|
120 |
return messages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
def extract_content_values(data):
|
123 |
content_values = []
|
|
|
147 |
run = wait_on_run(client, thread, run)
|
148 |
|
149 |
run_steps = get_run_steps(client, thread, run)
|
150 |
+
|
151 |
get_run_step_details(run_steps)
|
152 |
|
153 |
messages = get_messages(client, thread)
|