jozzy commited on
Commit
9f6e492
·
1 Parent(s): d4b3e89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -20
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 test:
73
- chatbot = gr.Chatbot()
74
- msg = gr.Textbox()
75
  clear_btn = gr.Button("Clear")
76
- msg.submit(textGPT2, [chatbot, msg], chatbot)
77
- clear_btn.click(fn=clear, inputs=None, outputs=chatbot, queue=False)
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")