kaiserpister commited on
Commit
a0f569f
·
1 Parent(s): 6eefbd7

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -38,12 +38,18 @@ def fn_to_str(x):
38
 
39
 
40
  def get_gpt_guess(clues, ask):
41
- system_message = """You are an expert mathematician. You will be given a list of input and outputs to a function and your job is to guess the output of the function on an unknown input.
42
  For example:
43
  f(2) = 6
44
  f(7) = 11
45
  What is f(3)?
46
- Answer: 7"""
 
 
 
 
 
 
47
 
48
  user_message = "\n".join(map(fn_to_str, clues)) + f"\nWhat is f({ask})?\nAnswer:"
49
  return chat([{"role": "system", "content": system_message}, {"role": "user", "content": user_message}], model=model)
@@ -79,8 +85,12 @@ with gr.Blocks() as demo:
79
  def submit_guess(value, history, clue_values):
80
  history.append(value)
81
 
82
- gpt_guess_value = get_gpt_guess(clue_values, ask)
83
- result = check_winner(int(gpt_guess_value), int(value), challenge(ask))
 
 
 
 
84
 
85
  clue = random.choice(list(available_numbers))
86
  available_numbers.remove(clue)
@@ -90,7 +100,7 @@ with gr.Blocks() as demo:
90
  return {
91
  guesses: history,
92
  history_box: ", ".join(history),
93
- gpt_guess: gpt_guess_value,
94
  clues: clue_values,
95
  title_text: title_text.value + result,
96
  clues_box: f"# Clues\n```\n{clue_str}\n```",
 
38
 
39
 
40
  def get_gpt_guess(clues, ask):
41
+ system_message = """You are an expert mathematician. You will be given a list of input and outputs to a function and your job is to guess the output of the function on an unknown input. If you cannot determine the answer, respond with 0.
42
  For example:
43
  f(2) = 6
44
  f(7) = 11
45
  What is f(3)?
46
+ Answer: 7
47
+
48
+ For example:
49
+ f(1) = 17
50
+ What is f(6)?
51
+ Answer: 0"""
52
+
53
 
54
  user_message = "\n".join(map(fn_to_str, clues)) + f"\nWhat is f({ask})?\nAnswer:"
55
  return chat([{"role": "system", "content": system_message}, {"role": "user", "content": user_message}], model=model)
 
85
  def submit_guess(value, history, clue_values):
86
  history.append(value)
87
 
88
+ try:
89
+ gpt_guess_value = int(get_gpt_guess(clue_values, ask))
90
+ except Exception:
91
+ gpt_guess_value = 0
92
+
93
+ result = check_winner(gpt_guess_value, int(value), challenge(ask))
94
 
95
  clue = random.choice(list(available_numbers))
96
  available_numbers.remove(clue)
 
100
  return {
101
  guesses: history,
102
  history_box: ", ".join(history),
103
+ gpt_guess: str(gpt_guess_value),
104
  clues: clue_values,
105
  title_text: title_text.value + result,
106
  clues_box: f"# Clues\n```\n{clue_str}\n```",