Skip to content

Commit

Permalink
Merge pull request #8 from Zhou-Shilin/main
Browse files Browse the repository at this point in the history
feat: Add AI-name-generation
  • Loading branch information
Zhou-Shilin authored May 11, 2024
2 parents 7af7283 + b305382 commit 7c028bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
15 changes: 10 additions & 5 deletions console.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import uuid

from log_writer import logger
import core
Expand Down Expand Up @@ -61,13 +62,12 @@ def get_schematic_advanced(description):
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")

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

# Log user inputs
logger(f"console: input version {version}")
logger(f"console: input name {name}")
logger(f"console: input description {description}")

print("Generating...")
Expand All @@ -77,6 +77,11 @@ def get_schematic_advanced(description):
schem = get_schematic_advanced(description)
else:
schem = generate_plugin(description)

print("Schematic generated. Generating schematic name...")
raw_name = core.askgpt(config.SYS_GEN_NAME, config.USR_GEN_NAME.replace("%DESCRIPTION%", description), config.NAMING_MODEL, disable_json_mode=True)

name = raw_name + "-" + str(uuid.uuid4())

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

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

print("Generated. Get your schem file in folder generated.")
print(f"Generated with file name \"{name}.schem\". Get your schem file in folder generated.")

else:
print("Error: Please run console.py as the main program instead of importing it from another program.")
13 changes: 6 additions & 7 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def generate_schematic():
Returns:
None
"""
global name

generate_button.config(state=tk.DISABLED, text="Generating...")

if config.ADVANCED_MODE:
Expand All @@ -72,17 +74,19 @@ def generate_schematic():
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.")

version = version_entry.get()
name = name_entry.get()
description = description_entry.get()

logger(f"console: input version {version}")
logger(f"console: input name {name}")
logger(f"console: input description {description}")

if config.ADVANCED_MODE:
schem = get_schematic_advanced(description)
else:
schem = get_schematic(description)

raw_name = core.askgpt(config.SYS_GEN_NAME, config.USR_GEN_NAME.replace("%DESCRIPTION%", description), config.NAMING_MODEL, disable_json_mode=True)

name = raw_name + "-" + str(uuid.uuid4())

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

name_label = tk.Label(window, text="What's the name of your structure? It will be the name of the generated *.schem file:")
name_label.pack()
name_entry = tk.Entry(window)
name_entry.pack()

description_label = tk.Label(window, text="What kind of structure would you like to generate? Describe as clear as possible:")
description_label.pack()
description_entry = tk.Entry(window)
Expand Down

0 comments on commit 7c028bc

Please sign in to comment.