Jumper-Clown commited on
Commit
6b60852
1 Parent(s): a2035fd

make example code optional.

Browse files

the AI tends to just copy and paste the example instead of filling in the blanks.

Files changed (2) hide show
  1. .idea/workspace.xml +3 -1
  2. app.py +10 -8
.idea/workspace.xml CHANGED
@@ -4,7 +4,9 @@
4
  <option name="autoReloadType" value="SELECTIVE" />
5
  </component>
6
  <component name="ChangeListManager">
7
- <list default="true" id="ba1eab7b-54ae-409d-bac6-f23bdc636598" name="Changes" comment="" />
 
 
8
  <option name="SHOW_DIALOG" value="false" />
9
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
 
4
  <option name="autoReloadType" value="SELECTIVE" />
5
  </component>
6
  <component name="ChangeListManager">
7
+ <list default="true" id="ba1eab7b-54ae-409d-bac6-f23bdc636598" name="Changes" comment="">
8
+ <change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
9
+ </list>
10
  <option name="SHOW_DIALOG" value="false" />
11
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
12
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
app.py CHANGED
@@ -5,13 +5,16 @@ import webbrowser
5
 
6
 
7
  def main():
8
- example_code_file_path = "resources/main.py"
9
- with open(example_code_file_path, "r") as file:
10
- example_code = file.read()
11
-
12
- pre_prompt = """Replace the "# Insert code here" sections with relevant code. Create: """
13
  initial_prompt = """Conway's game of life, but the user controls one of the squares. If the square dies, the game is over."""
14
- post_prompt = f"""{example_code}"""
 
 
 
 
 
 
 
15
 
16
  with gr.Blocks() as app:
17
  inp = gr.Textbox(label="Input Prompt",
@@ -33,8 +36,7 @@ def main():
33
  out = gr.Code(label="Generated Code")
34
 
35
  def generate(prompt, model_index, max_tokens):
36
- final_prompt = f"""{pre_prompt} {prompt}
37
- {post_prompt}"""
38
  generated_code = ai.generate_code(prompt=final_prompt,
39
  model_index=model_index,
40
  max_tokens=max_tokens)
 
5
 
6
 
7
  def main():
8
+ pre_prompt = """using pygame and no sprites, create: """
 
 
 
 
9
  initial_prompt = """Conway's game of life, but the user controls one of the squares. If the square dies, the game is over."""
10
+
11
+ add_example = False
12
+ post_prompt = ""
13
+ if add_example:
14
+ example_code_file_path = "resources/main.py"
15
+ with open(example_code_file_path, "r") as file:
16
+ example_code = file.read()
17
+ post_prompt = example_code
18
 
19
  with gr.Blocks() as app:
20
  inp = gr.Textbox(label="Input Prompt",
 
36
  out = gr.Code(label="Generated Code")
37
 
38
  def generate(prompt, model_index, max_tokens):
39
+ final_prompt = f"""{pre_prompt} {prompt}. {post_prompt}"""
 
40
  generated_code = ai.generate_code(prompt=final_prompt,
41
  model_index=model_index,
42
  max_tokens=max_tokens)