Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,9 @@ import os
|
|
13 |
from assistants import (
|
14 |
set_openai_client,
|
15 |
get_assistant,
|
|
|
16 |
get_thread,
|
|
|
17 |
create_assistant,
|
18 |
load_assistant,
|
19 |
create_thread,
|
@@ -37,22 +39,21 @@ def chat(message, history, openai_api_key):
|
|
37 |
# On first run, create assistant and update assistant_id,
|
38 |
# see https://platform.openai.com/playground/assistants.
|
39 |
# On subsequent runs, load assistant.
|
40 |
-
if get_assistant == None:
|
41 |
-
#
|
42 |
-
|
43 |
|
44 |
# TODO: Use Gradio session to support multiple users
|
45 |
if get_thread == None or len(history) == 0:
|
46 |
set_openai_client(openai_api_key)
|
47 |
-
|
48 |
-
thread = create_thread()
|
49 |
|
50 |
-
create_message(
|
51 |
-
run = create_run(
|
52 |
-
run = wait_on_run(
|
53 |
-
run_steps = get_run_steps(
|
54 |
-
recurse_execute_tool_calls(
|
55 |
-
messages = get_messages(
|
56 |
text_values, image_values = extract_content_values(messages)
|
57 |
|
58 |
download_link = ""
|
|
|
13 |
from assistants import (
|
14 |
set_openai_client,
|
15 |
get_assistant,
|
16 |
+
set_assistant,
|
17 |
get_thread,
|
18 |
+
set_thread,
|
19 |
create_assistant,
|
20 |
load_assistant,
|
21 |
create_thread,
|
|
|
39 |
# On first run, create assistant and update assistant_id,
|
40 |
# see https://platform.openai.com/playground/assistants.
|
41 |
# On subsequent runs, load assistant.
|
42 |
+
if get_assistant() == None:
|
43 |
+
#set_assistant(create_assistant())
|
44 |
+
set_assistant(load_assistant())
|
45 |
|
46 |
# TODO: Use Gradio session to support multiple users
|
47 |
if get_thread == None or len(history) == 0:
|
48 |
set_openai_client(openai_api_key)
|
49 |
+
set_thread(create_thread())
|
|
|
50 |
|
51 |
+
create_message(get_thread(), message)
|
52 |
+
run = create_run(get_assistant(), get_thread())
|
53 |
+
run = wait_on_run(get_thread(), run)
|
54 |
+
run_steps = get_run_steps(get_thread(), run)
|
55 |
+
recurse_execute_tool_calls(get_thread(), run, run_steps, 0)
|
56 |
+
messages = get_messages(get_thread())
|
57 |
text_values, image_values = extract_content_values(messages)
|
58 |
|
59 |
download_link = ""
|