Sarah Ciston commited on
Commit
07cff5b
·
1 Parent(s): 4617715

test with passed vars

Browse files
Files changed (1) hide show
  1. sketch.js +14 -12
sketch.js CHANGED
@@ -92,11 +92,11 @@ new p5(function(p5){
92
  // addButton.position(150,600)
93
  addButton.mousePressed(addField)
94
 
95
- // modelDisplay = p5.createElement("p", "Results:");
96
- // modelDisplay.position(0, 380);
97
- // // setTimeout(() => {
98
- // modelDisplay.html(modelResult)
99
- // // }, 2000);
100
 
101
  // TO-DO a model drop down list?
102
 
@@ -123,17 +123,19 @@ new p5(function(p5){
123
 
124
  async function getInputs(){
125
  // Map the list of blanks text values to a new list
126
- let inputValues = blankArray.map(i => i.value())
127
- console.log(inputValues)
128
 
129
  // Do model stuff in this function instead of in general
130
  PROMPT = promptInput.value() // updated check of the prompt field
131
 
132
  // BLANKS = inputValues // get ready to feed array list into model
133
 
134
- 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.`
135
 
136
- await runModel()
 
 
137
  }
138
 
139
  // var modelResult = submitButton.mousePressed(runModel) = function(){
@@ -165,7 +167,7 @@ new p5(function(p5){
165
  // var blankArray = [`${blankAResult}`, `${blankBResult}`, `${blankCResult}`]
166
 
167
 
168
- async function runModel(){
169
  // Chat completion API
170
  const out = await inference.chatCompletion({
171
  model: MODELNAME,
@@ -186,8 +188,8 @@ async function runModel(){
186
  // });
187
  console.log(out)
188
 
189
- var modelResult = await out.choices[0].message.content
190
- // var modelResult = await out[0].generated_text
191
  console.log(modelResult);
192
 
193
  return modelResult
 
92
  // addButton.position(150,600)
93
  addButton.mousePressed(addField)
94
 
95
+ modelDisplay = p5.createElement("p", "Results:");
96
+ modelDisplay.position(0, 380);
97
+ setTimeout(() => {
98
+ modelDisplay.html(modelResult)
99
+ }, 2000);
100
 
101
  // TO-DO a model drop down list?
102
 
 
123
 
124
  async function getInputs(){
125
  // Map the list of blanks text values to a new list
126
+ let INPUTVALUES = blankArray.map(i => i.value())
127
+ console.log(INPUTVALUES)
128
 
129
  // Do model stuff in this function instead of in general
130
  PROMPT = promptInput.value() // updated check of the prompt field
131
 
132
  // BLANKS = inputValues // get ready to feed array list into model
133
 
134
+ 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.`
135
 
136
+ // we pass PROMPT and PREPROMPT to the model function, don't need to pass INPUTVALUES bc it's passed into the PREPROMPT already here
137
+
138
+ await runModel(PREPROMPT, PROMPT)
139
  }
140
 
141
  // var modelResult = submitButton.mousePressed(runModel) = function(){
 
167
  // var blankArray = [`${blankAResult}`, `${blankBResult}`, `${blankCResult}`]
168
 
169
 
170
+ async function runModel(PREPROMPT, PROMPT){
171
  // Chat completion API
172
  const out = await inference.chatCompletion({
173
  model: MODELNAME,
 
188
  // });
189
  console.log(out)
190
 
191
+ // var modelResult = await out.choices[0].message.content
192
+ var modelResult = await out[0].generated_text
193
  console.log(modelResult);
194
 
195
  return modelResult