Yhhxhfh commited on
Commit
57c7d28
1 Parent(s): 805d7ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -9
app.py CHANGED
@@ -104,17 +104,33 @@ def load_and_train():
104
  """
105
  texts = []
106
  # Determinar el tamaño del lote
107
- num_examples = len(next(iter(examples.values()))) # Obtener el tamaño del lote
108
 
109
- for i in range(num_examples):
110
  text = ''
111
- if 'dialog' in examples and i < len(examples['dialog']) and examples['dialog'][i]:
112
- text = examples['dialog'][i]
113
- elif 'whole_func_string' in examples and i < len(examples['whole_func_string']) and examples['whole_func_string'][i]:
114
- text = examples['whole_func_string'][i]
115
- elif 'func_documentation_string' in examples and i < len(examples['func_documentation_string']) and examples['func_documentation_string'][i]:
116
- text = examples['func_documentation_string'][i]
117
- # Puedes añadir más campos si es necesario
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  texts.append(text)
119
 
120
  examples['text'] = texts
 
104
  """
105
  texts = []
106
  # Determinar el tamaño del lote
107
+ batch_size = len(next(iter(examples.values())))
108
 
109
+ for i in range(batch_size):
110
  text = ''
111
+ if 'dialog' in examples and examples['dialog'][i]:
112
+ # Verificar si el campo es una lista y concatenar si es necesario
113
+ dialog = examples['dialog'][i]
114
+ if isinstance(dialog, list):
115
+ dialog = ' '.join(dialog)
116
+ text = dialog
117
+ elif 'whole_func_string' in examples and examples['whole_func_string'][i]:
118
+ whole_func = examples['whole_func_string'][i]
119
+ if isinstance(whole_func, list):
120
+ whole_func = ' '.join(whole_func)
121
+ text = whole_func
122
+ elif 'func_documentation_string' in examples and examples['func_documentation_string'][i]:
123
+ func_doc = examples['func_documentation_string'][i]
124
+ if isinstance(func_doc, list):
125
+ func_doc = ' '.join(func_doc)
126
+ text = func_doc
127
+ else:
128
+ text = '' # Asignar cadena vacía si no hay texto disponible
129
+
130
+ # Asegurar que 'text' es una cadena de texto
131
+ if not isinstance(text, str):
132
+ text = str(text)
133
+
134
  texts.append(text)
135
 
136
  examples['text'] = texts