Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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=
|
41 |
-
max_new_tokens=
|
42 |
-
top_p=
|
43 |
-
repetition_penalty=
|
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():
|
@@ -65,15 +74,26 @@ with gr.Blocks() as app:
|
|
65 |
with gr.Column(scale=3):
|
66 |
inp = gr.Textbox(label="Prompt")
|
67 |
sys_inp = gr.Textbox(label="System Prompt (optional)")
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
with gr.Column(scale=1):
|
71 |
with gr.Group():
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
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():
|
|
|
74 |
with gr.Column(scale=3):
|
75 |
inp = gr.Textbox(label="Prompt")
|
76 |
sys_inp = gr.Textbox(label="System Prompt (optional)")
|
77 |
+
client_choice=gr.Dropdown(label="Models",type='index',choices=[c for c in models],value=models[0],interactive=True)
|
78 |
+
with gr.Row():
|
79 |
+
with gr.Column(scale=2):
|
80 |
+
btn = gr.Button("Chat")
|
81 |
+
with gr.Column(scale=1):
|
82 |
+
with gr.Group():
|
83 |
+
stop_btn=gr.Button("Stop")
|
84 |
+
clear_btn=gr.Button("Clear")
|
85 |
with gr.Column(scale=1):
|
86 |
with gr.Group():
|
87 |
+
rand = gr.Checkbox(label="Random", value=True)
|
88 |
+
seed=gr.Slider(label="Seed", minimum=1, maximum=1111111111111111,step=1, value=rand_val)
|
89 |
+
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")
|
90 |
+
temp=gr.Slider(label="Temperature",step=0.01, minimum=0.01, maximum=1.0, value=0.9)
|
91 |
+
top_p=gr.Slider(label="Top-P",step=0.01, minimum=0.01, maximum=1.0, value=0.9)
|
92 |
+
rep_p=gr.Slider(label="Repetition Penalty",step=0.1, minimum=0.1, maximum=2.0, value=1.0)
|
93 |
+
|
94 |
+
|
95 |
|
96 |
+
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)
|
97 |
stop_btn.click(None,None,None,cancels=go)
|
98 |
clear_btn.click(clear_fn,None,[inp,sys_inp,chat_b])
|
99 |
app.queue(default_concurrency_limit=10).launch()
|