Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
Akegarasu committed Mar 18, 2023
1 parent 4b6f715 commit 95b7944
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
6 changes: 0 additions & 6 deletions modules/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,12 @@ def limit_round(self):
self.rh = self.rh[-self.max_rounds:]

def save_history(self):
if not os.path.exists("outputs/save"):
os.mkdir("outputs/save")

s = [{"q": i[0], "o": i[1]} for i in self.history]
filename = f"history-{int(time.time())}.json"
with open(os.path.join("outputs", "save", filename), "w", encoding="utf-8") as f:
f.write(json.dumps(s, ensure_ascii=False))

def save_as_md(self):
if not os.path.exists("outputs/markdown"):
os.makedirs("outputs/markdown")

filename = f"history-{int(time.time())}.md"
output = ""
for i in self.history:
Expand Down
18 changes: 17 additions & 1 deletion webui.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import os
from modules.model import load_model
from modules.options import cmd_opts
from modules.ui import create_ui


def main():
def ensure_output_dirs():
folders = ["outputs/save", "outputs/markdown"]

def check_and_create(p):
if not os.path.exists(p):
os.makedirs(p)

for i in folders:
check_and_create(i)


def init():
ensure_output_dirs()
load_model()


def main():
ui = create_ui()
ui.launch(
server_name="0.0.0.0" if cmd_opts.listen else None,
Expand Down

0 comments on commit 95b7944

Please sign in to comment.