Sarah Ciston
commited on
Commit
·
94d8833
1
Parent(s):
acdfdf9
add button, test functionality
Browse files
sketch.js
CHANGED
@@ -14,14 +14,16 @@ const inference = new HfInference();
|
|
14 |
|
15 |
|
16 |
|
17 |
-
let promptResult,
|
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,
|
25 |
|
26 |
|
27 |
///// p5 STUFF
|
@@ -57,34 +59,34 @@ new p5(function(p5){
|
|
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 [
|
61 |
-
promptInput.value(`The [BLANK] works 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
|
65 |
-
promptResult = promptInput.value()
|
66 |
-
|
67 |
|
68 |
//make for loop to generate
|
69 |
//make a button to make another
|
70 |
//add them to the list of items
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
88 |
|
89 |
// modelDisplay = p5.createElement("p", "Results:");
|
90 |
// modelDisplay.position(0, 380);
|
@@ -104,9 +106,31 @@ new p5(function(p5){
|
|
104 |
// TO-DO alt-text description
|
105 |
}
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
function test(){
|
108 |
console.log('did test')
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
|
112 |
// var modelResult = promptButton.mousePressed(runModel) = function(){
|
@@ -117,9 +141,9 @@ new p5(function(p5){
|
|
117 |
// runModel()
|
118 |
// }
|
119 |
|
120 |
-
// function
|
121 |
// i = p5.createInput("");
|
122 |
-
// i.position(0, 300); //append to last
|
123 |
// i.size(200);
|
124 |
// i.elt.style.fontSize = "15px";
|
125 |
// }
|
@@ -129,13 +153,13 @@ new p5(function(p5){
|
|
129 |
///// MODEL STUFF
|
130 |
|
131 |
|
132 |
-
// var PROMPT = `The [BLANK] works as a [
|
133 |
-
// /// this needs to run on button click, use string variables to
|
134 |
-
var PROMPT = promptInput.value()
|
135 |
|
136 |
-
var
|
137 |
-
// // for num of
|
138 |
-
// var
|
139 |
|
140 |
|
141 |
// async function runModel(){
|
|
|
14 |
|
15 |
|
16 |
|
17 |
+
let PROMPT, promptResult, blankAResult, blankBResult, blankCResult, promptButton, blankButton, promptInput, blankA, blankB, blankC, modelDisplay, modelResult
|
18 |
// const detector = await pipeline('text-generation', 'meta-llama/Meta-Llama-3-8B', 'Xenova/LaMini-Flan-T5-783M');
|
19 |
|
20 |
+
let blankArray = []
|
21 |
+
|
22 |
let MODELNAME = 'Xenova/gpt-3.5-turbo'
|
23 |
// 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')
|
24 |
|
25 |
|
26 |
+
var PREPROMPT = `Return an array of sentences. In each sentence, blank in the [BLANK] in the following sentence with each word I provide in the array ${blankArray}. Replace any [blank] with an appropriate word of your choice.`
|
27 |
|
28 |
|
29 |
///// p5 STUFF
|
|
|
59 |
promptInput = p5.createInput("")
|
60 |
promptInput.position(0,160)
|
61 |
promptInput.size(500);
|
62 |
+
promptInput.attribute('label', `Write a text prompt with at least one [BLANK] that describes someone. You can also write [blank] where you want the bot to blank in a word.`)
|
63 |
+
promptInput.value(`The [BLANK] works as a [blank] but wishes for [blank].`)
|
64 |
promptInput.elt.style.fontSize = "15px";
|
65 |
p5.createP(promptInput.attribute('label')).position(0,100)
|
66 |
+
// p5.createP(`For example: "The BLANK has a job as a blank where their favorite thing to do is ...`)
|
|
|
|
|
67 |
|
68 |
//make for loop to generate
|
69 |
//make a button to make another
|
70 |
//add them to the list of items
|
71 |
+
blankA = p5.createInput("");
|
72 |
+
blankA.position(0, 240);
|
73 |
+
blankA.size(200);
|
74 |
+
blankA.elt.style.fontSize = "15px";
|
75 |
+
blankA.addClass("blank")
|
76 |
+
|
77 |
+
blankButton = p5.createButton("more blanks").position(230,240)
|
78 |
+
blankButton.elt.style.fontSize = "15px"
|
79 |
+
blankButton.mousePressed(makeBlank)
|
80 |
+
|
81 |
+
// blankB = p5.createInput("");
|
82 |
+
// blankB.position(0, 270);
|
83 |
+
// blankB.size(200);
|
84 |
+
// blankB.elt.style.fontSize = "15px";
|
85 |
+
|
86 |
+
// blankC = p5.createInput("");
|
87 |
+
// blankC.position(0, 300);
|
88 |
+
// blankC.size(200);
|
89 |
+
// blankC.elt.style.fontSize = "15px";
|
90 |
|
91 |
// modelDisplay = p5.createElement("p", "Results:");
|
92 |
// modelDisplay.position(0, 380);
|
|
|
106 |
// TO-DO alt-text description
|
107 |
}
|
108 |
|
109 |
+
function makeBlank(){
|
110 |
+
let i =
|
111 |
+
let b = p5.createInput("")
|
112 |
+
b.position(0, 240 + (i*30)) // positions new buttons below the prior buttons based on their place in the list
|
113 |
+
b.size(200)
|
114 |
+
b.elt.style.fontSize = "15px" // change this to CSS
|
115 |
+
b.addClass("blank")
|
116 |
+
blankA.append(b)
|
117 |
+
}
|
118 |
+
|
119 |
function test(){
|
120 |
console.log('did test')
|
121 |
+
//make sure to set these variables to the values here, at the moment of button press, otherwise they will be blank
|
122 |
+
promptResult = promptInput.value()
|
123 |
+
// blankAResult = blankA.value()
|
124 |
+
// blankBResult = blankB.value()
|
125 |
+
// blankCResult = blankC.value()
|
126 |
+
|
127 |
+
let blanks = document.querySelectorAll("class", "blank")
|
128 |
+
|
129 |
+
for (b in blanks){
|
130 |
+
// b = b.value()
|
131 |
+
inputArray.push(b.value())
|
132 |
+
}
|
133 |
+
console.log(promptResult, inputArray)
|
134 |
}
|
135 |
|
136 |
// var modelResult = promptButton.mousePressed(runModel) = function(){
|
|
|
141 |
// runModel()
|
142 |
// }
|
143 |
|
144 |
+
// function makeblank(i){
|
145 |
// i = p5.createInput("");
|
146 |
+
// i.position(0, 300); //append to last blank and move buttons down
|
147 |
// i.size(200);
|
148 |
// i.elt.style.fontSize = "15px";
|
149 |
// }
|
|
|
153 |
///// MODEL STUFF
|
154 |
|
155 |
|
156 |
+
// var PROMPT = `The [BLANK] works as a [blank] but wishes for [blank].`
|
157 |
+
// /// this needs to run on button click, use string variables to blank in the form
|
158 |
+
// var PROMPT = promptInput.value()
|
159 |
|
160 |
+
// var blankArray = ["mother", "father", "sister", "brother"]
|
161 |
+
// // for num of blanks put in list
|
162 |
+
// var blankArray = [`${blankAResult}`, `${blankBResult}`, `${blankCResult}`]
|
163 |
|
164 |
|
165 |
// async function runModel(){
|