Skip to content

Commit

Permalink
fixed crash on click for some distros
Browse files Browse the repository at this point in the history
  • Loading branch information
FontaineRiant committed Nov 14, 2021
1 parent 10decab commit a025fb6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
41 changes: 34 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ def play(self):
'choices': choices
}]

action = prompt(main_menu, style=self.style)['action']
action = {}
while not action:
action = prompt(main_menu, style=self.style)
action = action['action']

if action == 'new':
self.new_prompt()
Expand Down Expand Up @@ -103,7 +106,12 @@ def new_prompt(self):
] + ['ai-generated']
}]

action = prompt(menu, style=self.style)['action']

action = {}
while not action:
action = prompt(menu, style=self.style)
action = action['action']

if action == '< Back':
return
elif action == 'custom':
Expand All @@ -118,7 +126,12 @@ def new_prompt(self):
'message': 'Type a short prompt. This is the start of your story.\n',
'name': 'prompt'
}]
custom_input = prompt(questions, style=self.style)


custom_input = {}
while not custom_input:
custom_input = prompt(questions, style=self.style)

context = custom_input['context'].strip()
custom_prompt = custom_input['prompt'].strip()
elif action == 'ai-generated':
Expand All @@ -145,7 +158,10 @@ def load_prompt(self):
key=lambda name: os.path.getmtime(os.path.join(SAVE_PATH, name + '.json')))
}]

action = prompt(menu, style=self.style)['action']
action = {}
while not action:
action = prompt(menu, style=self.style)
action = action['action']

if action != '< Back':
self.story.load(action)
Expand All @@ -156,7 +172,12 @@ def save_prompt(self):
'message': "Type a name for your save file.",
'name': 'user_input'
}]
user_input = prompt(questions, style=self.style)['user_input']

user_input = {}
while not user_input:
user_input = prompt(questions, style=self.style)
user_input = user_input['user_input']

try:
self.story.save(user_input)
print(f'Successfully saved {user_input}')
Expand Down Expand Up @@ -263,7 +284,10 @@ def loop_choice(self):
}
]

user_input = prompt(question, style=self.style)['model_name']
user_input = {}
while not user_input:
user_input = prompt(question, style=self.style)
user_input = user_input['model_name']

if user_input == '< menu >':
return
Expand Down Expand Up @@ -322,7 +346,10 @@ def model_prompt(self):
}
]

model_name = prompt(question, style=self.style)['model_name']
model_name = {}
while not model_name:
model_name = prompt(question, style=self.style)
model_name = model_name['model_name']

if model_name == '< Back':
return
Expand Down
4 changes: 2 additions & 2 deletions play.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source ./venv/Scripts/activate
source ./venv/bin/activate
python main.py --censor --model gpt-neo-2.7B-horni-ln --cputts
read -sn 1 -p "Press any key to continue..."
read -sn 1 -p "Press any key to continue..."

0 comments on commit a025fb6

Please sign in to comment.