Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,7 +46,7 @@ def extract_content_values(data):
|
|
| 46 |
|
| 47 |
return content_values
|
| 48 |
|
| 49 |
-
def chat(message,
|
| 50 |
global _client, _assistant, _thread
|
| 51 |
|
| 52 |
if _client == None:
|
|
@@ -74,16 +74,7 @@ def chat(message, msg2, history):
|
|
| 74 |
show_json("messages", messages)
|
| 75 |
|
| 76 |
return extract_content_values(messages)[0]
|
| 77 |
-
|
| 78 |
-
def vote(data: gr.LikeData):
|
| 79 |
-
print(data.value)
|
| 80 |
-
print(data.value["value"])
|
| 81 |
-
#if data.liked:
|
| 82 |
-
# print("You upvoted this response: " + data.value["value"])
|
| 83 |
-
#else:
|
| 84 |
-
# print("You downvoted this response: " + data.value["value"])
|
| 85 |
|
| 86 |
-
"""
|
| 87 |
gr.ChatInterface(
|
| 88 |
chat,
|
| 89 |
chatbot=gr.Chatbot(height=300),
|
|
@@ -96,16 +87,7 @@ gr.ChatInterface(
|
|
| 96 |
retry_btn=None,
|
| 97 |
undo_btn=None,
|
| 98 |
clear_btn="Clear",
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
).launch()
|
| 104 |
-
"""
|
| 105 |
-
|
| 106 |
-
with gr.Blocks() as demo:
|
| 107 |
-
chatbot = gr.Chatbot(placeholder="<strong>Math Tutor</strong><br>Ask Me Anything")
|
| 108 |
-
chatbot.like(vote, None, None)
|
| 109 |
-
gr.ChatInterface(fn=chat, chatbot=chatbot)
|
| 110 |
-
|
| 111 |
-
demo.launch()
|
|
|
|
| 46 |
|
| 47 |
return content_values
|
| 48 |
|
| 49 |
+
def chat(message, history, openai_api_key):
|
| 50 |
global _client, _assistant, _thread
|
| 51 |
|
| 52 |
if _client == None:
|
|
|
|
| 74 |
show_json("messages", messages)
|
| 75 |
|
| 76 |
return extract_content_values(messages)[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
|
|
|
| 78 |
gr.ChatInterface(
|
| 79 |
chat,
|
| 80 |
chatbot=gr.Chatbot(height=300),
|
|
|
|
| 87 |
retry_btn=None,
|
| 88 |
undo_btn=None,
|
| 89 |
clear_btn="Clear",
|
| 90 |
+
additional_inputs=[
|
| 91 |
+
gr.Textbox("sk-", label="OpenAI API Key", type = "password"),
|
| 92 |
+
],
|
| 93 |
+
).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|