acecalisto3 commited on
Commit
83b1e97
·
verified ·
1 Parent(s): 32defef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -5
app.py CHANGED
@@ -107,11 +107,47 @@ def preprocess_bulk_text(text: str) -> str:
107
 
108
  return text
109
 
110
- # Example usage:
111
- def process_input(text: str) -> List[str]:
112
- """Process input text and return list of items"""
113
- processed_text = preprocess_bulk_text(text)
114
- return [item.strip() for item in processed_text.split(',') if item.strip()]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = []