Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,9 +25,14 @@ from assistants import (
|
|
| 25 |
extract_content_values,
|
| 26 |
)
|
| 27 |
|
| 28 |
-
def chat(message, history):
|
| 29 |
if not message:
|
| 30 |
raise gr.Error("Message is required.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
global assistant, thread
|
| 33 |
|
|
@@ -35,11 +40,8 @@ def chat(message, history):
|
|
| 35 |
# see https://platform.openai.com/playground/assistants.
|
| 36 |
# On subsequent runs, load assistant.
|
| 37 |
if assistant == None:
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
assistant = load_assistant()
|
| 41 |
-
except:
|
| 42 |
-
raise gr.Error("Please clone and bring your own credentials.")
|
| 43 |
|
| 44 |
# TODO: Use Gradio session to support multiple users
|
| 45 |
if thread == None or len(history) == 0:
|
|
@@ -81,4 +83,7 @@ gr.ChatInterface(
|
|
| 81 |
["1. Execute with tools: Get key announcements from latest OpenAI Dev Day. 2. Show the web references."]
|
| 82 |
],
|
| 83 |
cache_examples=True,
|
|
|
|
|
|
|
|
|
|
| 84 |
).launch()
|
|
|
|
| 25 |
extract_content_values,
|
| 26 |
)
|
| 27 |
|
| 28 |
+
def chat(message, history, openai_api_key):
|
| 29 |
if not message:
|
| 30 |
raise gr.Error("Message is required.")
|
| 31 |
+
|
| 32 |
+
if not openai_api_key:
|
| 33 |
+
raise gr.Error("OpenAI API key is required.")
|
| 34 |
+
|
| 35 |
+
print(openai_api_key)
|
| 36 |
|
| 37 |
global assistant, thread
|
| 38 |
|
|
|
|
| 40 |
# see https://platform.openai.com/playground/assistants.
|
| 41 |
# On subsequent runs, load assistant.
|
| 42 |
if assistant == None:
|
| 43 |
+
#assistant = create_assistant()
|
| 44 |
+
assistant = load_assistant()
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
# TODO: Use Gradio session to support multiple users
|
| 47 |
if thread == None or len(history) == 0:
|
|
|
|
| 83 |
["1. Execute with tools: Get key announcements from latest OpenAI Dev Day. 2. Show the web references."]
|
| 84 |
],
|
| 85 |
cache_examples=True,
|
| 86 |
+
additional_inputs=[
|
| 87 |
+
gr.Textbox(label="OpenAI API Key", type="password"),
|
| 88 |
+
],
|
| 89 |
).launch()
|