Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -119,7 +119,7 @@ async def rollback_last(
|
|
119 |
search_prompt = None
|
120 |
for tmp_prompt, uis in internet_search(ppm, serper_api_key, global_context, ctx_num_lconv):
|
121 |
search_prompt = tmp_prompt
|
122 |
-
yield "", prompt, uis, str(res), gr.update(interactive=False)
|
123 |
|
124 |
async for result in gen_text(
|
125 |
search_prompt if internet_option else prompt,
|
@@ -134,9 +134,9 @@ async def rollback_last(
|
|
134 |
}
|
135 |
):
|
136 |
ppm.append_pong(result)
|
137 |
-
yield prompt, ppm.build_uis(), str(res), gr.update(interactive=False)
|
138 |
|
139 |
-
yield prompt, ppm.build_uis(), str(res), gr.update(interactive=True)
|
140 |
|
141 |
def reset_chat(idx, ld, state):
|
142 |
res = [state["ppmanager_type"].from_json(json.dumps(ppm_str)) for ppm_str in ld]
|
@@ -173,7 +173,7 @@ async def chat_stream(
|
|
173 |
search_prompt = None
|
174 |
for tmp_prompt, uis in internet_search(ppm, serper_api_key, global_context, ctx_num_lconv):
|
175 |
search_prompt = tmp_prompt
|
176 |
-
yield "", prompt, uis, str(res), gr.update(interactive=False)
|
177 |
|
178 |
async for result in gen_text(
|
179 |
search_prompt if internet_option else prompt,
|
@@ -188,9 +188,9 @@ async def chat_stream(
|
|
188 |
}
|
189 |
):
|
190 |
ppm.append_pong(result)
|
191 |
-
yield "", prompt, ppm.build_uis(), str(res), gr.update(interactive=False)
|
192 |
|
193 |
-
yield "", prompt, ppm.build_uis(), str(res), gr.update(interactive=True)
|
194 |
|
195 |
def channel_num(btn_title):
|
196 |
choice = 0
|
@@ -270,6 +270,14 @@ with gr.Blocks(css=MODEL_SELECTION_CSS, theme='gradio/soft') as demo:
|
|
270 |
for channel in channels[1:]:
|
271 |
channel_btns.append(gr.Button(channel, elem_classes=["custom-btn"]))
|
272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
with gr.Column(scale=8, elem_id="right-pane"):
|
274 |
with gr.Column(
|
275 |
elem_id="initial-popup", visible=False
|
@@ -338,16 +346,6 @@ with gr.Blocks(css=MODEL_SELECTION_CSS, theme='gradio/soft') as demo:
|
|
338 |
elem_id="global-context"
|
339 |
)
|
340 |
|
341 |
-
gr.Markdown("#### Internet search")
|
342 |
-
with gr.Row():
|
343 |
-
internet_option = gr.Radio(choices=["on", "off"], value="off", label="mode")
|
344 |
-
serper_api_key = gr.Textbox(
|
345 |
-
value= os.getenv("SERPER_API_KEY"),
|
346 |
-
placeholder="Get one by visiting serper.dev",
|
347 |
-
label="Serper api key",
|
348 |
-
visible=False
|
349 |
-
)
|
350 |
-
|
351 |
gr.Markdown("#### GenConfig for **response** text generation")
|
352 |
with gr.Row():
|
353 |
res_temp = gr.Slider(0.0, 2.0, 1.0, step=0.1, label="temp", interactive=True)
|
@@ -373,7 +371,7 @@ with gr.Blocks(css=MODEL_SELECTION_CSS, theme='gradio/soft') as demo:
|
|
373 |
[idx, local_data, instruction_txtbox, chat_state,
|
374 |
global_context, res_temp, res_topk, res_rpen, res_mnts, res_sample, ctx_num_lconv,
|
375 |
internet_option, serper_api_key],
|
376 |
-
[instruction_txtbox, context_inspector, chatbot, local_data, regenerate]
|
377 |
).then(
|
378 |
None, local_data, None,
|
379 |
_js="(v)=>{ setStorage('local_data',v) }"
|
@@ -405,7 +403,7 @@ with gr.Blocks(css=MODEL_SELECTION_CSS, theme='gradio/soft') as demo:
|
|
405 |
[idx, local_data, chat_state,
|
406 |
global_context, res_temp, res_topk, res_rpen, res_mnts, res_sample, ctx_num_lconv,
|
407 |
internet_option, serper_api_key],
|
408 |
-
[context_inspector, chatbot, local_data, regenerate]
|
409 |
).then(
|
410 |
None, local_data, None,
|
411 |
_js="(v)=>{ setStorage('local_data',v) }"
|
|
|
119 |
search_prompt = None
|
120 |
for tmp_prompt, uis in internet_search(ppm, serper_api_key, global_context, ctx_num_lconv):
|
121 |
search_prompt = tmp_prompt
|
122 |
+
yield "", prompt, uis, str(res), gr.update(interactive=False), "off"
|
123 |
|
124 |
async for result in gen_text(
|
125 |
search_prompt if internet_option else prompt,
|
|
|
134 |
}
|
135 |
):
|
136 |
ppm.append_pong(result)
|
137 |
+
yield prompt, ppm.build_uis(), str(res), gr.update(interactive=False), "off"
|
138 |
|
139 |
+
yield prompt, ppm.build_uis(), str(res), gr.update(interactive=True), "off"
|
140 |
|
141 |
def reset_chat(idx, ld, state):
|
142 |
res = [state["ppmanager_type"].from_json(json.dumps(ppm_str)) for ppm_str in ld]
|
|
|
173 |
search_prompt = None
|
174 |
for tmp_prompt, uis in internet_search(ppm, serper_api_key, global_context, ctx_num_lconv):
|
175 |
search_prompt = tmp_prompt
|
176 |
+
yield "", prompt, uis, str(res), gr.update(interactive=False), "off"
|
177 |
|
178 |
async for result in gen_text(
|
179 |
search_prompt if internet_option else prompt,
|
|
|
188 |
}
|
189 |
):
|
190 |
ppm.append_pong(result)
|
191 |
+
yield "", prompt, ppm.build_uis(), str(res), gr.update(interactive=False), "off"
|
192 |
|
193 |
+
yield "", prompt, ppm.build_uis(), str(res), gr.update(interactive=True), "off"
|
194 |
|
195 |
def channel_num(btn_title):
|
196 |
choice = 0
|
|
|
270 |
for channel in channels[1:]:
|
271 |
channel_btns.append(gr.Button(channel, elem_classes=["custom-btn"]))
|
272 |
|
273 |
+
internet_option = gr.Radio(choices=["on", "off"], value="off", label="internet mode")
|
274 |
+
serper_api_key = gr.Textbox(
|
275 |
+
value= os.getenv("SERPER_API_KEY"),
|
276 |
+
placeholder="Get one by visiting serper.dev",
|
277 |
+
label="Serper api key",
|
278 |
+
visible=False
|
279 |
+
)
|
280 |
+
|
281 |
with gr.Column(scale=8, elem_id="right-pane"):
|
282 |
with gr.Column(
|
283 |
elem_id="initial-popup", visible=False
|
|
|
346 |
elem_id="global-context"
|
347 |
)
|
348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
gr.Markdown("#### GenConfig for **response** text generation")
|
350 |
with gr.Row():
|
351 |
res_temp = gr.Slider(0.0, 2.0, 1.0, step=0.1, label="temp", interactive=True)
|
|
|
371 |
[idx, local_data, instruction_txtbox, chat_state,
|
372 |
global_context, res_temp, res_topk, res_rpen, res_mnts, res_sample, ctx_num_lconv,
|
373 |
internet_option, serper_api_key],
|
374 |
+
[instruction_txtbox, context_inspector, chatbot, local_data, regenerate, internet_option]
|
375 |
).then(
|
376 |
None, local_data, None,
|
377 |
_js="(v)=>{ setStorage('local_data',v) }"
|
|
|
403 |
[idx, local_data, chat_state,
|
404 |
global_context, res_temp, res_topk, res_rpen, res_mnts, res_sample, ctx_num_lconv,
|
405 |
internet_option, serper_api_key],
|
406 |
+
[context_inspector, chatbot, local_data, regenerate, internet_option]
|
407 |
).then(
|
408 |
None, local_data, None,
|
409 |
_js="(v)=>{ setStorage('local_data',v) }"
|