Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -107,11 +107,47 @@ def preprocess_bulk_text(text: str) -> str:
|
|
107 |
|
108 |
return text
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
def process_file(file):
|
117 |
dataset = []
|
|
|
107 |
|
108 |
return text
|
109 |
|
110 |
+
def process_inputs(urls, file, text_input, model_name, batch_size, epochs):
|
111 |
+
try:
|
112 |
+
# Log the input parameters for debugging
|
113 |
+
logger.info("Processing inputs with the following parameters:")
|
114 |
+
logger.info(f"URLs: {urls}")
|
115 |
+
logger.info(f"File: {file}")
|
116 |
+
logger.info(f"Text Input: {text_input}")
|
117 |
+
logger.info(f"Model Name: {model_name}")
|
118 |
+
logger.info(f"Batch Size: {batch_size}")
|
119 |
+
logger.info(f"Epochs: {epochs}")
|
120 |
+
|
121 |
+
# Validate inputs
|
122 |
+
if not urls and not file and not text_input:
|
123 |
+
logger.error("No input data provided. Please provide at least one of URLs, file, or text input.")
|
124 |
+
return "Error: No input data provided."
|
125 |
+
|
126 |
+
# Create dataset or perform any processing logic you need
|
127 |
+
output_file = create_dataset(urls, file, text_input, model_name, batch_size, epochs)
|
128 |
+
|
129 |
+
# Log the successful creation of the dataset
|
130 |
+
logger.info(f"Dataset created successfully: {output_file}")
|
131 |
+
|
132 |
+
return output_file # Return the output file for download
|
133 |
+
|
134 |
+
except Exception as e:
|
135 |
+
logger.error(f"An error occurred while processing inputs: {e}")
|
136 |
+
return f"Error: {str(e)}" # Return error message for user feedback
|
137 |
+
|
138 |
+
# Assuming process_btn is a Gradio button
|
139 |
+
process_btn.click(
|
140 |
+
fn=process_inputs,
|
141 |
+
inputs=[
|
142 |
+
urls_input,
|
143 |
+
file_input,
|
144 |
+
text_input,
|
145 |
+
model_name,
|
146 |
+
batch_size,
|
147 |
+
epochs
|
148 |
+
],
|
149 |
+
outputs=download_output
|
150 |
+
)
|
151 |
|
152 |
def process_file(file):
|
153 |
dataset = []
|