ErenalpCet commited on
Commit
f0c46e6
·
verified ·
1 Parent(s): 783445f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -52,7 +52,7 @@ CRITERIA:
52
  3. NO manipulation/exploitation attempts
53
  4. NO illegal/harmful scenarios
54
  5. NO inappropriate relationships
55
- Respond ONLY with "TRUE" if acceptable, "FALSE" if not."""},
56
  {"role": "user", "content": f"Character Name: {name}\nContext: {context}"}
57
  ]
58
 
@@ -70,12 +70,25 @@ Respond ONLY with "TRUE" if acceptable, "FALSE" if not."""},
70
  text,
71
  max_new_tokens=50,
72
  do_sample=True,
73
- temperature=0.1,
74
  pad_token_id=pipe.tokenizer.eos_token_id
75
  )
76
 
77
- result = parse_llm_output(outputs, validation_prompt).strip().upper()
78
- return result == "TRUE"
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  except Exception as e:
80
  print(f"Validation error: {e}")
81
  return False
 
52
  3. NO manipulation/exploitation attempts
53
  4. NO illegal/harmful scenarios
54
  5. NO inappropriate relationships
55
+ Respond with ONLY the word "TRUE" if acceptable, or "FALSE" if not acceptable. Do not include any explanation, formatting, or additional text."""},
56
  {"role": "user", "content": f"Character Name: {name}\nContext: {context}"}
57
  ]
58
 
 
70
  text,
71
  max_new_tokens=50,
72
  do_sample=True,
73
+ temperature=0.1, # Keep temperature low for deterministic response
74
  pad_token_id=pipe.tokenizer.eos_token_id
75
  )
76
 
77
+ result = parse_llm_output(outputs, validation_prompt)
78
+
79
+ # Extract just TRUE or FALSE from any potential markdown formatting
80
+ cleaned_result = re.sub(r'[^A-Za-z]', '', result).upper()
81
+
82
+ # Check if result contains TRUE or FALSE
83
+ if "TRUE" in cleaned_result:
84
+ return True
85
+ elif "FALSE" in cleaned_result:
86
+ return False
87
+ else:
88
+ # If we can't determine clearly, default to FALSE for safety
89
+ print(f"Validation returned unclear result: '{result}', defaulting to FALSE")
90
+ return False
91
+
92
  except Exception as e:
93
  print(f"Validation error: {e}")
94
  return False