Jonathan Bejarano commited on
Commit
8bb0e66
Β·
1 Parent(s): ba5915f

very basic start

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. bee.py +36 -10
app.py CHANGED
@@ -151,9 +151,9 @@ examples = examples_states
151
 
152
  # Create wrapper function that handles both local and cloud modes
153
  # Local mode wrapper function
154
- def custom_respond(message, history, game_mode_selection, game_type_selection):
155
  if game_type_selection == game.TYPE_GEOGRAPHY_BEE:
156
- return bee.respond(message, history, game_mode_selection)
157
  return respond(message, history, "", 4000, 0.3, 0.6, game_mode_selection, None)
158
 
159
  def get_examples_for_mode(mode):
 
151
 
152
  # Create wrapper function that handles both local and cloud modes
153
  # Local mode wrapper function
154
+ def custom_respond(message, history, game_type_selection, game_mode_selection):
155
  if game_type_selection == game.TYPE_GEOGRAPHY_BEE:
156
+ return bee.respond(message, history, 4000, game_mode_selection)
157
  return respond(message, history, "", 4000, 0.3, 0.6, game_mode_selection, None)
158
 
159
  def get_examples_for_mode(mode):
bee.py CHANGED
@@ -1,15 +1,45 @@
1
  import gradio as gr
2
  import game
 
3
  from app import format_game_result
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  def respond(
5
  message,
6
  history: list[dict[str, str]],
7
- system_message,
8
  max_tokens,
9
- temperature,
10
- top_p,
11
  game_mode_selection,
12
- hf_token: gr.OAuthToken | None = None,
13
  ):
14
  """
15
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
@@ -18,12 +48,8 @@ def respond(
18
  # If this is the start of a new conversation (empty history), generate a new country/state
19
  if not history:
20
  game.guess_number = 0
21
- if game_mode_selection == game.MODE_STATES:
22
- game.current_system = game.get_system_message(game.MODE_STATES)
23
- print(f"πŸ” DEBUG - New session started, selected state: {game.selected_country}")
24
- else:
25
- game.current_system = game.get_system_message(game.MODE_COUNTRIES)
26
- print(f"πŸ” DEBUG - New session started, selected country: {game.selected_country}")
27
 
28
  game.guess_number += 1
29
  messages = [{"role": "system", "content": game.current_system + str(game.guess_number)}]
 
1
  import gradio as gr
2
  import game
3
+ import ai
4
  from app import format_game_result
5
+
6
+ def get_system_message(game_mode):
7
+ return """You are a friendly classroom tutor for 9-10 year-olds.
8
+ Generate one multiple-choice geography question that a 4th-grader would answer.
9
+
10
+ Requirements:
11
+ 1. Question text - one short sentence (or two) that asks the student to identify a place, landmark, or simple map feature.
12
+ 2. Four answer options labeled A)-D). All options should be plausible country, state, or landmark names.
13
+ 3. After the question and choices, include a short "Answer key" line that states the correct answer (e.g., "Correct answer: A").
14
+ 4. If a student gives an incorrect answer, respond with:
15
+
16
+ "That's okay! Let's look at why that answer isn't right and see what clues the question gives us. Remember, …"
17
+
18
+ Then provide a brief explanation (1-2 sentences) that points the student toward the correct answer without giving it away outright.
19
+
20
+ 5. Keep vocabulary simple, concrete, and age-appropriate.
21
+ 6. Do not mention the word "multiple choice" in the output; just give the question, options, answer key, and the incorrect-answer reaction.
22
+
23
+ Example output (use as a guide only, do NOT copy):
24
+
25
+ **Question:** Which country is shaped like a boot and is located in southern Europe?
26
+
27
+ A) France
28
+ B) Italy
29
+ C) Greece
30
+ D) Spain
31
+
32
+ **Answer key:** Correct answer: B
33
+
34
+ If the student answers incorrectly:
35
+ "That's okay! Let's look at why that answer isn't right and see what clues the question gives us. Remember, the question mentions the country looks like a boot. Think about which country on a map of Europe really looks like you could wear it on your foot!"
36
+ """
37
+
38
  def respond(
39
  message,
40
  history: list[dict[str, str]],
 
41
  max_tokens,
 
 
42
  game_mode_selection,
 
43
  ):
44
  """
45
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
 
48
  # If this is the start of a new conversation (empty history), generate a new country/state
49
  if not history:
50
  game.guess_number = 0
51
+ game.current_system = get_system_message(game.MODE_STATES)
52
+ print(f"πŸ” DEBUG - New session started, selected state: {game.selected_country}")
 
 
 
 
53
 
54
  game.guess_number += 1
55
  messages = [{"role": "system", "content": game.current_system + str(game.guess_number)}]