mirror of
https://github.com/wassname/Clover-Edition.git
synced 2026-09-09 11:13:26 +08:00
caching works
This commit is contained in:
@@ -32,7 +32,7 @@ bucket = storage_client.get_bucket("dungeon-cache")
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
phrases = [" You attack", " You use", " You tell", " You use"]
|
||||
phrases = [" You attack", " You use", " You tell", " You go"]
|
||||
prompts = ["You enter a dungeon with your trusty sword and shield. You are searching for the evil necromancer who killed your family. You've heard that he resides at the bottom of the dungeon, guarded by legions of the undead. You enter the first door and see"]
|
||||
|
||||
session = None
|
||||
@@ -49,7 +49,7 @@ def cache_file(seed, prompt_num, choices, response, tag):
|
||||
|
||||
blob_file_name = "p" + str(prompt_num) + "/seed" + str(seed) + "/" + tag
|
||||
for action in choices:
|
||||
blob_file_name + str(action)
|
||||
blob_file_name = blob_file_name + str(action)
|
||||
blob = bucket.blob(blob_file_name)
|
||||
|
||||
blob.upload_from_string(response)
|
||||
@@ -61,18 +61,18 @@ def retrieve_from_cache(seed, prompt_num, choices, tag):
|
||||
blob_file_name = "p" + str(prompt_num) + "/seed" + str(seed) + "/" + tag
|
||||
|
||||
for action in choices:
|
||||
blob_file_name + str(action)
|
||||
blob_file_name = blob_file_name + str(action)
|
||||
|
||||
blob = bucket.blob(blob_file_name)
|
||||
|
||||
if blob.exists(storage_client):
|
||||
result = blob.download_as_string()
|
||||
result = blob.download_as_string().decode("utf-8")
|
||||
print(blob_file_name, " found in cache")
|
||||
else:
|
||||
result = None
|
||||
print(blob_file_name, " not found in cache")
|
||||
|
||||
return result.decode("utf-8")
|
||||
return result
|
||||
|
||||
|
||||
@app.route('/generate', methods=['POST'])
|
||||
|
||||
+5
-4
@@ -9,8 +9,9 @@ var blinkCounter = 0
|
||||
var action_list = ["You attack", "You tell", "You use", "You go"]
|
||||
var prompt_num = 0
|
||||
var seed_max = 100
|
||||
var seed_min = 100
|
||||
var seed = Math.floor(Math.random() * (+seed_max - +seed_min)) + +seed_min;
|
||||
var seed_min = 0
|
||||
var seed = 100
|
||||
//var seed = Math.floor(Math.random() * (+seed_max - +seed_min)) + +seed_min;
|
||||
|
||||
var StoryTracker = {
|
||||
firstStory: null,
|
||||
@@ -92,7 +93,7 @@ var StoryTracker = {
|
||||
if(choice_int >= 0 && choice_int <= 3){
|
||||
|
||||
console.log("choice_int is %d", choice_int)
|
||||
StoryTracker.actions.push(choice_int)
|
||||
StoryTracker.choices.push(choice_int)
|
||||
StoryTracker.lastAction = StoryTracker.actions[choice_int]
|
||||
StoryTracker.lastStory = StoryTracker.results[choice_int]
|
||||
StoryTracker.makeActionRequests(StoryTracker.firstStory + StoryTracker.lastStory)
|
||||
@@ -178,7 +179,7 @@ function writeAppend(str){
|
||||
|
||||
|
||||
function startTyping(){
|
||||
addTextTimer = setInterval("typeWords()", 40)
|
||||
addTextTimer = setInterval("typeWords()", 30)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user