Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,33 +48,17 @@ def textGPT(text):
|
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
-
def textGPT2(chat_history, text):
|
| 52 |
-
global messages
|
| 53 |
-
|
| 54 |
-
messages.append({"role": "user", "content": text})
|
| 55 |
-
|
| 56 |
-
#response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages)
|
| 57 |
-
|
| 58 |
-
#system_message = response["choices"][0]["message"]
|
| 59 |
-
system_message = text.type() + "121234123"
|
| 60 |
-
#system_message = text + "121234123"
|
| 61 |
-
messages.append(system_message)
|
| 62 |
-
|
| 63 |
-
return chat_history + [[text, system_message]]
|
| 64 |
-
|
| 65 |
-
|
| 66 |
def clear():
|
| 67 |
global messages
|
| 68 |
messages = [{"role": "system", "content": 'You are a helpful technology assistant.'}]
|
| 69 |
return
|
| 70 |
|
| 71 |
|
| 72 |
-
with gr.Blocks() as
|
| 73 |
-
|
| 74 |
-
msg = gr.Textbox()
|
| 75 |
clear_btn = gr.Button("Clear")
|
| 76 |
-
|
| 77 |
-
|
| 78 |
|
| 79 |
|
| 80 |
text = gr.Interface(fn=textGPT, inputs="text", outputs="text")
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
def clear():
|
| 52 |
global messages
|
| 53 |
messages = [{"role": "system", "content": 'You are a helpful technology assistant.'}]
|
| 54 |
return
|
| 55 |
|
| 56 |
|
| 57 |
+
with gr.Blocks() as ClearHistory:
|
| 58 |
+
gr.Markdown("Click the Clear button below to remove all the chat history.")
|
|
|
|
| 59 |
clear_btn = gr.Button("Clear")
|
| 60 |
+
clear_btn.click(fn=clear, inputs=None, outputs=None, queue=False)
|
| 61 |
+
|
| 62 |
|
| 63 |
|
| 64 |
text = gr.Interface(fn=textGPT, inputs="text", outputs="text")
|