Peter commited on
Commit
814a362
1 Parent(s): 38ca40a

:lipstick: update UI

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -46,7 +46,7 @@ cwd = Path.cwd()
46
  my_cwd = str(cwd.resolve()) # string so it can be passed to os.path() objects
47
 
48
 
49
- def chat(trivia_query, temperature=0.7, top_p=0.95, top_k=50):
50
  """
51
  chat - helper function that makes the whole gradio thing work.
52
 
@@ -58,13 +58,13 @@ def chat(trivia_query, temperature=0.7, top_p=0.95, top_k=50):
58
  """
59
  history = []
60
  response = ask_gpt(
61
- message=trivia_query,
62
  chat_pipe=my_chatbot,
63
  top_p=top_p,
64
  top_k=top_k,
65
  temperature=temperature,
66
  )
67
- history = [trivia_query, response]
68
  html = ""
69
  for item in history:
70
  html += f"<b>{item}</b> <br>"
@@ -202,7 +202,7 @@ if __name__ == "__main__":
202
  minimum=0.0, maximum=1.0, step=0.01, default=0.6, label="temperature"
203
  ),
204
  Slider(minimum=0.0, maximum=1.0, step=0.01, default=0.95, label="top_p"),
205
- Slider(minimum=0, maximum=250, step=1, default=50, label="top_k"),
206
  ],
207
  outputs="html",
208
  examples_per_page=8,
@@ -212,10 +212,10 @@ if __name__ == "__main__":
212
  ["Hi, my name is……", 0.6, 0.95, 50],
213
  ["Happy birthday!", 0.9, 0.95, 50],
214
  ["I have a question, can you help me?", 0.6, 0.95, 50],
215
- ["Do you know a joke?", 0.6, 0.85, 50],
216
- ["Will you marry me?", 0.6, 0.95, 138],
217
  ["Are you single?", 0.6, 0.95, 138],
218
- ["Do you like people?", 0.6, 0.95, 50],
219
  ["Are you part of the Matrix?", 0.6, 0.95, 50],
220
  ["Do you have a hobby?", 0.6, 0.95, 50],
221
  ["You’re clever", 0.6, 0.95, 50],
@@ -228,12 +228,12 @@ if __name__ == "__main__":
228
  title=f"GPT Chatbot Demo: {default_model} Model",
229
  description=f"A Demo of a Chatbot trained for conversation with humans. Size XL= 1.5B parameters.\n\n"
230
  "**Important Notes & About:**\n\n"
231
- "You can find a link to the model card [here](https://huggingface.co/ethzanalytics/ai-msgbot-gpt2-XL-dialogue)\n\n"
232
- "1. the model can take up to 60 seconds to respond sometimes, patience is a virtue.\n"
233
- "2. the model started from a pretrained checkpoint, and was trained on several different datasets. Anything it says should be fact-checked before being regarded as a true statement.\n"
234
- "3. Some params are still being tweaked (in the future, will be inputs) any feedback is welcome :)\n",
235
  css="""
236
- .chatbox {display:flex;flex-direction:column}
237
  .user_msg, .resp_msg {padding:4px;margin-bottom:4px;border-radius:4px;width:80%}
238
  .user_msg {background-color:cornflowerblue;color:white;align-self:start}
239
  .resp_msg {background-color:lightgray;align-self:self-end}
 
46
  my_cwd = str(cwd.resolve()) # string so it can be passed to os.path() objects
47
 
48
 
49
+ def chat(prompt_message, temperature=0.7, top_p=0.95, top_k=50):
50
  """
51
  chat - helper function that makes the whole gradio thing work.
52
 
 
58
  """
59
  history = []
60
  response = ask_gpt(
61
+ message=prompt_message,
62
  chat_pipe=my_chatbot,
63
  top_p=top_p,
64
  top_k=top_k,
65
  temperature=temperature,
66
  )
67
+ history = [prompt_message, response]
68
  html = ""
69
  for item in history:
70
  html += f"<b>{item}</b> <br>"
 
202
  minimum=0.0, maximum=1.0, step=0.01, default=0.6, label="temperature"
203
  ),
204
  Slider(minimum=0.0, maximum=1.0, step=0.01, default=0.95, label="top_p"),
205
+ Slider(minimum=0, maximum=250, step=5, default=50, label="top_k"),
206
  ],
207
  outputs="html",
208
  examples_per_page=8,
 
212
  ["Hi, my name is……", 0.6, 0.95, 50],
213
  ["Happy birthday!", 0.9, 0.95, 50],
214
  ["I have a question, can you help me?", 0.6, 0.95, 50],
215
+ ["Do you know a joke?", 0.8, 0.85, 50],
216
+ ["Will you marry me?", 0.9, 0.95, 138],
217
  ["Are you single?", 0.6, 0.95, 138],
218
+ ["Do you like people?", 0.7, 0.95, 25],
219
  ["Are you part of the Matrix?", 0.6, 0.95, 50],
220
  ["Do you have a hobby?", 0.6, 0.95, 50],
221
  ["You’re clever", 0.6, 0.95, 50],
 
228
  title=f"GPT Chatbot Demo: {default_model} Model",
229
  description=f"A Demo of a Chatbot trained for conversation with humans. Size XL= 1.5B parameters.\n\n"
230
  "**Important Notes & About:**\n\n"
231
+ "You can find a link to the model card **[here](https://huggingface.co/ethzanalytics/ai-msgbot-gpt2-XL-dialogue)**\n\n"
232
+ "1. responses can take up to 60 seconds to respond sometimes, patience is a virtue.\n"
233
+ "2. the model was trained on several different datasets. fact-check responses instead of regarding as a true statement.\n"
234
+ "3. Try adjusting the **[generation parameters](https://huggingface.co/blog/how-to-generate)** to get a better understanding of how they work!\n",
235
  css="""
236
+ .chatbox {display:flex;flex-direction:row}
237
  .user_msg, .resp_msg {padding:4px;margin-bottom:4px;border-radius:4px;width:80%}
238
  .user_msg {background-color:cornflowerblue;color:white;align-self:start}
239
  .resp_msg {background-color:lightgray;align-self:self-end}