Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,10 @@ def create_assistant(client):
|
|
| 25 |
show_json("assistant", assistant)
|
| 26 |
|
| 27 |
return assistant
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
| 29 |
def create_thread(client):
|
| 30 |
thread = client.beta.threads.create()
|
| 31 |
|
|
@@ -67,20 +70,24 @@ def wait_on_run(client, thread, run):
|
|
| 67 |
|
| 68 |
return run
|
| 69 |
|
| 70 |
-
def
|
| 71 |
run_steps = client.beta.threads.runs.steps.list(
|
| 72 |
thread_id=thread.id,
|
| 73 |
run_id=run.id,
|
| 74 |
order="asc",
|
| 75 |
)
|
|
|
|
|
|
|
| 76 |
|
|
|
|
|
|
|
|
|
|
| 77 |
for step in run_steps.data:
|
| 78 |
step_details = step.step_details
|
|
|
|
| 79 |
show_json("step_details", step_details)
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
def list_messages(client, thread):
|
| 84 |
messages = client.beta.threads.messages.list(
|
| 85 |
thread_id=thread.id
|
| 86 |
)
|
|
@@ -113,9 +120,11 @@ def chat(message, history):
|
|
| 113 |
run = create_run(client, assistant, thread)
|
| 114 |
run = wait_on_run(client, thread, run)
|
| 115 |
|
| 116 |
-
|
|
|
|
|
|
|
| 117 |
|
| 118 |
-
messages =
|
| 119 |
|
| 120 |
content_values = extract_content_values(messages)
|
| 121 |
|
|
|
|
| 25 |
show_json("assistant", assistant)
|
| 26 |
|
| 27 |
return assistant
|
| 28 |
+
|
| 29 |
+
def load_assistant():
|
| 30 |
+
return "TODO"
|
| 31 |
+
|
| 32 |
def create_thread(client):
|
| 33 |
thread = client.beta.threads.create()
|
| 34 |
|
|
|
|
| 70 |
|
| 71 |
return run
|
| 72 |
|
| 73 |
+
def get_run_steps(client, thread, run):
|
| 74 |
run_steps = client.beta.threads.runs.steps.list(
|
| 75 |
thread_id=thread.id,
|
| 76 |
run_id=run.id,
|
| 77 |
order="asc",
|
| 78 |
)
|
| 79 |
+
|
| 80 |
+
show_json("run_steps", run_steps)
|
| 81 |
|
| 82 |
+
return run_steps
|
| 83 |
+
|
| 84 |
+
def get_run_step_details(run_steps):
|
| 85 |
for step in run_steps.data:
|
| 86 |
step_details = step.step_details
|
| 87 |
+
|
| 88 |
show_json("step_details", step_details)
|
| 89 |
+
|
| 90 |
+
def get_messages(client, thread):
|
|
|
|
|
|
|
| 91 |
messages = client.beta.threads.messages.list(
|
| 92 |
thread_id=thread.id
|
| 93 |
)
|
|
|
|
| 120 |
run = create_run(client, assistant, thread)
|
| 121 |
run = wait_on_run(client, thread, run)
|
| 122 |
|
| 123 |
+
run_steps = get_run_steps(client, thread, run)
|
| 124 |
+
|
| 125 |
+
get_step_details(run_steps)
|
| 126 |
|
| 127 |
+
messages = get_messages(client, thread)
|
| 128 |
|
| 129 |
content_values = extract_content_values(messages)
|
| 130 |
|