Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,10 +10,9 @@ import gradio as gr
|
|
10 |
|
11 |
import os
|
12 |
|
13 |
-
from openai import OpenAI
|
14 |
-
|
15 |
from assistants import (
|
16 |
-
|
|
|
17 |
assistant,
|
18 |
thread,
|
19 |
create_assistant,
|
@@ -36,14 +35,10 @@ def chat(message, history, openai_api_key):
|
|
36 |
|
37 |
#raise gr.Error("Please clone and bring your own credentials.")
|
38 |
|
39 |
-
global
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
if openai_client == None:
|
44 |
-
openai_client = OpenAI(api_key=openai_api_key)
|
45 |
-
print("openai_client=")
|
46 |
-
print(openai_client)
|
47 |
|
48 |
# On first run, create assistant and update assistant_id,
|
49 |
# see https://platform.openai.com/playground/assistants.
|
@@ -70,8 +65,6 @@ def chat(message, history, openai_api_key):
|
|
70 |
if len(image_values) > 0:
|
71 |
download_link = f"<hr>[Download](https://platform.openai.com/storage/files/{image_values[0]})"
|
72 |
|
73 |
-
del os.environ["OPENAI_API_KEY"]
|
74 |
-
|
75 |
#return f"{'<hr>'.join(list(reversed(text_values))[1:])}{download_link}"
|
76 |
return f"{text_values[0]}{download_link}"
|
77 |
|
|
|
10 |
|
11 |
import os
|
12 |
|
|
|
|
|
13 |
from assistants import (
|
14 |
+
get_openai_client,
|
15 |
+
set_openai_client,
|
16 |
assistant,
|
17 |
thread,
|
18 |
create_assistant,
|
|
|
35 |
|
36 |
#raise gr.Error("Please clone and bring your own credentials.")
|
37 |
|
38 |
+
global assistant, thread
|
39 |
|
40 |
+
if get_openai_client() == None:
|
41 |
+
set_openai_client(openai_api_key)
|
|
|
|
|
|
|
|
|
42 |
|
43 |
# On first run, create assistant and update assistant_id,
|
44 |
# see https://platform.openai.com/playground/assistants.
|
|
|
65 |
if len(image_values) > 0:
|
66 |
download_link = f"<hr>[Download](https://platform.openai.com/storage/files/{image_values[0]})"
|
67 |
|
|
|
|
|
68 |
#return f"{'<hr>'.join(list(reversed(text_values))[1:])}{download_link}"
|
69 |
return f"{text_values[0]}{download_link}"
|
70 |
|