yandricr commited on
Commit
79b18b1
·
verified ·
1 Parent(s): 6589afc
Files changed (1) hide show
  1. app.py +1 -29
app.py CHANGED
@@ -16,11 +16,7 @@ with gr.Blocks() as demo:
16
  interactive=True, choices=["gpt-4", "gpt-3.5-turbo"], value="gpt-4", label="Select Model", info="ChatGPT", visible=True
17
  )
18
  msg = gr.Textbox(placeholder="Message", show_label=False)
19
- clear = None
20
- btnRandom = None
21
- with gr.Row():
22
- btnRandom = gr.Button("Random message")
23
- clear = gr.ClearButton([msg, chatbot])
24
 
25
  def change_model(req):
26
  match req.lower():
@@ -142,32 +138,8 @@ with gr.Blocks() as demo:
142
  error_alert("You haven't selected an AI model to start")
143
  history[cnt][1] = None
144
  yield history
145
-
146
- def rand_message():
147
- try:
148
- res = gpt.prompts(lang="en", limit=4, offset=0)
149
-
150
- if res.error != None:
151
- error_alert("The error has occurred. Please try again.")
152
- return ""
153
- else:
154
- result = res.result
155
- if result.get("items") != None:
156
- random_prompt = random.choice(result.get("items"))
157
- if random_prompt != None and random_prompt.get("prompt") != None:
158
- return str(random_prompt.get("prompt"))
159
- else:
160
- error_alert("The error has occurred. Please try again.")
161
- return ""
162
- else:
163
- error_alert("The error has occurred. Please try again.")
164
- return ""
165
- except Exception as e:
166
- error_alert("The error has occurred. Please try again.")
167
- return ""
168
 
169
  radio.change(fn=change_model, inputs=radio, outputs=drp)
170
- btnRandom.click(fn=rand_message, outputs=[msg])
171
 
172
  msg.submit(user_msg, inputs=[msg, chatbot], outputs=[msg, chatbot], queue=True).then(
173
  strm_message, [chatbot, radio, drp], chatbot
 
16
  interactive=True, choices=["gpt-4", "gpt-3.5-turbo"], value="gpt-4", label="Select Model", info="ChatGPT", visible=True
17
  )
18
  msg = gr.Textbox(placeholder="Message", show_label=False)
19
+ clear = gr.ClearButton([msg, chatbot])
 
 
 
 
20
 
21
  def change_model(req):
22
  match req.lower():
 
138
  error_alert("You haven't selected an AI model to start")
139
  history[cnt][1] = None
140
  yield history
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
  radio.change(fn=change_model, inputs=radio, outputs=drp)
 
143
 
144
  msg.submit(user_msg, inputs=[msg, chatbot], outputs=[msg, chatbot], queue=True).then(
145
  strm_message, [chatbot, radio, drp], chatbot