Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions examples/app_huggingface/app.py → app_gradio/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,25 @@
def dingo_demo(dataset_source, input_path, uploaded_file, data_format, column_content, rule_list, prompt_list, model,
key, api_url):
if not data_format:
return 'ValueError: data_format can not be empty, please input.', None
raise gr.Error('ValueError: data_format can not be empty, please input.')
Comment thread
e06084 marked this conversation as resolved.
if not column_content:
return 'ValueError: column_content can not be empty, please input.', None
raise gr.Error('ValueError: column_content can not be empty, please input.')
if not rule_list and not prompt_list:
return 'ValueError: rule_list and prompt_list can not be empty at the same time.', None
raise gr.Error('ValueError: rule_list and prompt_list can not be empty at the same time.')

# Handle input path based on dataset source
if dataset_source == "hugging_face":
if not input_path:
return 'ValueError: input_path can not be empty for hugging_face dataset, please input.', None
raise gr.Error('ValueError: input_path can not be empty for hugging_face dataset, please input.')
final_input_path = input_path
else: # local
if not uploaded_file:
return 'ValueError: Please upload a file for local dataset.', None
raise gr.Error('Please upload a file for local dataset.')

file_base_name = os.path.basename(uploaded_file.name)
if not str(file_base_name).endswith(('.jsonl', '.json', '.txt')):
raise gr.Error('File format must be \'.jsonl\', \'.json\' or \'.txt\'')

final_input_path = uploaded_file.name

input_data = {
Expand All @@ -34,20 +39,19 @@ def dingo_demo(dataset_source, input_path, uploaded_file, data_format, column_co
"save_raw": True,
"data_format": data_format,
"column_content": column_content,
"custom_config":
{
"rule_list": rule_list,
"prompt_list": prompt_list,
"llm_config":
{
"detect_text_quality_detail":
{
"model": model,
"key": key,
"api_url": api_url,
}
}
}
"custom_config":{
"rule_list": rule_list,
"prompt_list": prompt_list,
"llm_config":
{
"detect_text_quality_detail":
{
"model": model,
"key": key,
"api_url": api_url,
}
}
}
}
input_args = InputArgs(**input_data)
executor = Executor.exec_map["local"](input_args)
Expand Down
File renamed without changes.