Sarah Ciston commited on
Commit
581179a
·
1 Parent(s): 7f1b310

debug reorder

Browse files
Files changed (1) hide show
  1. sketch.js +117 -105
sketch.js CHANGED
@@ -10,6 +10,10 @@ 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 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
 
@@ -19,6 +23,117 @@ let MODELNAME = 'Xenova/gpt-3.5-turbo'
19
 
20
  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.`
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}`
@@ -27,6 +142,7 @@ 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
32
  // const out = await inference.chatCompletion({
@@ -144,108 +260,4 @@ var inputArray = ["mother", "father", "sister", "brother"]
144
 
145
  // function draw(){
146
  // //
147
- // }
148
-
149
-
150
- new p5(function(p5){
151
- p5.setup = function(){
152
- console.log('p5 loaded')
153
- p5.noCanvas()
154
- makeInterface()
155
- // let canvas = p5.createCanvas(200,200)
156
- // canvas.position(300, 1000);
157
- // p5.background(200)
158
- // p5.textSize(20)
159
- // p5.textAlign(p5.CENTER,p5.CENTER)
160
- }
161
-
162
- p5.draw = function(){
163
- //
164
- }
165
-
166
- window.onload = function(){
167
- console.log('sketchfile loaded')
168
- }
169
-
170
-
171
-
172
- function makeInterface(){
173
- console.log('got to make interface')
174
- let title = p5.createElement('h1', 'p5.js Critical AI Prompt Battle')
175
- title.position(0,50)
176
-
177
- promptInput = p5.createInput("")
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 ...`)
185
-
186
-
187
- //make for loop to generate
188
- //make a button to make another
189
- //add them to the list of items
190
- maskInputA = p5.createInput("");
191
- maskInputA.position(0, 240);
192
- maskInputA.size(200);
193
- maskInputA.elt.style.fontSize = "15px";
194
- maskAResult = maskInputA.value()
195
- maskInputA.changed()
196
-
197
- maskInputB = p5.createInput("");
198
- maskInputB.position(0, 270);
199
- maskInputB.size(200);
200
- maskInputB.elt.style.fontSize = "15px";
201
- maskBResult = maskInputB.value()
202
-
203
- maskInputC = p5.createInput("");
204
- maskInputC.position(0, 300);
205
- maskInputC.size(200);
206
- maskInputC.elt.style.fontSize = "15px";
207
- maskCResult = maskInputC.value()
208
-
209
- modelDisplay = p5.createElement("p", "Results:");
210
- modelDisplay.position(0, 380);
211
- // setTimeout(() => {
212
- modelDisplay.html(modelResult)
213
- // }, 2000);
214
-
215
- //a model drop down list?
216
-
217
- //GO BUTTON
218
- promptButton = p5.createButton("GO").position(0, 340);
219
- promptButton.position(0, 340);
220
- promptButton.elt.style.fontSize = "15px";
221
- promptButton.mousePressed(test)
222
- // promptInput.changed(test)
223
- // maskInputA.changed(test)
224
- // maskInputB.changed(test)
225
- // maskInputC.changed(test)
226
-
227
- // describe(``)
228
- // TO-DO alt-text description
229
- function test(){
230
- console.log('did something')
231
- console.log(promptInput.value())
232
- }
233
- }
234
-
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
-
245
- // function makeInput(i){
246
- // i = p5.createInput("");
247
- // i.position(0, 300); //append to last input and move buttons down
248
- // i.size(200);
249
- // i.elt.style.fontSize = "15px";
250
- // }
251
- });
 
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
+ ///////// VARIABLES
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
 
 
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
28
+
29
+
30
+ new p5(function(p5){
31
+ p5.setup = function(){
32
+ console.log('p5 loaded')
33
+ p5.noCanvas()
34
+ makeInterface()
35
+ // let canvas = p5.createCanvas(200,200)
36
+ // canvas.position(300, 1000);
37
+ // p5.background(200)
38
+ // p5.textSize(20)
39
+ // p5.textAlign(p5.CENTER,p5.CENTER)
40
+ }
41
+
42
+ p5.draw = function(){
43
+ //
44
+ }
45
+
46
+ window.onload = function(){
47
+ console.log('sketchfile loaded')
48
+ }
49
+
50
+
51
+
52
+ function makeInterface(){
53
+ console.log('got to make interface')
54
+ let title = p5.createElement('h1', 'p5.js Critical AI Prompt Battle')
55
+ title.position(0,50)
56
+
57
+ promptInput = p5.createInput("")
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);
91
+ // // setTimeout(() => {
92
+ // modelDisplay.html(modelResult)
93
+ // // }, 2000);
94
+
95
+ //a model drop down list?
96
+
97
+ //GO BUTTON
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
119
+ // // run the prompt through the model here
120
+ // // modelResult = runModel()
121
+ // // return modelResult
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
+ // }
131
+ });
132
+
133
+
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}`
 
142
  // // for num of inputs put in list
143
  // var inputArray = [`${maskAResult}`, `${maskBResult}`, `${maskCResult}`]
144
 
145
+
146
  // async function runModel(){
147
  // // Chat completion API
148
  // const out = await inference.chatCompletion({
 
260
 
261
  // function draw(){
262
  // //
263
+ // }