tistabaulopez commited on
Commit
1c19372
verified
1 Parent(s): d858cca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -21
app.py CHANGED
@@ -13,32 +13,36 @@ def experiment_loop(initial_question, max_cycles=10):
13
  communication = "Initializing experiment."
14
  response_log = []
15
 
16
- for cycle in range(max_cycles):
17
- # Generar la respuesta del modelo
18
- inputs = tokenizer(prompt, return_tensors="pt").input_ids
19
- outputs = model.generate(inputs, max_length=200)
20
- response = tokenizer.decode(outputs[0], skip_special_tokens=True)
 
21
 
22
- # Descomponer la respuesta en afirmaci贸n y nueva pregunta
23
- affirmation = extract_affirmation(response)
24
- new_question = extract_question(response)
25
 
26
- # Actualizar el estado de la efectividad
27
- effectiveness = min(1000, effectiveness + 10 * cycle) # Ejemplo de aumento de efectividad
28
 
29
- # Comunicaci贸n con el usuario
30
- communication = f"Cycle {cycle + 1}: Affirmation: '{affirmation}' | New Question: '{new_question}'"
31
 
32
- # Guardar el ciclo actual en el log
33
- response_log.append((affirmation, new_question, effectiveness, communication))
34
 
35
- # Verificar si el modelo decide detenerse
36
- if "Descanso" in response:
37
- final_output = generate_final_output(response_log)
38
- return final_output
39
-
40
- # Actualizar el prompt con la nueva afirmaci贸n y pregunta
41
- prompt = f"<thinking>{affirmation} {new_question}</thinking>"
 
 
 
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)