Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,7 +20,7 @@ temperature=0.99
|
|
| 20 |
top_p=0.99
|
| 21 |
repetition_penalty=1.0
|
| 22 |
|
| 23 |
-
def compress_history(history,temperature=temperature,top_p=top_p,repetition_penalty=repetition_penalty):
|
| 24 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 25 |
|
| 26 |
print("COMPRESSING")
|
|
@@ -31,8 +31,7 @@ def compress_history(history,temperature=temperature,top_p=top_p,repetition_pena
|
|
| 31 |
top_p=top_p,
|
| 32 |
repetition_penalty=repetition_penalty,
|
| 33 |
do_sample=True,
|
| 34 |
-
seed=
|
| 35 |
-
#seed=42,
|
| 36 |
)
|
| 37 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
| 38 |
output = ""
|
|
@@ -42,7 +41,7 @@ def compress_history(history,temperature=temperature,top_p=top_p,repetition_pena
|
|
| 42 |
|
| 43 |
MAX_HISTORY=100
|
| 44 |
opts=[]
|
| 45 |
-
def generate(prompt, history,max_new_tokens,health,temperature=temperature,top_p=top_p,repetition_penalty=repetition_penalty):
|
| 46 |
opts.clear()
|
| 47 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 48 |
|
|
@@ -57,8 +56,7 @@ def generate(prompt, history,max_new_tokens,health,temperature=temperature,top_p
|
|
| 57 |
top_p=top_p,
|
| 58 |
repetition_penalty=repetition_penalty,
|
| 59 |
do_sample=True,
|
| 60 |
-
seed=
|
| 61 |
-
#seed=42,
|
| 62 |
)
|
| 63 |
cnt=0
|
| 64 |
stats=health
|
|
@@ -156,7 +154,10 @@ Power: 20
|
|
| 156 |
Strength: 24
|
| 157 |
*******************
|
| 158 |
'''
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
| 160 |
with gr.Blocks() as app:
|
| 161 |
gr.HTML("""<center><h1>Mixtral 8x7B RPG</h1><h3>Role Playing Game Master</h3>""")
|
| 162 |
with gr.Group():
|
|
@@ -169,6 +170,8 @@ with gr.Blocks() as app:
|
|
| 169 |
#prompt=gr.Textbox(label = "Prompt", value="Start a new game")
|
| 170 |
with gr.Column(scale=2):
|
| 171 |
button=gr.Button()
|
|
|
|
|
|
|
| 172 |
#models_dd=gr.Dropdown(choices=[m for m in return_list],interactive=True)
|
| 173 |
with gr.Row():
|
| 174 |
stop_button=gr.Button("Stop")
|
|
@@ -188,7 +191,7 @@ with gr.Blocks() as app:
|
|
| 188 |
#inp_query.change(search_models,inp_query,models_dd)
|
| 189 |
#test_b=test_btn.click(itt,url,e_box)
|
| 190 |
clear_btn.click(clear_fn,None,[opt,chatbot])
|
| 191 |
-
go=button.click(generate,[opt,chatbot,tokens,char_stats],[chatbot,char_stats,json_out,opt])
|
| 192 |
stop_button.click(None,None,None,cancels=[go])
|
| 193 |
app.launch(show_api=False)
|
| 194 |
|
|
|
|
| 20 |
top_p=0.99
|
| 21 |
repetition_penalty=1.0
|
| 22 |
|
| 23 |
+
def compress_history(history,seed,temperature=temperature,top_p=top_p,repetition_penalty=repetition_penalty):
|
| 24 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 25 |
|
| 26 |
print("COMPRESSING")
|
|
|
|
| 31 |
top_p=top_p,
|
| 32 |
repetition_penalty=repetition_penalty,
|
| 33 |
do_sample=True,
|
| 34 |
+
seed=seed,
|
|
|
|
| 35 |
)
|
| 36 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
| 37 |
output = ""
|
|
|
|
| 41 |
|
| 42 |
MAX_HISTORY=100
|
| 43 |
opts=[]
|
| 44 |
+
def generate(prompt, history,max_new_tokens,health,seed,temperature=temperature,top_p=top_p,repetition_penalty=repetition_penalty):
|
| 45 |
opts.clear()
|
| 46 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 47 |
|
|
|
|
| 56 |
top_p=top_p,
|
| 57 |
repetition_penalty=repetition_penalty,
|
| 58 |
do_sample=True,
|
| 59 |
+
seed=seed,
|
|
|
|
| 60 |
)
|
| 61 |
cnt=0
|
| 62 |
stats=health
|
|
|
|
| 154 |
Strength: 24
|
| 155 |
*******************
|
| 156 |
'''
|
| 157 |
+
def check_rand(inp):
|
| 158 |
+
if inp==True:
|
| 159 |
+
return gr.Slider(label="Seed", minimum=1, maximum=99999999999, value=random.randint(1,99999999999))
|
| 160 |
+
rand_val=random.randint(1,99999999999)
|
| 161 |
with gr.Blocks() as app:
|
| 162 |
gr.HTML("""<center><h1>Mixtral 8x7B RPG</h1><h3>Role Playing Game Master</h3>""")
|
| 163 |
with gr.Group():
|
|
|
|
| 170 |
#prompt=gr.Textbox(label = "Prompt", value="Start a new game")
|
| 171 |
with gr.Column(scale=2):
|
| 172 |
button=gr.Button()
|
| 173 |
+
rand = gr.Checkbox(label="Random", value=False)
|
| 174 |
+
seed=gr.Slider(label="Seed", minimum=1, maximum=99999999999, value=rand_val)
|
| 175 |
#models_dd=gr.Dropdown(choices=[m for m in return_list],interactive=True)
|
| 176 |
with gr.Row():
|
| 177 |
stop_button=gr.Button("Stop")
|
|
|
|
| 191 |
#inp_query.change(search_models,inp_query,models_dd)
|
| 192 |
#test_b=test_btn.click(itt,url,e_box)
|
| 193 |
clear_btn.click(clear_fn,None,[opt,chatbot])
|
| 194 |
+
go=button.click(check_rand,rand,seed).then(generate,[opt,chatbot,tokens,char_stats,seed],[chatbot,char_stats,json_out,opt])
|
| 195 |
stop_button.click(None,None,None,cancels=[go])
|
| 196 |
app.launch(show_api=False)
|
| 197 |
|