Update app.py
Browse files
app.py
CHANGED
@@ -104,17 +104,33 @@ def load_and_train():
|
|
104 |
"""
|
105 |
texts = []
|
106 |
# Determinar el tamaño del lote
|
107 |
-
|
108 |
|
109 |
-
for i in range(
|
110 |
text = ''
|
111 |
-
if 'dialog' in examples and
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
text =
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|