peter szemraj commited on
Commit
2a3e09e
1 Parent(s): b649bd8

:lipstick: formatting for GUI

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -66,7 +66,7 @@ def ask_gpt(message: str):
66
  Returns:
67
  [str]: [model response as a string]
68
  """
69
- st = time.time()
70
  prompt = clean(message) # clean user input
71
  prompt = prompt.strip() # get rid of any extra whitespace
72
  if len(prompt) > 200:
@@ -81,12 +81,12 @@ def ask_gpt(message: str):
81
  top_p=0.65, # optimize this with hyperparam search
82
  )
83
  bot_resp = gramformer_correct(corrector, qphrase=resp["out_text"])
84
- rt = round(time.time() - st, 2)
85
  print(f"took {rt} sec to respond")
86
  return bot_resp
87
 
88
 
89
- def chat(message):
90
  """
91
  chat - helper function that makes the whole gradio thing work.
92
 
@@ -98,8 +98,8 @@ def chat(message):
98
  [str]: [returns an html string to display]
99
  """
100
  history = []
101
- response = ask_gpt(message)
102
- history.append(f"<b>{message}</b> <br> <br> <b>{response}</b>")
103
  gr.set_state(history) # save the history
104
  html = ""
105
  for item in history:
@@ -150,7 +150,7 @@ if __name__ == "__main__":
150
  chat,
151
  inputs=["text"],
152
  outputs="html",
153
- title=f"[WORK-IN-PROGRESS] Ballpark Trivia: {default_model} Model",
154
  description=f"Are you frequently asked google-able Trivia questions and annoyed by it? Well, this is the app for you! Ballpark Trivia Bot answers any trivia question with something that sounds plausible but is probably not 100% correct. \n\n One might say.. the answers are in the right ballpark.",
155
  article="Further details can be found in the [model card](https: // huggingface.co/pszemraj/Ballpark-Trivia-L). If you are interested in a more deceptively incorrect model, there is also an XL version on my page.\n\n"
156
  "**Important Notes & About:**\n\n"
@@ -171,5 +171,5 @@ if __name__ == "__main__":
171
  # launch the gradio interface and start the server
172
  iface.launch(
173
  share=True,
174
- enable_queue=True,
175
  )
 
66
  Returns:
67
  [str]: [model response as a string]
68
  """
69
+ st = time.perf_counter()
70
  prompt = clean(message) # clean user input
71
  prompt = prompt.strip() # get rid of any extra whitespace
72
  if len(prompt) > 200:
 
81
  top_p=0.65, # optimize this with hyperparam search
82
  )
83
  bot_resp = gramformer_correct(corrector, qphrase=resp["out_text"])
84
+ rt = round(time.perf_counter() - st, 2)
85
  print(f"took {rt} sec to respond")
86
  return bot_resp
87
 
88
 
89
+ def chat(trivia_query):
90
  """
91
  chat - helper function that makes the whole gradio thing work.
92
 
 
98
  [str]: [returns an html string to display]
99
  """
100
  history = []
101
+ response = ask_gpt(trivia_query)
102
+ history.append(f"<b>Trivia Question: {trivia_query}</b> <br> <br> <b>Ballpark Answer: {response}</b>")
103
  gr.set_state(history) # save the history
104
  html = ""
105
  for item in history:
 
150
  chat,
151
  inputs=["text"],
152
  outputs="html",
153
+ title=f"Ballpark Trivia: {default_model} Model",
154
  description=f"Are you frequently asked google-able Trivia questions and annoyed by it? Well, this is the app for you! Ballpark Trivia Bot answers any trivia question with something that sounds plausible but is probably not 100% correct. \n\n One might say.. the answers are in the right ballpark.",
155
  article="Further details can be found in the [model card](https: // huggingface.co/pszemraj/Ballpark-Trivia-L). If you are interested in a more deceptively incorrect model, there is also an XL version on my page.\n\n"
156
  "**Important Notes & About:**\n\n"
 
171
  # launch the gradio interface and start the server
172
  iface.launch(
173
  share=True,
174
+ enable_queue=True, # also allows for dealing with multiple users simultaneously (per newer gradio version)
175
  )