# -*- coding: utf-8 -*-
"""Talk to /mlp/.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1MuhbJsPC1Z0OBO9NJxO8bhRVpG2-YH45

# Talk to /mlp/ - Pony
This is a Colab notebook with a GPT-2 text generating model trained on a 100MB worth of a dump of /mlp/'s posts from its inception to June 2019. Open this in playground mode (button at the top left). Follow the instructions or you're a faggot

## Setup
Click the button on its left to run a cell. Run this cell only once and wait a bit for it to set up the model.
"""

# Commented out IPython magic to ensure Python compatibility.
# %tensorflow_version 1.x
!pip install -q gpt-2-simple
import gpt_2_simple as gpt2
from datetime import datetime
from google.colab import files
import os 
import shutil 
#@markdown RUN THIS ONLY ONCE
def safemkdir(dirn):
  if not os.path.isdir(dirn):
    os.mkdir(dirn)

safemkdir("checkpoint")
os.chdir("checkpoint")
safemkdir("run1")
os.chdir("run1")

print("downloading model, please wait...")
!gdown --id 1005XgaUmY1mTp3WztWE4I8NmUCsFSEZw
print("big file downloaded")
!gdown --id 100xxNUNHf5LYwzSfOKFFLLgwN2ueMy3E
!gdown --id 103A4Td9Nv1a15rICUVNaOti4T8JyJzlx
!gdown --id 1-Aodz1xNxy8oiwp3sZk2uUwyfspSWMJ3
!gdown --id 1-IVYe2vDsnuqxMTUeN7HneKlN1GW3njn
!gdown --id 1-DhVI8DTjcT5t06uCYPiXmHR-V0v-2B9
!gdown --id 1-UdJ6yjnLVuUGFXYqxuYpD0NzHPXoBgn

os.chdir("/content/checkpoint/run1")
with open("checkpoint","w") as chkpf:
  chkpf.write("model_checkpoint_path: \"/content/checkpoint/run1/model-30000\"\n")
  chkpf.write("all_model_checkpoint_paths: \"/content/checkpoint/run1/model-30000\"\n")

os.chdir("/content")
sess = gpt2.start_tf_sess()
gpt2.load_gpt2(sess, run_name='run1')
print("Ready to generate!!!!11")

"""##Generate
You can either give it a prompt or leave it empty for random output. Run this cell.

It really likes writing green for some reason.
"""

Prompt = ">rape" #@param {type:"string"}
gpt2.generate(sess,prefix=Prompt, run_name='run1')