Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -83,9 +83,9 @@ def generate(prompt, history,max_new_tokens,health,temperature=temperature,top_p
|
|
83 |
for response in stream:
|
84 |
output += response.token.text
|
85 |
if history:
|
86 |
-
yield "",[(prompt,output)],stats,None
|
87 |
else:
|
88 |
-
yield "",[(prompt,output)],stats,None
|
89 |
generate_kwargs2 = dict(
|
90 |
temperature=temperature,
|
91 |
max_new_tokens=128,
|
@@ -105,6 +105,7 @@ def generate(prompt, history,max_new_tokens,health,temperature=temperature,top_p
|
|
105 |
lines = output.strip().strip("\n").split("\n")
|
106 |
skills=[]
|
107 |
skill_dict={}
|
|
|
108 |
new_stat="*******************\n"
|
109 |
for i,line in enumerate(lines):
|
110 |
if ":" in line:
|
@@ -112,6 +113,7 @@ def generate(prompt, history,max_new_tokens,health,temperature=temperature,top_p
|
|
112 |
try:
|
113 |
if f'{z}' in lines[i+z]:
|
114 |
print(lines[i+z].split(" ",1)[1])
|
|
|
115 |
except Exception:
|
116 |
pass
|
117 |
if ": " in line:
|
@@ -132,11 +134,13 @@ def generate(prompt, history,max_new_tokens,health,temperature=temperature,top_p
|
|
132 |
skills.append(skill_dict)
|
133 |
new_stat+="*******************\n"
|
134 |
stats=new_stat
|
|
|
|
|
135 |
if history:
|
136 |
history.append((prompt,output))
|
137 |
-
yield "",history,stats,skills
|
138 |
else:
|
139 |
-
yield "",[(prompt,output)],stats,skills
|
140 |
|
141 |
def clear_fn():
|
142 |
return None,None
|
@@ -160,9 +164,9 @@ with gr.Blocks() as app:
|
|
160 |
with gr.Row():
|
161 |
with gr.Column(scale=3):
|
162 |
prompt=gr.Textbox(label = "Prompt", value="Start a new game")
|
163 |
-
with gr.Column(scale=
|
164 |
button=gr.Button()
|
165 |
-
|
166 |
#models_dd=gr.Dropdown(choices=[m for m in return_list],interactive=True)
|
167 |
with gr.Row():
|
168 |
stop_button=gr.Button("Stop")
|
@@ -172,11 +176,15 @@ with gr.Blocks() as app:
|
|
172 |
with gr.Column(scale=1):
|
173 |
json_out=gr.JSON(value=base_stats)
|
174 |
char_stats=gr.Textbox(value=text_stats)
|
|
|
|
|
|
|
|
|
175 |
#text=gr.JSON()
|
176 |
#inp_query.change(search_models,inp_query,models_dd)
|
177 |
#test_b=test_btn.click(itt,url,e_box)
|
178 |
clear_btn.click(clear_fn,None,[prompt,chatbot])
|
179 |
-
go=button.click(generate,[prompt,chatbot,tokens,char_stats],[prompt,chatbot,char_stats,json_out])
|
180 |
stop_button.click(None,None,None,cancels=[go])
|
181 |
app.launch(show_api=False)
|
182 |
|
|
|
83 |
for response in stream:
|
84 |
output += response.token.text
|
85 |
if history:
|
86 |
+
yield "",[(prompt,output)],stats,None,None
|
87 |
else:
|
88 |
+
yield "",[(prompt,output)],stats,None,None
|
89 |
generate_kwargs2 = dict(
|
90 |
temperature=temperature,
|
91 |
max_new_tokens=128,
|
|
|
105 |
lines = output.strip().strip("\n").split("\n")
|
106 |
skills=[]
|
107 |
skill_dict={}
|
108 |
+
option_drop=[]
|
109 |
new_stat="*******************\n"
|
110 |
for i,line in enumerate(lines):
|
111 |
if ":" in line:
|
|
|
113 |
try:
|
114 |
if f'{z}' in lines[i+z]:
|
115 |
print(lines[i+z].split(" ",1)[1])
|
116 |
+
option_drop.append(lines[i+z].split(" ",1)[1])
|
117 |
except Exception:
|
118 |
pass
|
119 |
if ": " in line:
|
|
|
134 |
skills.append(skill_dict)
|
135 |
new_stat+="*******************\n"
|
136 |
stats=new_stat
|
137 |
+
option_drop=gr.Dropdown(label="Choices", choices=[e for e in option_drop])
|
138 |
+
|
139 |
if history:
|
140 |
history.append((prompt,output))
|
141 |
+
yield "",history,stats,skills,option_drop
|
142 |
else:
|
143 |
+
yield "",[(prompt,output)],stats,skills,option_drop
|
144 |
|
145 |
def clear_fn():
|
146 |
return None,None
|
|
|
164 |
with gr.Row():
|
165 |
with gr.Column(scale=3):
|
166 |
prompt=gr.Textbox(label = "Prompt", value="Start a new game")
|
167 |
+
with gr.Column(scale=2):
|
168 |
button=gr.Button()
|
169 |
+
opt=gr.Dropdown(label="Choices")
|
170 |
#models_dd=gr.Dropdown(choices=[m for m in return_list],interactive=True)
|
171 |
with gr.Row():
|
172 |
stop_button=gr.Button("Stop")
|
|
|
176 |
with gr.Column(scale=1):
|
177 |
json_out=gr.JSON(value=base_stats)
|
178 |
char_stats=gr.Textbox(value=text_stats)
|
179 |
+
textboxes = []
|
180 |
+
for i in range(max_textboxes):
|
181 |
+
t = gr.Button(f"Textbox {i}")
|
182 |
+
textboxes.append(t)
|
183 |
#text=gr.JSON()
|
184 |
#inp_query.change(search_models,inp_query,models_dd)
|
185 |
#test_b=test_btn.click(itt,url,e_box)
|
186 |
clear_btn.click(clear_fn,None,[prompt,chatbot])
|
187 |
+
go=button.click(generate,[prompt,chatbot,tokens,char_stats],[prompt,chatbot,char_stats,json_out,opt])
|
188 |
stop_button.click(None,None,None,cancels=[go])
|
189 |
app.launch(show_api=False)
|
190 |
|