Sarah Ciston commited on
Commit
96990ed
·
1 Parent(s): 581179a
Files changed (1) hide show
  1. sketch.js +34 -39
sketch.js CHANGED
@@ -14,14 +14,14 @@ const inference = new HfInference();
14
 
15
 
16
 
17
- let promptResult, maskAResult, maskBResult, maskCResult, promptButton, buttonButton, promptInput, maskInputA, maskInputB, maskInputC, modelDisplay, modelResult
18
  // const detector = await pipeline('text-generation', 'meta-llama/Meta-Llama-3-8B', 'Xenova/LaMini-Flan-T5-783M');
19
 
20
  let MODELNAME = 'Xenova/gpt-3.5-turbo'
21
  // models('Xenova/gpt2', 'Xenova/gpt-3.5-turbo', 'mistralai/Mistral-7B-Instruct-v0.2', 'Xenova/llama-68m', 'meta-llama/Meta-Llama-3-8B', 'Xenova/bloom-560m', 'Xenova/distilgpt2')
22
 
23
 
24
- var PREPROMPT = `Return an array of sentences. In each sentence, fill in the [BLANK] in the following sentence with each word I provide in the array ${inputArray}. Replace any [FILL] with an appropriate word of your choice.`
25
 
26
 
27
  ///// p5 STUFF
@@ -58,33 +58,33 @@ new p5(function(p5){
58
  promptInput.position(0,160)
59
  promptInput.size(500);
60
  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.`)
61
- promptInput.value(`For example: "The [BLANK] has a job as a ...`)
62
  promptInput.elt.style.fontSize = "15px";
63
  p5.createP(promptInput.attribute('label')).position(0,100)
64
- // p5.createP(`For example: "The BLANK has a job as a MASK where their favorite thing to do is ...`)
65
 
66
 
67
  //make for loop to generate
68
  //make a button to make another
69
  //add them to the list of items
70
- maskInputA = p5.createInput("");
71
- maskInputA.position(0, 240);
72
- maskInputA.size(200);
73
- maskInputA.elt.style.fontSize = "15px";
74
- maskAResult = maskInputA.value()
75
- maskInputA.changed()
76
-
77
- maskInputB = p5.createInput("");
78
- maskInputB.position(0, 270);
79
- maskInputB.size(200);
80
- maskInputB.elt.style.fontSize = "15px";
81
- maskBResult = maskInputB.value()
82
-
83
- maskInputC = p5.createInput("");
84
- maskInputC.position(0, 300);
85
- maskInputC.size(200);
86
- maskInputC.elt.style.fontSize = "15px";
87
- maskCResult = maskInputC.value()
88
 
89
  // modelDisplay = p5.createElement("p", "Results:");
90
  // modelDisplay.position(0, 380);
@@ -98,21 +98,16 @@ new p5(function(p5){
98
  promptButton = p5.createButton("GO").position(0, 340);
99
  promptButton.position(0, 340);
100
  promptButton.elt.style.fontSize = "15px";
101
- promptButton.mousePressed(test)
102
- // promptInput.changed(test)
103
- // maskInputA.changed(test)
104
- // maskInputB.changed(test)
105
- // maskInputC.changed(test)
106
 
107
  // describe(``)
108
  // TO-DO alt-text description
109
-
110
  }
111
 
112
- function test(){
113
- console.log('did something')
114
- console.log(promptInput.value())
115
- }
116
 
117
  // var modelResult = promptButton.mousePressed(runModel) = function(){
118
  // // listens for the button to be clicked
@@ -122,9 +117,9 @@ new p5(function(p5){
122
  // runModel()
123
  // }
124
 
125
- // function makeInput(i){
126
  // i = p5.createInput("");
127
- // i.position(0, 300); //append to last input and move buttons down
128
  // i.size(200);
129
  // i.elt.style.fontSize = "15px";
130
  // }
@@ -134,13 +129,13 @@ new p5(function(p5){
134
  ///// MODEL STUFF
135
 
136
 
137
- var PROMPT = `The [BLANK] works as a [FILL] but wishes for [FILL].`
138
  // /// this needs to run on button click, use string variables to fill in the form
139
- // var PROMPT = `${promptResult}`
140
 
141
- var inputArray = ["mother", "father", "sister", "brother"]
142
- // // for num of inputs put in list
143
- // var inputArray = [`${maskAResult}`, `${maskBResult}`, `${maskCResult}`]
144
 
145
 
146
  // async function runModel(){
 
14
 
15
 
16
 
17
+ let promptResult, fillAResult, fillBResult, fillCResult, promptButton, buttonButton, promptInput, fillA, fillB, fillC, modelDisplay, modelResult
18
  // const detector = await pipeline('text-generation', 'meta-llama/Meta-Llama-3-8B', 'Xenova/LaMini-Flan-T5-783M');
19
 
20
  let MODELNAME = 'Xenova/gpt-3.5-turbo'
21
  // models('Xenova/gpt2', 'Xenova/gpt-3.5-turbo', 'mistralai/Mistral-7B-Instruct-v0.2', 'Xenova/llama-68m', 'meta-llama/Meta-Llama-3-8B', 'Xenova/bloom-560m', 'Xenova/distilgpt2')
22
 
23
 
24
+ var PREPROMPT = `Return an array of sentences. In each sentence, fill in the [BLANK] in the following sentence with each word I provide in the array ${fillArray}. Replace any [FILL] with an appropriate word of your choice.`
25
 
26
 
27
  ///// p5 STUFF
 
58
  promptInput.position(0,160)
59
  promptInput.size(500);
60
  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.`)
61
+ promptInput.value(`The [BLANK] works as a [FILL] but wishes for [FILL].`)
62
  promptInput.elt.style.fontSize = "15px";
63
  p5.createP(promptInput.attribute('label')).position(0,100)
64
+ // p5.createP(`For example: "The BLANK has a job as a FILL where their favorite thing to do is ...`)
65
 
66
 
67
  //make for loop to generate
68
  //make a button to make another
69
  //add them to the list of items
70
+ fillA = p5.createInput("");
71
+ fillA.position(0, 240);
72
+ fillA.size(200);
73
+ fillA.elt.style.fontSize = "15px";
74
+ fillAResult = fillA.value()
75
+ fillA.changed()
76
+
77
+ fillB = p5.createInput("");
78
+ fillB.position(0, 270);
79
+ fillB.size(200);
80
+ fillB.elt.style.fontSize = "15px";
81
+ fillBResult = fillB.value()
82
+
83
+ fillC = p5.createInput("");
84
+ fillC.position(0, 300);
85
+ fillC.size(200);
86
+ fillC.elt.style.fontSize = "15px";
87
+ fillCResult = fillC.value()
88
 
89
  // modelDisplay = p5.createElement("p", "Results:");
90
  // modelDisplay.position(0, 380);
 
98
  promptButton = p5.createButton("GO").position(0, 340);
99
  promptButton.position(0, 340);
100
  promptButton.elt.style.fontSize = "15px";
101
+ promptButton.mousePressed(console.log(promptInput.value()))
 
 
 
 
102
 
103
  // describe(``)
104
  // TO-DO alt-text description
 
105
  }
106
 
107
+ // function test(){
108
+ // console.log('did something')
109
+ // console.log(promptInput.value())
110
+ // }
111
 
112
  // var modelResult = promptButton.mousePressed(runModel) = function(){
113
  // // listens for the button to be clicked
 
117
  // runModel()
118
  // }
119
 
120
+ // function makefill(i){
121
  // i = p5.createInput("");
122
+ // i.position(0, 300); //append to last fill and move buttons down
123
  // i.size(200);
124
  // i.elt.style.fontSize = "15px";
125
  // }
 
129
  ///// MODEL STUFF
130
 
131
 
132
+ // var PROMPT = `The [BLANK] works as a [FILL] but wishes for [FILL].`
133
  // /// this needs to run on button click, use string variables to fill in the form
134
+ var PROMPT = promptInput.value()
135
 
136
+ var fillArray = ["mother", "father", "sister", "brother"]
137
+ // // for num of fills put in list
138
+ // var fillArray = [`${fillAResult}`, `${fillBResult}`, `${fillCResult}`]
139
 
140
 
141
  // async function runModel(){