decula commited on
Commit ·
4f26428
1
Parent(s): 48f4118
Added stop button
Browse files
7b_rag.py
CHANGED
|
@@ -211,23 +211,39 @@ install_Frpc('7860',frpconfigfile,use_frpc)
|
|
| 211 |
# Gradio blocks
|
| 212 |
with gr.Blocks(title=title) as demo:
|
| 213 |
gr.HTML(f"<div style=\"text-align: center;\">\n<h1>RWKV-5 World v2 with RAG - {title}</h1>\n</div>")
|
| 214 |
-
with gr.Tab("
|
| 215 |
-
gr.Markdown(f"
|
| 216 |
with gr.Row():
|
| 217 |
with gr.Column():
|
| 218 |
-
prompt = gr.Textbox(lines=2, label="
|
| 219 |
-
token_count = gr.Slider(0, 20000, label="
|
| 220 |
-
temperature = gr.Slider(0.2, 2.0, label="
|
| 221 |
top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.3)
|
| 222 |
-
presence_penalty = gr.Slider(0.0, 1.0, label="
|
| 223 |
-
count_penalty = gr.Slider(0.0, 1.0, label="
|
| 224 |
with gr.Column():
|
| 225 |
with gr.Row():
|
| 226 |
-
submit = gr.Button("
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
clear.click(lambda: None, [], [output])
|
| 232 |
data.click(lambda x: x, [data], [prompt, token_count, temperature, top_p, presence_penalty, count_penalty])
|
| 233 |
|
|
|
|
| 211 |
# Gradio blocks
|
| 212 |
with gr.Blocks(title=title) as demo:
|
| 213 |
gr.HTML(f"<div style=\"text-align: center;\">\n<h1>RWKV-5 World v2 with RAG - {title}</h1>\n</div>")
|
| 214 |
+
with gr.Tab("Raw Generation"):
|
| 215 |
+
gr.Markdown(f"这是带有RAG功能的RWKV-5 World v2模型。支持100多种世界语言和代码。演示限制上下文长度为{ctx_limit}。")
|
| 216 |
with gr.Row():
|
| 217 |
with gr.Column():
|
| 218 |
+
prompt = gr.Textbox(lines=2, label="提示词", value="")
|
| 219 |
+
token_count = gr.Slider(0, 20000, label="最大Token数", step=200, value=100)
|
| 220 |
+
temperature = gr.Slider(0.2, 2.0, label="温度", step=0.1, value=1.0)
|
| 221 |
top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.3)
|
| 222 |
+
presence_penalty = gr.Slider(0.0, 1.0, label="存在惩罚", step=0.1, value=1)
|
| 223 |
+
count_penalty = gr.Slider(0.0, 1.0, label="计数惩罚", step=0.1, value=1)
|
| 224 |
with gr.Column():
|
| 225 |
with gr.Row():
|
| 226 |
+
submit = gr.Button("提交", variant="primary")
|
| 227 |
+
stop_btn = gr.Button("中断", variant="stop")
|
| 228 |
+
clear = gr.Button("清除", variant="secondary")
|
| 229 |
+
output = gr.Textbox(label="输出", lines=5)
|
| 230 |
+
data = gr.Dataset(components=[prompt, token_count, temperature, top_p, presence_penalty, count_penalty], label="示例指令", headers=["提示词", "最大Token数", "温度", "Top P", "存在惩罚", "计数惩罚"])
|
| 231 |
+
|
| 232 |
+
# 设置提交按钮事件
|
| 233 |
+
submit_event = submit.click(
|
| 234 |
+
evaluate,
|
| 235 |
+
[prompt, token_count, temperature, top_p, presence_penalty, count_penalty],
|
| 236 |
+
[output]
|
| 237 |
+
)
|
| 238 |
+
|
| 239 |
+
# 设置中断按钮事件
|
| 240 |
+
stop_btn.click(
|
| 241 |
+
fn=None,
|
| 242 |
+
inputs=None,
|
| 243 |
+
outputs=None,
|
| 244 |
+
cancels=[submit_event] # 取消正在进行的生成过程
|
| 245 |
+
)
|
| 246 |
+
|
| 247 |
clear.click(lambda: None, [], [output])
|
| 248 |
data.click(lambda x: x, [data], [prompt, token_count, temperature, top_p, presence_penalty, count_penalty])
|
| 249 |
|