DataEval commited on
Commit
55b7ba9
·
verified ·
1 Parent(s): 30b656c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -20
app.py CHANGED
@@ -5,15 +5,15 @@ from dingo.exec import Executor
5
  from dingo.io import InputArgs
6
 
7
 
8
- def dingo_demo(input_path, data_format, column_content, input_rules, input_prompts, key, api_url):
9
  if not input_path:
10
  return 'ValueError: input_path can not be empty, please input.'
11
  if not data_format:
12
  return 'ValueError: data_format can not be empty, please input.'
13
  if not column_content:
14
  return 'ValueError: column_content can not be empty, please input.'
15
- if not input_rules and not input_prompts:
16
- return 'ValueError: input_rules and input_prompts can not be empty at the same time.'
17
 
18
  input_data = {
19
  "input_path": input_path,
@@ -21,8 +21,8 @@ def dingo_demo(input_path, data_format, column_content, input_rules, input_promp
21
  "column_content": column_content,
22
  "custom_config":
23
  {
24
- "rule_list": input_rules,
25
- "prompt_list": input_prompts,
26
  "llm_config":
27
  {
28
  "detect_text_quality_detail":
@@ -44,19 +44,30 @@ if __name__ == '__main__':
44
  rule_options = ['RuleAbnormalChar', 'RuleAbnormalHtml', 'RuleContentNull', 'RuleContentShort', 'RuleEnterAndSpace', 'RuleOnlyUrl']
45
  prompt_options = ['PromptRepeat', 'PromptContentChaos']
46
 
47
- #接口创建函数
48
- #fn设置处理函数,inputs设置输入接口组件,outputs设置输出接口组件
49
- #fn,inputs,outputs都是必填函数
50
- demo = gr.Interface(
51
- fn=dingo_demo,
52
- inputs=[
53
- gr.Textbox(value='chupei/format-jsonl', placeholder="please input huggingface dataset path"),
54
- gr.Dropdown(["jsonl", "json", "plaintext", "listjson"], label="data_format"),
55
- gr.Textbox(value="content", placeholder="please input column name of content in dataset"),
56
- gr.CheckboxGroup(choices=rule_options, label="rule_list"),
57
- gr.CheckboxGroup(choices=prompt_options, label="prompt_list"),
58
- 'text',
59
- 'text',
60
- ],
61
- outputs="text")
 
 
 
 
 
 
 
 
 
 
 
62
  demo.launch()
 
5
  from dingo.io import InputArgs
6
 
7
 
8
+ def dingo_demo(input_path, data_format, column_content, rule_list, prompt_list, key, api_url):
9
  if not input_path:
10
  return 'ValueError: input_path can not be empty, please input.'
11
  if not data_format:
12
  return 'ValueError: data_format can not be empty, please input.'
13
  if not column_content:
14
  return 'ValueError: column_content can not be empty, please input.'
15
+ if not rule_list and not prompt_list:
16
+ return 'ValueError: rule_list and prompt_list can not be empty at the same time.'
17
 
18
  input_data = {
19
  "input_path": input_path,
 
21
  "column_content": column_content,
22
  "custom_config":
23
  {
24
+ "rule_list": rule_list,
25
+ "prompt_list": prompt_list,
26
  "llm_config":
27
  {
28
  "detect_text_quality_detail":
 
44
  rule_options = ['RuleAbnormalChar', 'RuleAbnormalHtml', 'RuleContentNull', 'RuleContentShort', 'RuleEnterAndSpace', 'RuleOnlyUrl']
45
  prompt_options = ['PromptRepeat', 'PromptContentChaos']
46
 
47
+ with open("header.html", "r") as file:
48
+ header = file.read()
49
+ with gr.Blocks() as demo:
50
+ gr.HTML(header)
51
+ with gr.Row():
52
+ with gr.Column():
53
+ input_path = gr.Textbox(value='chupei/format-jsonl', placeholder="please input huggingface dataset path", label="input_path")
54
+ data_format = gr.Dropdown(["jsonl", "json", "plaintext", "listjson"], label="data_format")
55
+ column_content = gr.Textbox(value="content", placeholder="please input column name of content in dataset", label="column_content")
56
+ rule_list = gr.CheckboxGroup(choices=rule_options, label="rule_list")
57
+ prompt_list = gr.CheckboxGroup(choices=prompt_options, label="prompt_list")
58
+ key = gr.Textbox(placeholder="If want to use llm, please input the key of it.", label="key")
59
+ api_url = gr.Textbox(placeholder="If want to use llm, please input the api_url of it.", label="api_url")
60
+ with gr.Row():
61
+ submit_single = gr.Button(value="Submit", interactive=True, variant="primary")
62
+ with gr.Column():
63
+ # 输出组件
64
+ output = gr.Textbox(label="output")
65
+
66
+ submit_single.click(
67
+ fn=dingo_demo,
68
+ inputs=[input_path, data_format, column_content, rule_list, prompt_list, key, api_url],
69
+ outputs=output
70
+ )
71
+
72
+ # 启动界面
73
  demo.launch()