dlflannery commited on
Commit
167569a
·
verified ·
1 Parent(s): 14fc436

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -49,6 +49,9 @@ def clear():
49
  def updatePassword(txt):
50
  return [txt.lower(), "*********"]
51
 
 
 
 
52
  def chat(prompt, user_window, pwd_window, past, response, gptModel):
53
  user_window = user_window.lower()
54
  if user_window == unames[0] and pwd_window == pwdList[0]:
@@ -63,7 +66,7 @@ def chat(prompt, user_window, pwd_window, past, response, gptModel):
63
  completion = client.chat.completions.create(model=gptModel,
64
  messages=past)
65
  reply = completion.choices[0].message.content
66
- response += "\n\nYOU: " + prompt + "\nGPT: " + reply
67
  if len(response) > 40000:
68
  response += "\n\nTHIS DIALOG IS GETTING TOO LONG. PLEASE CLEAR IT."
69
  past.append({"role":"assistant", "content": reply})
@@ -102,5 +105,5 @@ with gr.Blocks() as demo:
102
  submit_window.click(chat, inputs=[prompt_window, user_window, password, history, output_window, model],
103
  outputs=[history, output_window, prompt_window])
104
  clear_button.click(clear, inputs=[], outputs=[prompt_window, history, output_window])
105
-
106
  demo.launch()
 
49
  def updatePassword(txt):
50
  return [txt.lower(), "*********"]
51
 
52
+ def setModel(val):
53
+ return val
54
+
55
  def chat(prompt, user_window, pwd_window, past, response, gptModel):
56
  user_window = user_window.lower()
57
  if user_window == unames[0] and pwd_window == pwdList[0]:
 
66
  completion = client.chat.completions.create(model=gptModel,
67
  messages=past)
68
  reply = completion.choices[0].message.content
69
+ response += "\n\nYOU: " + prompt + "\nGPT: " + reply # + "\nModel = " + gptModel
70
  if len(response) > 40000:
71
  response += "\n\nTHIS DIALOG IS GETTING TOO LONG. PLEASE CLEAR IT."
72
  past.append({"role":"assistant", "content": reply})
 
105
  submit_window.click(chat, inputs=[prompt_window, user_window, password, history, output_window, model],
106
  outputs=[history, output_window, prompt_window])
107
  clear_button.click(clear, inputs=[], outputs=[prompt_window, history, output_window])
108
+ gpt_chooser.input(fn=setModel, inputs=gpt_chooser, outputs=model)
109
  demo.launch()