Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -32,7 +32,15 @@ def create_message(client, thread, msg):
|
|
32 |
)
|
33 |
show_json("message", message)
|
34 |
return message
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
def wait_on_run(client, thread, run):
|
37 |
while run.status == "queued" or run.status == "in_progress":
|
38 |
run = client.beta.threads.runs.retrieve(
|
@@ -40,6 +48,7 @@ def wait_on_run(client, thread, run):
|
|
40 |
run_id=run.id,
|
41 |
)
|
42 |
time.sleep(0.25)
|
|
|
43 |
return run
|
44 |
|
45 |
def extract_content_values(data):
|
@@ -61,14 +70,8 @@ def chat(message, history, openai_api_key):
|
|
61 |
|
62 |
message = create_message(_client, _thread, message)
|
63 |
|
64 |
-
run = _client
|
65 |
-
assistant_id=_assistant.id,
|
66 |
-
thread_id=_thread.id,
|
67 |
-
)
|
68 |
-
show_json("run", run)
|
69 |
-
|
70 |
run = wait_on_run(_client, _thread, run)
|
71 |
-
show_json("run", run)
|
72 |
|
73 |
messages = _client.beta.threads.messages.list(
|
74 |
thread_id=_thread.id
|
|
|
32 |
)
|
33 |
show_json("message", message)
|
34 |
return message
|
35 |
+
|
36 |
+
def create_run(client, assistant, thread):
|
37 |
+
run = client.beta.threads.runs.create(
|
38 |
+
assistant_id=assistant.id,
|
39 |
+
thread_id=thread.id,
|
40 |
+
)
|
41 |
+
show_json("run", run)
|
42 |
+
return run
|
43 |
+
|
44 |
def wait_on_run(client, thread, run):
|
45 |
while run.status == "queued" or run.status == "in_progress":
|
46 |
run = client.beta.threads.runs.retrieve(
|
|
|
48 |
run_id=run.id,
|
49 |
)
|
50 |
time.sleep(0.25)
|
51 |
+
show_json("run", run)
|
52 |
return run
|
53 |
|
54 |
def extract_content_values(data):
|
|
|
70 |
|
71 |
message = create_message(_client, _thread, message)
|
72 |
|
73 |
+
run = create_run(_client, _assistant, _thread)
|
|
|
|
|
|
|
|
|
|
|
74 |
run = wait_on_run(_client, _thread, run)
|
|
|
75 |
|
76 |
messages = _client.beta.threads.messages.list(
|
77 |
thread_id=_thread.id
|