Peter commited on
Commit
72460eb
1 Parent(s): 3fdc337

:sparkles: add interactive params

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -12,6 +12,7 @@ import time
12
  import argparse
13
  import logging
14
  import gradio as gr
 
15
  import os
16
  import sys
17
  from os.path import dirname
@@ -45,7 +46,7 @@ cwd = Path.cwd()
45
  my_cwd = str(cwd.resolve()) # string so it can be passed to os.path() objects
46
 
47
 
48
- def chat(trivia_query):
49
  """
50
  chat - helper function that makes the whole gradio thing work.
51
 
@@ -56,7 +57,8 @@ def chat(trivia_query):
56
  [str]: the bot's response
57
  """
58
  history = []
59
- response = ask_gpt(message=trivia_query, chat_pipe=my_chatbot)
 
60
  history = [trivia_query, response]
61
  html = ""
62
  for item in history:
@@ -189,7 +191,10 @@ if __name__ == "__main__":
189
  print(f"using model stored here: \n {model_loc} \n")
190
  iface = gr.Interface(
191
  chat,
192
- inputs=["text"],
 
 
 
193
  outputs="html",
194
  examples_per_page=12,
195
  examples=[
 
12
  import argparse
13
  import logging
14
  import gradio as gr
15
+ from gradio.inputs import Slider
16
  import os
17
  import sys
18
  from os.path import dirname
 
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
 
 
57
  [str]: the bot's response
58
  """
59
  history = []
60
+ response = ask_gpt(message=trivia_query, chat_pipe=my_chatbot,
61
+ top_p=top_p, top_k=top_k, temperature=temperature)
62
  history = [trivia_query, response]
63
  html = ""
64
  for item in history:
 
191
  print(f"using model stored here: \n {model_loc} \n")
192
  iface = gr.Interface(
193
  chat,
194
+ inputs=["text",
195
+ Slider(minimum=0.0, maximum=1.0, step=0.01, default=0.6, label="temperature"),
196
+ Slider(minimum=0.0, maximum=1.0, step=0.01, default=0.95, label="top_p"),
197
+ Slider(minimum=0, maximum=250, step=1, default=50, label="top_k")],
198
  outputs="html",
199
  examples_per_page=12,
200
  examples=[