Skip to content

Commit

Permalink
exit command correct
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanBongiorni committed Jul 13, 2023
1 parent 6397d80 commit b1938d5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions nlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def main():
Starts an infinite loop that can be broken only via Ctrl+C or by
typing "exit" as prompt.
"""

# TODO: this is an overkill - change that, pickle dict locally
_, char2idx = process_corpus()
idx2char = {v: k for k, v in char2idx.items()}
Expand All @@ -98,17 +99,15 @@ def main():
while True:
prompt = input("\nUser:\n")

# TODO: CHECK FOR EXIT BEFORE CHECK FOR INPUT LEN
if prompt.strip() == "exit":
print(config.MSG_FAREWELL)
quit()

if len(prompt) < config.INPUT_LENGTH:
print(f"Please provide a prompt of {config.INPUT_LENGTH}")

print(f"\nPlease provide a prompt of {config.INPUT_LENGTH}")
# If prompt too short send a shakespearean message
print(config.MSG_INPUT_TOO_SHORT.format(config.INPUT_LENGTH))
continue
elif prompt == "exit":
print(config.MSG_FAREWELL)
quit()
else:
generated_text = generate_text(gpt, prompt, char2idx, idx2char)
print(f"\nShakespeare-GPT:\n{generated_text}\n")
Expand Down

0 comments on commit b1938d5

Please sign in to comment.