Skip to content

Commit 7c028bc

Browse files
authored
Merge pull request #8 from Zhou-Shilin/main
feat: Add AI-name-generation
2 parents 7af7283 + b305382 commit 7c028bc

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

console.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import uuid
23

34
from log_writer import logger
45
import core
@@ -61,13 +62,12 @@ def get_schematic_advanced(description):
6162
print("Welcome to BuilderGPT, an open source, free, AI-powered Minecraft structure generator developed by BaimoQilin (@Zhou-Shilin). Don't forget to check out the config.yaml configuration file, you need to fill in the OpenAI API key.\n")
6263

6364
# Get user inputs
64-
version = input("[0/2] What's your minecraft version? (eg. 1.20.1): ")
65-
name = input("[1/2] What's the name of your structure? It will be the name of the generated *.schem file: ")
66-
description = input("[2/2] What kind of structure would you like to generate? Describe as clear as possible: ")
65+
version = input("[0/3] What's your minecraft version? (eg. 1.20.1): ")
66+
description = input("[1/3] What kind of structure would you like to generate? Describe as clear as possible: ")
67+
render = input("[2/3] Do you want to render the structure? (y/n): ")
6768

6869
# Log user inputs
6970
logger(f"console: input version {version}")
70-
logger(f"console: input name {name}")
7171
logger(f"console: input description {description}")
7272

7373
print("Generating...")
@@ -77,6 +77,11 @@ def get_schematic_advanced(description):
7777
schem = get_schematic_advanced(description)
7878
else:
7979
schem = generate_plugin(description)
80+
81+
print("Schematic generated. Generating schematic name...")
82+
raw_name = core.askgpt(config.SYS_GEN_NAME, config.USR_GEN_NAME.replace("%DESCRIPTION%", description), config.NAMING_MODEL, disable_json_mode=True)
83+
84+
name = raw_name + "-" + str(uuid.uuid4())
8085

8186
logger(f"console: Saving {name}.schem to generated/ folder.")
8287
version_tag = core.input_version_to_mcs_tag(version)
@@ -89,7 +94,7 @@ def get_schematic_advanced(description):
8994

9095
schem.save("generated", name, version_tag)
9196

92-
print("Generated. Get your schem file in folder generated.")
97+
print(f"Generated with file name \"{name}.schem\". Get your schem file in folder generated.")
9398

9499
else:
95100
print("Error: Please run console.py as the main program instead of importing it from another program.")

ui.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def generate_schematic():
6464
Returns:
6565
None
6666
"""
67+
global name
68+
6769
generate_button.config(state=tk.DISABLED, text="Generating...")
6870

6971
if config.ADVANCED_MODE:
@@ -72,17 +74,19 @@ def generate_schematic():
7274
msgbox.showinfo("Info", "It is expected to take 30 seconds to 5 minutes. The programme may \"not responding\", this is normal, just be patient. DO NOT CLOSE THE PROGRAM. Click the button below to start generating.")
7375

7476
version = version_entry.get()
75-
name = name_entry.get()
7677
description = description_entry.get()
7778

7879
logger(f"console: input version {version}")
79-
logger(f"console: input name {name}")
8080
logger(f"console: input description {description}")
8181

8282
if config.ADVANCED_MODE:
8383
schem = get_schematic_advanced(description)
8484
else:
8585
schem = get_schematic(description)
86+
87+
raw_name = core.askgpt(config.SYS_GEN_NAME, config.USR_GEN_NAME.replace("%DESCRIPTION%", description), config.NAMING_MODEL, disable_json_mode=True)
88+
89+
name = raw_name + "-" + str(uuid.uuid4())
8690

8791
logger(f"console: Saving {name}.schem to generated/ folder.")
8892
version_tag = core.input_version_to_mcs_tag(version)
@@ -137,11 +141,6 @@ def Application():
137141
version_entry = tk.Entry(window)
138142
version_entry.pack()
139143

140-
name_label = tk.Label(window, text="What's the name of your structure? It will be the name of the generated *.schem file:")
141-
name_label.pack()
142-
name_entry = tk.Entry(window)
143-
name_entry.pack()
144-
145144
description_label = tk.Label(window, text="What kind of structure would you like to generate? Describe as clear as possible:")
146145
description_label.pack()
147146
description_entry = tk.Entry(window)

0 commit comments

Comments
 (0)