Omnibus commited on
Commit
fe8c2db
·
verified ·
1 Parent(s): d0d4c9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -7
app.py CHANGED
@@ -25,7 +25,7 @@ def format_prompt(message, history):
25
 
26
 
27
 
28
- def chat_inf(system_prompt,prompt,history,client_choice):
29
  #token max=8192
30
  client=clients[int(client_choice)-1]
31
  if not history:
@@ -35,12 +35,12 @@ def chat_inf(system_prompt,prompt,history,client_choice):
35
  hist_len=len(history)
36
  print(hist_len)
37
 
38
- seed = random.randint(1,1111111111111111)
39
  generate_kwargs = dict(
40
- temperature=0.9,
41
- max_new_tokens=6000,
42
- top_p=0.95,
43
- repetition_penalty=1.0,
44
  do_sample=True,
45
  seed=seed,
46
  )
@@ -57,6 +57,15 @@ def chat_inf(system_prompt,prompt,history,client_choice):
57
 
58
  def clear_fn():
59
  return None,None,None
 
 
 
 
 
 
 
 
 
60
  with gr.Blocks() as app:
61
  gr.HTML("""<center><h1 style='font-size:xx-large;'>Google Gemma Models</h1><br><h3>running on Huggingface Inference Client</h3><br><h7>EXPERIMENTAL""")
62
  with gr.Group():
@@ -68,12 +77,20 @@ with gr.Blocks() as app:
68
  btn = gr.Button("Chat")
69
 
70
  with gr.Column(scale=1):
 
 
 
 
 
 
 
 
71
  with gr.Group():
72
  stop_btn=gr.Button("Stop")
73
  clear_btn=gr.Button("Clear")
74
  client_choice=gr.Dropdown(label="Models",type='index',choices=[c for c in models],value=models[0],interactive=True)
75
 
76
- go=btn.click(chat_inf,[sys_inp,inp,chat_b,client_choice],chat_b)
77
  stop_btn.click(None,None,None,cancels=go)
78
  clear_btn.click(clear_fn,None,[inp,sys_inp,chat_b])
79
  app.queue(default_concurrency_limit=10).launch()
 
25
 
26
 
27
 
28
+ def chat_inf(system_prompt,prompt,history,client_choice,seed,temp,tokens,top_p,rep_p):
29
  #token max=8192
30
  client=clients[int(client_choice)-1]
31
  if not history:
 
35
  hist_len=len(history)
36
  print(hist_len)
37
 
38
+ #seed = random.randint(1,1111111111111111)
39
  generate_kwargs = dict(
40
+ temperature=temp,
41
+ max_new_tokens=tokens,
42
+ top_p=top_p,
43
+ repetition_penalty=rep_p,
44
  do_sample=True,
45
  seed=seed,
46
  )
 
57
 
58
  def clear_fn():
59
  return None,None,None
60
+ rand_val=random.randint(1,1111111111111111)
61
+ def check_rand(inp,val):
62
+ if inp==True:
63
+ return gr.Slider(label="Seed", minimum=1, maximum=1111111111111111, value=random.randint(1,1111111111111111))
64
+ else:
65
+ return gr.Slider(label="Seed", minimum=1, maximum=1111111111111111, value=int(val))
66
+
67
+
68
+
69
  with gr.Blocks() as app:
70
  gr.HTML("""<center><h1 style='font-size:xx-large;'>Google Gemma Models</h1><br><h3>running on Huggingface Inference Client</h3><br><h7>EXPERIMENTAL""")
71
  with gr.Group():
 
77
  btn = gr.Button("Chat")
78
 
79
  with gr.Column(scale=1):
80
+ with gr.Group():
81
+ rand = gr.Checkbox(label="Random", value=True)
82
+ seed=gr.Slider(label="Seed", minimum=1, maximum=1111111111111111,step=1, value=rand_val)
83
+ tokens = gr.Slider(label="Max new tokens",value=6400,minimum=0,maximum=8000,step=64,interactive=True, visible=True,info="The maximum number of tokens")
84
+ temp=gr.Slider(label="Temperature",step=0.01, minimum=0.01, maximum=1.0, value=0.9)
85
+ top_p=gr.Slider(label="Top-P",step=0.01, minimum=0.01, maximum=1.0, value=0.9)
86
+ rep_p=gr.Slider(label="Repetition Penalty",step=0.1, minimum=0.1, maximum=2.0, value=1.0)
87
+
88
  with gr.Group():
89
  stop_btn=gr.Button("Stop")
90
  clear_btn=gr.Button("Clear")
91
  client_choice=gr.Dropdown(label="Models",type='index',choices=[c for c in models],value=models[0],interactive=True)
92
 
93
+ go=btn.click(check_rand,[rand,seed],seed).then(chat_inf,[sys_inp,inp,chat_b,client_choice,seed,temp,tokens,top_p,rep_p],chat_b)
94
  stop_btn.click(None,None,None,cancels=go)
95
  clear_btn.click(clear_fn,None,[inp,sys_inp,chat_b])
96
  app.queue(default_concurrency_limit=10).launch()