Merge pull request #1 from nickwalton/new-master

New master
This commit is contained in:
Nick Walton authored and GitHub committed 2019-04-08 13:44:05 -06:00
commit 5ee1dc695e
29 files changed
+40 -35

No files matched your search

+1 -3
View File
@@ -1,4 +1,2 @@
__pychache__/*
gpt2/__pycache__/*
**/__pychache__
gpt2/models/*
regex
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -13,7 +13,7 @@ pos_action_starts = ["You attack", "You tell", "You use", "You go"]
class StoryGenerator():
def __init__(self, sess, length=80, temperature=0.9, top_k=40):
def __init__(self, sess, length=75, temperature=0.9, top_k=40):
seed = None
batch_size=1
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
View File
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5 -4
View File
@@ -30,6 +30,8 @@ from flask import Flask, render_template, request
app = Flask(__name__)
phrases = [" You attack", " You use", " You tell", " You use"]
session = None
generator = None
@@ -44,16 +46,15 @@ def root():
def story_request():
print("****Generating Story****")
prompt = request.form["prompt"] # given prompt
phrase = request.form["phrase"]
gen_actions = request.form["actions"] # given prompt
print("\n Given prompt is: \n",prompt," ", phrase,"\n")
print("\n Given prompt is: \n",prompt," ","\n")
generator = get_generator()
if gen_actions == "true":
action, result = generator.generate_action_result(prompt, phrase)
response = json.dumps([action, result])
action_results = [generator.generate_action_result(prompt, phrase) for phrase in phrases]
response = json.dumps(action_results)
else:
response = generator.generate_story_block(prompt)
+33 -27
View File
@@ -20,7 +20,7 @@ var StoryTracker = {
getFirstStory:function(){
console.log("Requesting first story")
Typer.appendToText(initial_prompt)
StoryTracker.requestStory(initial_prompt, "None")
StoryTracker.requestStory(initial_prompt)
},
@@ -36,26 +36,33 @@ var StoryTracker = {
},
addNextAction:function(action_result){
var action_result = JSON.parse(action_result)
action = action_result[0]
result = action_result[1]
StoryTracker.actions.push(action)
StoryTracker.results.push(result)
var print_action = "\n" + String(StoryTracker.action_int) + ") " + action
StoryTracker.action_int += 1
Typer.appendToText(print_action)
var action_results = JSON.parse(action_result)
for (i = 0; i < 4; i++){
action_result = action_results[i]
if (StoryTracker.action_int > 3){
Typer.appendToText("\nWhich action do you choose? ")
StoryTracker.action_int = 0
acceptInput = true
action = action_result[0]
result = action_result[1]
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
setTimeout(StoryTracker.mobileButton, 1000);
StoryTracker.actions.push(action)
StoryTracker.results.push(result)
var print_action = "\n" + String(StoryTracker.action_int) + ") " + action
StoryTracker.action_int += 1
Typer.appendToText(print_action)
if (StoryTracker.action_int > 3){
Typer.appendToText("\nWhich action do you choose? ")
StoryTracker.action_int = 0
acceptInput = true
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
setTimeout(StoryTracker.mobileButton, 1000);
}
}
}
},
@@ -76,19 +83,18 @@ var StoryTracker = {
StoryTracker.actions = []
StoryTracker.results = []
for (i = 0; i < 4; i++){
StoryTracker.requestAction(prompt, action_list[i])
}
StoryTracker.requestAction(prompt)
},
requestStory:function(prompt, phrase){
$.post("/generate", {actions: false, prompt, phrase},
requestStory:function(prompt){
$.post("/generate", {actions: false, prompt},
StoryTracker.addNextStory)
},
requestAction:function(prompt, phrase){
$.post("/generate", {actions: true, prompt, phrase},
requestAction:function(prompt){
$.post("/generate", {actions: true, prompt},
StoryTracker.addNextAction)
},
@@ -101,7 +107,7 @@ var StoryTracker = {
StoryTracker.lastAction = StoryTracker.actions[choice_int]
StoryTracker.lastStory = StoryTracker.results[choice_int]
StoryTracker.makeActionRequests(StoryTracker.firstStory + StoryTracker.lastStory)
Typer.appendToText("\n\n")
Typer.appendToText("\n")
Typer.appendToText(StoryTracker.lastStory)
Typer.appendToText("\n\nOptions:")
}
@@ -187,7 +193,7 @@ function writeAppend(str){
function startTyping(){
addTextTimer = setInterval("typeWords()", 40)
addTextTimer = setInterval("typeWords()", 50)
}