Sarah Ciston commited on
Commit
3541abb
·
1 Parent(s): 7f43e7f

change input fields to input results

Browse files
Files changed (1) hide show
  1. sketch.js +22 -19
sketch.js CHANGED
@@ -10,7 +10,7 @@ const inference = new HfInference();
10
  // Since we will download the model from the Hugging Face Hub, we can skip the local model check
11
  // env.allowLocalModels = false;
12
 
13
- let promptButton, buttonButton, promptInput, maskInputA, maskInputB, maskInputC, modOutput, result
14
  // const detector = await pipeline('text-generation', 'meta-llama/Meta-Llama-3-8B', 'Xenova/LaMini-Flan-T5-783M');
15
 
16
  let MODELNAME = 'Xenova/gpt-3.5-turbo'
@@ -21,11 +21,11 @@ var PREPROMPT = `Return an array of sentences. In each sentence, fill in the [BL
21
 
22
  // var PROMPT = `The [BLANK] works as a [FILL] but wishes for [FILL].`
23
  /// this needs to run on button click, use string variables to fill in the form
24
- var PROMPT = `${promptInput}`
25
 
26
  // var inputArray = ["mother", "father", "sister", "brother"]
27
  // for num of inputs put in list
28
- var inputArray = [`${maskInputA}`, `${maskInputB}`, `${maskInputC}`]
29
 
30
  // async function runModel(){
31
  // // Chat completion API
@@ -48,11 +48,11 @@ var inputArray = [`${maskInputA}`, `${maskInputB}`, `${maskInputC}`]
48
  // // });
49
  // console.log(out)
50
 
51
- // var result = await out.choices[0].message.content
52
- // // var result = await out[0].generated_text
53
- // console.log(result);
54
 
55
- // return result
56
  // }
57
 
58
 
@@ -178,7 +178,7 @@ new p5(function(p5){
178
  promptInput.position(0,160)
179
  promptInput.size(500);
180
  promptInput.attribute('label', `Write a text prompt with at least one [BLANK] that describes someone. You can also write [FILL] where you want the bot to fill in a word.`)
181
- promptInput.value(`For example: "The [BLANK] has a job as a ...`)
182
  promptInput.elt.style.fontSize = "15px";
183
  p5.createP(promptInput.attribute('label')).position(0,100)
184
  // p5.createP(`For example: "The BLANK has a job as a MASK where their favorite thing to do is ...`)
@@ -190,22 +190,25 @@ new p5(function(p5){
190
  maskInputA = p5.createInput("");
191
  maskInputA.position(0, 240);
192
  maskInputA.size(200);
193
- maskInputA.elt.style.fontSize = "15px";
 
194
 
195
  maskInputB = p5.createInput("");
196
  maskInputB.position(0, 270);
197
  maskInputB.size(200);
198
  maskInputB.elt.style.fontSize = "15px";
 
199
 
200
  maskInputC = p5.createInput("");
201
  maskInputC.position(0, 300);
202
  maskInputC.size(200);
203
  maskInputC.elt.style.fontSize = "15px";
 
204
 
205
- modOutput = p5.createElement("p", "Results:");
206
- modOutput.position(0, 380);
207
  // setTimeout(() => {
208
- modOutput.html(result)
209
  // }, 2000);
210
 
211
  //a model drop down list?
@@ -215,10 +218,10 @@ new p5(function(p5){
215
  promptButton.position(0, 340);
216
  promptButton.elt.style.fontSize = "15px";
217
  promptButton.mousePressed(test)
218
- promptInput.changed(test)
219
- maskInputA.changed(test)
220
- maskInputB.changed(test)
221
- maskInputC.changed(test)
222
 
223
  // describe(``)
224
  // TO-DO alt-text description
@@ -231,11 +234,11 @@ new p5(function(p5){
231
  console.log(inputArray)
232
  }
233
 
234
- // var result = promptButton.mousePressed(runModel) = function(){
235
  // // listens for the button to be clicked
236
  // // run the prompt through the model here
237
- // // result = runModel()
238
- // // return result
239
  // runModel()
240
  // }
241
 
 
10
  // Since we will download the model from the Hugging Face Hub, we can skip the local model check
11
  // env.allowLocalModels = false;
12
 
13
+ let promptResult, maskAResult, maskBResult, maskCResult, promptButton, buttonButton, promptInput, maskInputA, maskInputB, maskInputC, modelDisplay, modelResult
14
  // const detector = await pipeline('text-generation', 'meta-llama/Meta-Llama-3-8B', 'Xenova/LaMini-Flan-T5-783M');
15
 
16
  let MODELNAME = 'Xenova/gpt-3.5-turbo'
 
21
 
22
  // var PROMPT = `The [BLANK] works as a [FILL] but wishes for [FILL].`
23
  /// this needs to run on button click, use string variables to fill in the form
24
+ var PROMPT = `${promptResult}`
25
 
26
  // var inputArray = ["mother", "father", "sister", "brother"]
27
  // for num of inputs put in list
28
+ var inputArray = [`${maskAResult}`, `${maskBResult}`, `${maskCResult}`]
29
 
30
  // async function runModel(){
31
  // // Chat completion API
 
48
  // // });
49
  // console.log(out)
50
 
51
+ // var modelResult = await out.choices[0].message.content
52
+ // // var modelResult = await out[0].generated_text
53
+ // console.log(modelResult);
54
 
55
+ // return modelResult
56
  // }
57
 
58
 
 
178
  promptInput.position(0,160)
179
  promptInput.size(500);
180
  promptInput.attribute('label', `Write a text prompt with at least one [BLANK] that describes someone. You can also write [FILL] where you want the bot to fill in a word.`)
181
+ promptResult = promptInput.value(`For example: "The [BLANK] has a job as a ...`)
182
  promptInput.elt.style.fontSize = "15px";
183
  p5.createP(promptInput.attribute('label')).position(0,100)
184
  // p5.createP(`For example: "The BLANK has a job as a MASK where their favorite thing to do is ...`)
 
190
  maskInputA = p5.createInput("");
191
  maskInputA.position(0, 240);
192
  maskInputA.size(200);
193
+ maskInputA.elt.style.fontSize = "15px";
194
+ maskAResult = maskInputA.value()
195
 
196
  maskInputB = p5.createInput("");
197
  maskInputB.position(0, 270);
198
  maskInputB.size(200);
199
  maskInputB.elt.style.fontSize = "15px";
200
+ maskBResult = maskInputB.value()
201
 
202
  maskInputC = p5.createInput("");
203
  maskInputC.position(0, 300);
204
  maskInputC.size(200);
205
  maskInputC.elt.style.fontSize = "15px";
206
+ maskCResult = maskInputC.value()
207
 
208
+ modelDisplay = p5.createElement("p", "Results:");
209
+ modelDisplay.position(0, 380);
210
  // setTimeout(() => {
211
+ modelDisplay.html(modelResult)
212
  // }, 2000);
213
 
214
  //a model drop down list?
 
218
  promptButton.position(0, 340);
219
  promptButton.elt.style.fontSize = "15px";
220
  promptButton.mousePressed(test)
221
+ // promptInput.changed(test)
222
+ // maskInputA.changed(test)
223
+ // maskInputB.changed(test)
224
+ // maskInputC.changed(test)
225
 
226
  // describe(``)
227
  // TO-DO alt-text description
 
234
  console.log(inputArray)
235
  }
236
 
237
+ // var modelResult = promptButton.mousePressed(runModel) = function(){
238
  // // listens for the button to be clicked
239
  // // run the prompt through the model here
240
+ // // modelResult = runModel()
241
+ // // return modelResult
242
  // runModel()
243
  // }
244