Spaces:
Runtime error
Runtime error
fix nontype errs
Browse files
app.py
CHANGED
@@ -18,13 +18,9 @@ model = GPT2LMHeadModel.from_pretrained('checkpoint-10000')
|
|
18 |
generation_config = GenerationConfig.from_pretrained('gpt2-medium')
|
19 |
generation_config.max_new_tokens = response_length
|
20 |
generation_config.pad_token_id = generation_config.eos_token_id
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
def generate_response(outputs, new_prompt):
|
26 |
|
27 |
-
story_so_far = "\n".join(outputs[:int(1024 / response_length + 1)])
|
28 |
|
29 |
set_seed(random.randint(0, 4000000000))
|
30 |
inputs = tokenizer.encode(story_so_far + '\n' + new_prompt if story_so_far else new_prompt,
|
@@ -42,10 +38,10 @@ def generate_response(outputs, new_prompt):
|
|
42 |
|
43 |
def undo(outputs):
|
44 |
|
45 |
-
outputs = outputs[:-1]
|
46 |
return {
|
47 |
user_outputs: outputs,
|
48 |
-
story: "\n".join(outputs)
|
49 |
}
|
50 |
|
51 |
def clean_paragraph(entry):
|
|
|
18 |
generation_config = GenerationConfig.from_pretrained('gpt2-medium')
|
19 |
generation_config.max_new_tokens = response_length
|
20 |
generation_config.pad_token_id = generation_config.eos_token_id
|
|
|
|
|
|
|
|
|
21 |
def generate_response(outputs, new_prompt):
|
22 |
|
23 |
+
story_so_far = "\n".join(outputs[:int(1024 / response_length + 1)]) if outputs else ""
|
24 |
|
25 |
set_seed(random.randint(0, 4000000000))
|
26 |
inputs = tokenizer.encode(story_so_far + '\n' + new_prompt if story_so_far else new_prompt,
|
|
|
38 |
|
39 |
def undo(outputs):
|
40 |
|
41 |
+
outputs = outputs[:-1] if outputs else None
|
42 |
return {
|
43 |
user_outputs: outputs,
|
44 |
+
story: "\n".join(outputs) if outputs else None
|
45 |
}
|
46 |
|
47 |
def clean_paragraph(entry):
|