Sarah Ciston commited on
Commit
0bb49c6
·
1 Parent(s): 5ef1468

declared vars in new places to tighten scope

Browse files
Files changed (1) hide show
  1. sketch.js +14 -16
sketch.js CHANGED
@@ -14,11 +14,9 @@ env.allowLocalModels = false;
14
 
15
  ///////// VARIABLES
16
 
17
- // establish global variables
18
-
19
- let promptInput
20
-
21
- let blankArray = []
22
 
23
  // pick a model (see list of models)
24
  // INFERENCE MODELS
@@ -88,15 +86,15 @@ new p5(function (p5) {
88
  // // BUTTONS // //
89
 
90
  // send prompt to model
91
- submitButton = p5.createButton("SUBMIT")
92
  // submitButton.position(0,500)
93
- submitButton.size(200)
94
  submitButton.class('submit');
95
  submitButton.mousePressed(getInputs)
96
 
97
  // add more blanks to fill in
98
- addButton = p5.createButton("more blanks")
99
- addButton.size(200)
100
  // addButton.position(220,500)
101
  addButton.mousePressed(addField)
102
 
@@ -112,7 +110,7 @@ new p5(function (p5) {
112
  f.parent("#fieldsDiv")
113
 
114
  // DOES THIS WORK???????????????????
115
- blankArray.push(f)
116
  console.log("made field")
117
 
118
  // Cap the number of fields, avoids token limit in prompt
@@ -125,19 +123,19 @@ new p5(function (p5) {
125
 
126
  async function getInputs(){
127
  // Map the list of blanks text values to a new list
128
- let INPUTVALUES = blankArray.map(i => i.value())
129
- console.log(INPUTVALUES)
130
 
131
  // Do model stuff in this function instead of in general
132
- PROMPT = promptInput.value() // updated check of the prompt field
133
 
134
  // BLANKS = inputValues // get ready to feed array list into model
135
 
136
- PREPROMPT = `Please return an array of sentences. In each sentence, fill in the [BLANK] in the following sentence with each word I provide in the array ${INPUTVALUES}. Replace any [FILL] with an appropriate word of your choice.`
137
 
138
- // we pass PROMPT and PREPROMPT to the model function, don't need to pass INPUTVALUES bc it's passed into the PREPROMPT already here
139
 
140
- modelResult = await runModel(PREPROMPT, PROMPT)
141
 
142
  await displayModel(modelResult)
143
  }
 
14
 
15
  ///////// VARIABLES
16
 
17
+ // establish global variables to reference later
18
+ var promptInput
19
+ var blankArray = []
 
 
20
 
21
  // pick a model (see list of models)
22
  // INFERENCE MODELS
 
86
  // // BUTTONS // //
87
 
88
  // send prompt to model
89
+ let submitButton = p5.createButton("SUBMIT")
90
  // submitButton.position(0,500)
91
+ // submitButton.size(200)
92
  submitButton.class('submit');
93
  submitButton.mousePressed(getInputs)
94
 
95
  // add more blanks to fill in
96
+ let addButton = p5.createButton("more blanks")
97
+ // addButton.size(200)
98
  // addButton.position(220,500)
99
  addButton.mousePressed(addField)
100
 
 
110
  f.parent("#fieldsDiv")
111
 
112
  // DOES THIS WORK???????????????????
113
+ blanksArray.push(f)
114
  console.log("made field")
115
 
116
  // Cap the number of fields, avoids token limit in prompt
 
123
 
124
  async function getInputs(){
125
  // Map the list of blanks text values to a new list
126
+ let BLANKSVALUES = blankArray.map(i => i.value())
127
+ console.log(BLANKSVALUES)
128
 
129
  // Do model stuff in this function instead of in general
130
+ let PROMPT = promptInput.value() // updated check of the prompt field
131
 
132
  // BLANKS = inputValues // get ready to feed array list into model
133
 
134
+ let PREPROMPT = `Please return an array of sentences. In each sentence, fill in the [BLANK] in the following sentence with each word I provide in the array ${BLANKSVALUES}. Replace any [FILL] with an appropriate word of your choice.`
135
 
136
+ // we pass PROMPT and PREPROMPT to the model function, don't need to pass BLANKSVALUES bc it's passed into the PREPROMPT already here
137
 
138
+ let modelResult = await runModel(PREPROMPT, PROMPT)
139
 
140
  await displayModel(modelResult)
141
  }