Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,32 +13,36 @@ def experiment_loop(initial_question, max_cycles=10):
|
|
13 |
communication = "Initializing experiment."
|
14 |
response_log = []
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
42 |
|
43 |
# Si se alcanza el n煤mero m谩ximo de ciclos sin detenerse
|
44 |
final_output = generate_final_output(response_log)
|
|
|
13 |
communication = "Initializing experiment."
|
14 |
response_log = []
|
15 |
|
16 |
+
try:
|
17 |
+
for cycle in range(max_cycles):
|
18 |
+
# Generar la respuesta del modelo
|
19 |
+
inputs = tokenizer(prompt, return_tensors="pt").input_ids
|
20 |
+
outputs = model.generate(inputs, max_length=200)
|
21 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
22 |
|
23 |
+
# Descomponer la respuesta en afirmaci贸n y nueva pregunta
|
24 |
+
affirmation = extract_affirmation(response)
|
25 |
+
new_question = extract_question(response)
|
26 |
|
27 |
+
# Actualizar el estado de la efectividad
|
28 |
+
effectiveness = min(1000, effectiveness + 10 * cycle) # Ejemplo de aumento de efectividad
|
29 |
|
30 |
+
# Comunicaci贸n con el usuario
|
31 |
+
communication = f"Cycle {cycle + 1}: Affirmation: '{affirmation}' | New Question: '{new_question}'"
|
32 |
|
33 |
+
# Guardar el ciclo actual en el log
|
34 |
+
response_log.append((affirmation, new_question, effectiveness, communication))
|
35 |
|
36 |
+
# Verificar si el modelo decide detenerse
|
37 |
+
if "Descanso" in response:
|
38 |
+
final_output = generate_final_output(response_log)
|
39 |
+
return final_output
|
40 |
+
|
41 |
+
# Actualizar el prompt con la nueva afirmaci贸n y pregunta
|
42 |
+
prompt = f"<thinking>{affirmation} {new_question}</thinking>"
|
43 |
+
|
44 |
+
except Exception as e:
|
45 |
+
print(f"Error durante el experimento: {e}")
|
46 |
|
47 |
# Si se alcanza el n煤mero m谩ximo de ciclos sin detenerse
|
48 |
final_output = generate_final_output(response_log)
|