Skip to content

Commit

Permalink
feat: Update progress bar while generating & rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhou-Shilin committed Jun 21, 2024
1 parent f94286e commit 5093f1f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 281 deletions.
9 changes: 9 additions & 0 deletions browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ def set_progress(progress):
progress_bar.set(progress)

browser = playwright.chromium.launch(headless=True)

set_progress(25)

context = browser.new_context()

set_progress(30)

page = context.new_page()

set_progress(35)

page.goto(config.RENDERING_URL)

set_progress(40)
Expand Down
4 changes: 2 additions & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RENDERING_URL: "https://beta.cubical.xyz/" # Don't change this unless you know w

# DEVELOPER SETTINGS #
DEBUG_MODE: False
VERSION_NUMBER: "2.0.0" # NEVER EDIT THIS IF YOU DON'T KNOW WHAT ARE YOU DOING
VERSION_NUMBER: "2.0.0" #NEVER EDIT THIS IF YOU DON'T KNOW WHAT ARE YOU DOING

# PROMPT SETTINGS #
# If you don't know what it is, please don't touch it. Be sure to backup before editing.
Expand Down Expand Up @@ -284,7 +284,7 @@ SYS_GEN: |
}
]
}
Never response anything else. Do not design a building which is too large (more than 10 floors). Never use markdown format. Use \n for line feed.
Never response anything else. The schematic can be as large as 25*25*50 or even bigger. Never use markdown format. Use \n for line feed.
USR_GEN: |
%DESCRIPTION%
Expand Down
278 changes: 0 additions & 278 deletions ui-v2.py

This file was deleted.

20 changes: 19 additions & 1 deletion ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import os
import shutil
import uuid
import time
import threading

from log_writer import logger, get_log_filename
import config
Expand All @@ -22,11 +24,18 @@ def get_schematic(description, progressbar):
Returns:
mcschematic.MCSchematic: The generated schematic.
"""
progressbar.set(20)
# 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.start()

response = core.askgpt(config.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()

schem = core.text_to_schem(response)
progressbar.set(100)

Expand Down Expand Up @@ -161,6 +170,15 @@ def export_log(args: dict):

return True

def update_progress_bar(progressbar, start, end, interval):
current = start
while current < end:
time.sleep(interval)
current += 1
progressbar.set(current)
if current >= end:
break

def open_config(args: dict):
"""
Opens the config file.
Expand Down

0 comments on commit 5093f1f

Please sign in to comment.