Update app.py
Browse files
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,
|
| 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
|
| 16 |
-
return 'ValueError:
|
| 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":
|
| 25 |
-
"prompt_list":
|
| 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 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|