Spaces:
Runtime error
Runtime error
Update utils.py
Browse files
utils.py
CHANGED
@@ -472,6 +472,35 @@ def cancel_outputing():
|
|
472 |
return "Stop Done"
|
473 |
|
474 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
#########################################
|
476 |
#Bildbearbeitung
|
477 |
#########################################
|
|
|
472 |
return "Stop Done"
|
473 |
|
474 |
|
475 |
+
########################################
|
476 |
+
#Open Assistant Funktionen für File upload
|
477 |
+
########################################
|
478 |
+
def get_response(thread):
|
479 |
+
return client.beta.threads.messages.list(thread_id=thread.id, order="asc")
|
480 |
+
|
481 |
+
def create_thread_and_run(user_input):
|
482 |
+
thread = client.beta.threads.create()
|
483 |
+
run = submit_message(MATH_ASSISTANT_ID, thread, user_input)
|
484 |
+
return thread, run
|
485 |
+
|
486 |
+
def pretty_print(messages):
|
487 |
+
print("# Messages")
|
488 |
+
for m in messages:
|
489 |
+
print(f"{m.role}: {m.content[0].text.value}")
|
490 |
+
print()
|
491 |
+
|
492 |
+
# Waiting in a loop
|
493 |
+
def wait_on_run(run, thread):
|
494 |
+
while run.status == "queued" or run.status == "in_progress":
|
495 |
+
run = client.beta.threads.runs.retrieve(
|
496 |
+
thread_id=thread.id,
|
497 |
+
run_id=run.id,
|
498 |
+
)
|
499 |
+
time.sleep(0.5)
|
500 |
+
return run
|
501 |
+
|
502 |
+
|
503 |
+
|
504 |
#########################################
|
505 |
#Bildbearbeitung
|
506 |
#########################################
|