Skip to content

Commit

Permalink
Merge pull request #28 from Zhou-Shilin/feat-force-nojson
Browse files Browse the repository at this point in the history
Force disable json mode
  • Loading branch information
Zhou-Shilin authored Jun 30, 2024
2 parents eccf69c + 1979c0b commit 03dff35
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ BASE_URL: "https://api.openai.com/v1/chat/completions"

GENERATE_MODEL: "gpt-4-turbo" # Don't use gpt-4, because this model is longer supports json modes.

FORCE_DISABLE_JSON_MODE: True # For openai-formatting claude users.

# ADVANCED MODE #
# This mode is experimental. This will enrich the aesthetics of the generated structure, but may affect the quality of the output to some extent. It also consumes more tokens when this mode is turned on, but we still recommend turning it on.
Expand Down
2 changes: 1 addition & 1 deletion core.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def askgpt(system_prompt: str, user_prompt: str, model_name: str, disable_json_m
logger(f"askgpt: user {user_prompt}")

# Create a chat completion
if disable_json_mode:
if disable_json_mode or config.FORCE_DISABLE_JSON_MODE:
response = client.chat.completions.create(
model=model_name,
messages=messages,
Expand Down
7 changes: 2 additions & 5 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_schematic(description, progressbar):
mcschematic.MCSchematic: The generated schematic.
"""
# Start the progress bar update in a separate thread
progress_thread = threading.Thread(target=update_progress_bar, args=(progressbar, 20, 80, 0.75))
progress_thread = threading.Thread(target=update_progress_bar, args=(progressbar, 0, 95, 0.75))
progress_thread.start()

if config.GIVE_GPT_BLOCK_ID_LIST:
Expand All @@ -37,14 +37,11 @@ def get_schematic(description, progressbar):

response = core.askgpt(sys_gen, config.USR_GEN.replace("%DESCRIPTION%", description), config.GENERATE_MODEL)

# Ensure progress reaches 80% once askgpt completes
progressbar.set(80)

# Wait for the progress thread to finish
progress_thread.join()

# Ensure progress reaches 80% once askgpt completes
progressbar.set(80)
progressbar.set(95)

# Wait for the progress thread to finish
progress_thread.join()
Expand Down

0 comments on commit 03dff35

Please sign in to comment.