feat(frontend): 添加数据集生成轮次控制功能
- 在数据集生成页面添加"生成轮次"输入框,支持设置生成轮数 - 更新生成逻辑,根据设置的轮次进行多次生成
This commit is contained in:
parent
961a017f19
commit
86bcf90c66
@ -57,9 +57,18 @@ def dataset_generate_page():
|
|||||||
)
|
)
|
||||||
api_choice = gr.State(value=initial_api)
|
api_choice = gr.State(value=initial_api)
|
||||||
|
|
||||||
output_text = gr.Textbox(label="生成结果", interactive=False)
|
rounds_input = gr.Number(
|
||||||
|
value=1,
|
||||||
|
label="生成轮次",
|
||||||
|
minimum=1,
|
||||||
|
maximum=100,
|
||||||
|
step=1,
|
||||||
|
interactive=True
|
||||||
|
)
|
||||||
generate_button = gr.Button("生成数据集",variant="primary")
|
generate_button = gr.Button("生成数据集",variant="primary")
|
||||||
|
|
||||||
|
output_text = gr.Textbox(label="生成结果", interactive=False)
|
||||||
|
|
||||||
with gr.Column(scale=2):
|
with gr.Column(scale=2):
|
||||||
variables_dataframe = gr.Dataframe(
|
variables_dataframe = gr.Dataframe(
|
||||||
headers=["变量名", "变量值"],
|
headers=["变量名", "变量值"],
|
||||||
@ -88,7 +97,7 @@ def dataset_generate_page():
|
|||||||
dataframe_value = [] if input_variables is None else input_variables
|
dataframe_value = [] if input_variables is None else input_variables
|
||||||
return selected_prompt, dataframe_value
|
return selected_prompt, dataframe_value
|
||||||
|
|
||||||
def on_generate_click(doc_state, prompt_state, api_state, variables_dataframe, progress=gr.Progress()):
|
def on_generate_click(doc_state, prompt_state, api_state, variables_dataframe, rounds, progress=gr.Progress()):
|
||||||
variables_dict = {}
|
variables_dict = {}
|
||||||
# 正确遍历DataFrame的行数据
|
# 正确遍历DataFrame的行数据
|
||||||
for _, row in variables_dataframe.iterrows():
|
for _, row in variables_dataframe.iterrows():
|
||||||
@ -98,7 +107,7 @@ def dataset_generate_page():
|
|||||||
variables_dict[var_name] = var_value
|
variables_dict[var_name] = var_value
|
||||||
|
|
||||||
import time
|
import time
|
||||||
total_steps = 10
|
total_steps = rounds
|
||||||
for i in range(total_steps):
|
for i in range(total_steps):
|
||||||
# 模拟每个步骤的工作负载
|
# 模拟每个步骤的工作负载
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
@ -117,7 +126,7 @@ def dataset_generate_page():
|
|||||||
|
|
||||||
generate_button.click(
|
generate_button.click(
|
||||||
on_generate_click,
|
on_generate_click,
|
||||||
inputs=[doc_choice, prompt_choice, api_choice, variables_dataframe],
|
inputs=[doc_choice, prompt_choice, api_choice, variables_dataframe, rounds_input],
|
||||||
outputs=output_text
|
outputs=output_text
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user