mirror of
https://github.com/wassname/Clover-Edition.git
synced 2026-09-09 11:13:26 +08:00
added print wrapping
This commit is contained in:
+12
-1
@@ -8,7 +8,18 @@ CRED_FILE = "./AI-Adventure-2bb65e3a4e2f.json"
|
||||
|
||||
|
||||
def console_print(text, width=75):
|
||||
print(textwrap.fill(text, width))
|
||||
last_newline = 0
|
||||
i = 0
|
||||
while i < len(text):
|
||||
if text[i] == "\n":
|
||||
last_newline = 0
|
||||
elif last_newline > width:
|
||||
text = text[:i] + "\n" + text[i:]
|
||||
else:
|
||||
last_newline += 1
|
||||
i += 1
|
||||
|
||||
|
||||
|
||||
|
||||
def play_unconstrained():
|
||||
|
||||
@@ -11,8 +11,6 @@ from generator.gpt2.src import model, sample, encoder
|
||||
import json
|
||||
import numpy as np
|
||||
|
||||
tf.logging.set_verbosity(tf.logging.ERROR)
|
||||
|
||||
class GPT2Generator:
|
||||
|
||||
def __init__(self, generate_num=100, temperature=0.3, top_k=40, top_p=0.8):
|
||||
|
||||
Reference in New Issue
Block a user