KebabLover commited on
Commit
5f973f8
·
1 Parent(s): 3797534

update validation function

Browse files
Files changed (1) hide show
  1. tools/validate_final_answer.py +6 -0
tools/validate_final_answer.py CHANGED
@@ -8,7 +8,13 @@ class ValidateFinalAnswer(Tool):
8
  inputs = {'answer': {'type': 'any', 'description': 'The final answer to the problem to be validate'}}
9
  output_type = "any"
10
 
 
11
  def forward(self, answer: Any) -> Any:
 
 
 
 
 
12
  try:
13
  compile(answer, "bogusfile.py", "exec")
14
  # os.remove("bogusfile.py")
 
8
  inputs = {'answer': {'type': 'any', 'description': 'The final answer to the problem to be validate'}}
9
  output_type = "any"
10
 
11
+
12
  def forward(self, answer: Any) -> Any:
13
+ BAN_FUNC = [ "st.chat_input", "chat_message", "set_page_config", "st.sidebar"]
14
+ for func in BAN_FUNC:
15
+ if answer.find(func) != -1:
16
+ print(f"Invalid answer : {func} is not an allowed function")
17
+ return f"Invalid answer : {func} is not an allowed function"
18
  try:
19
  compile(answer, "bogusfile.py", "exec")
20
  # os.remove("bogusfile.py")