Sarah Ciston
commited on
Commit
•
47d8484
1
Parent(s):
0ad633f
CSS and formatting updates
Browse files- index.html +2 -2
- sketch.js +51 -63
- style.css +49 -6
index.html
CHANGED
@@ -24,8 +24,8 @@
|
|
24 |
<!-- </label> -->
|
25 |
<!-- <label id="status">Loading model...</label> -->
|
26 |
<!-- <input id="upload" type="file" accept="image/*" /> -->
|
27 |
-
<div id="
|
28 |
-
</div>
|
29 |
</main>
|
30 |
<script type="module" src="sketch.js"></script>
|
31 |
</body>
|
|
|
24 |
<!-- </label> -->
|
25 |
<!-- <label id="status">Loading model...</label> -->
|
26 |
<!-- <input id="upload" type="file" accept="image/*" /> -->
|
27 |
+
<!-- <div id="fieldsDiv">
|
28 |
+
</div> -->
|
29 |
</main>
|
30 |
<script type="module" src="sketch.js"></script>
|
31 |
</body>
|
sketch.js
CHANGED
@@ -14,7 +14,7 @@ const inference = new HfInference();
|
|
14 |
|
15 |
|
16 |
|
17 |
-
let PROMPT, promptResult, blankAResult, blankBResult, blankCResult,
|
18 |
// const detector = await pipeline('text-generation', 'meta-llama/Meta-Llama-3-8B', 'Xenova/LaMini-Flan-T5-783M');
|
19 |
|
20 |
let blankArray = []
|
@@ -34,11 +34,6 @@ new p5(function(p5){
|
|
34 |
console.log('p5 loaded')
|
35 |
p5.noCanvas()
|
36 |
makeInterface()
|
37 |
-
// let canvas = p5.createCanvas(200,200)
|
38 |
-
// canvas.position(300, 1000);
|
39 |
-
// p5.background(200)
|
40 |
-
// p5.textSize(20)
|
41 |
-
// p5.textAlign(p5.CENTER,p5.CENTER)
|
42 |
}
|
43 |
|
44 |
p5.draw = function(){
|
@@ -49,7 +44,7 @@ new p5(function(p5){
|
|
49 |
console.log('dom and js loaded')
|
50 |
}
|
51 |
|
52 |
-
let
|
53 |
|
54 |
function makeInterface(){
|
55 |
console.log('reached makeInterface')
|
@@ -58,37 +53,41 @@ new p5(function(p5){
|
|
58 |
|
59 |
promptInput = p5.createInput("")
|
60 |
promptInput.position(0,160)
|
61 |
-
promptInput.size(
|
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 [
|
64 |
-
// promptInput.elt.style.fontSize = "15px";
|
65 |
promptInput.addClass("prompt")
|
66 |
p5.createP(promptInput.attribute('label')).position(0,100)
|
67 |
-
// p5.createP(`For example: "The BLANK has a job as a blank where their favorite thing to do is ...`)
|
68 |
|
69 |
//make for loop to generate
|
70 |
//make a button to make another
|
71 |
//add them to the list of items
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
//
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
//
|
84 |
-
|
85 |
-
|
86 |
-
//
|
87 |
-
|
88 |
-
//
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
// modelDisplay = p5.createElement("p", "Results:");
|
94 |
// modelDisplay.position(0, 380);
|
@@ -96,49 +95,39 @@ new p5(function(p5){
|
|
96 |
// modelDisplay.html(modelResult)
|
97 |
// // }, 2000);
|
98 |
|
99 |
-
//a model drop down list?
|
100 |
-
|
101 |
-
//GO BUTTON
|
102 |
-
promptButton = p5.createButton("GO").position(0, 340);
|
103 |
-
promptButton.position(0, 340);
|
104 |
-
promptButton.elt.style.fontSize = "15px";
|
105 |
-
promptButton.mousePressed(test)
|
106 |
|
107 |
// describe(``)
|
108 |
// TO-DO alt-text description
|
109 |
}
|
110 |
|
111 |
-
function
|
112 |
-
let
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
console.log("made
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
-
function
|
122 |
console.log('did test')
|
123 |
-
//make sure to set these variables to the values here, at the moment of button press, otherwise they will be blank
|
124 |
-
// promptResult = promptInput.value()
|
125 |
-
// blankAResult = blankA.value()
|
126 |
-
// blankBResult = blankB.value()
|
127 |
-
// blankCResult = blankC.value()
|
128 |
-
|
129 |
-
let blanks = document.querySelectorAll(".blank")
|
130 |
|
131 |
-
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
// // let blankResult = b.value()
|
136 |
-
// append(inputArray, blankResult)
|
137 |
-
// }
|
138 |
-
// console.log(promptResult, inputArray)
|
139 |
}
|
140 |
|
141 |
-
// var modelResult =
|
142 |
// // listens for the button to be clicked
|
143 |
// // run the prompt through the model here
|
144 |
// // modelResult = runModel()
|
@@ -150,7 +139,6 @@ new p5(function(p5){
|
|
150 |
// i = p5.createInput("");
|
151 |
// i.position(0, 300); //append to last blank and move buttons down
|
152 |
// i.size(200);
|
153 |
-
// i.elt.style.fontSize = "15px";
|
154 |
// }
|
155 |
});
|
156 |
|
|
|
14 |
|
15 |
|
16 |
|
17 |
+
let PROMPT, promptResult, blankAResult, blankBResult, blankCResult, submitButton, addButton, 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 = []
|
|
|
34 |
console.log('p5 loaded')
|
35 |
p5.noCanvas()
|
36 |
makeInterface()
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
p5.draw = function(){
|
|
|
44 |
console.log('dom and js loaded')
|
45 |
}
|
46 |
|
47 |
+
let fieldsDiv = document.querySelector("#blanks")
|
48 |
|
49 |
function makeInterface(){
|
50 |
console.log('reached makeInterface')
|
|
|
53 |
|
54 |
promptInput = p5.createInput("")
|
55 |
promptInput.position(0,160)
|
56 |
+
promptInput.size(600);
|
57 |
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.`)
|
58 |
+
promptInput.value(`The [BLANK] works as a [FILL] but wishes for...`)
|
|
|
59 |
promptInput.addClass("prompt")
|
60 |
p5.createP(promptInput.attribute('label')).position(0,100)
|
|
|
61 |
|
62 |
//make for loop to generate
|
63 |
//make a button to make another
|
64 |
//add them to the list of items
|
65 |
+
fieldsDiv = p5.createDiv()
|
66 |
+
fieldsDiv.id('fieldsDiv')
|
67 |
+
fieldsDiv.position(0,250)
|
68 |
+
|
69 |
+
// initial code to make a single field
|
70 |
+
// blankA = p5.createInput("");
|
71 |
+
// blankA.position(0, 240);
|
72 |
+
// blankA.size(300);
|
73 |
+
// blankA.addClass("blank")
|
74 |
+
// blankA.parent('#fieldsDiv')
|
75 |
+
|
76 |
+
// function to generate a single BLANK form field instead
|
77 |
+
addField()
|
78 |
+
|
79 |
+
// // BUTTONS // //
|
80 |
+
|
81 |
+
// send prompt to model
|
82 |
+
submitButton = p5.createButton("SUBMIT")
|
83 |
+
submitButton.position(0,600)
|
84 |
+
submitButton.class('submit');
|
85 |
+
submitButton.mousePressed(getInputs)
|
86 |
+
|
87 |
+
// add more blanks to fill in
|
88 |
+
addButton = p5.createButton("more blanks")
|
89 |
+
addButton.position(150,600)
|
90 |
+
addButton.mousePressed(addField)
|
91 |
|
92 |
// modelDisplay = p5.createElement("p", "Results:");
|
93 |
// modelDisplay.position(0, 380);
|
|
|
95 |
// modelDisplay.html(modelResult)
|
96 |
// // }, 2000);
|
97 |
|
98 |
+
// TO-DO a model drop down list?
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
// describe(``)
|
101 |
// TO-DO alt-text description
|
102 |
}
|
103 |
|
104 |
+
function addField(){
|
105 |
+
let f = p5.createInput("")
|
106 |
+
f.class("blank")
|
107 |
+
f.parent("#fieldsDiv")
|
108 |
+
|
109 |
+
// DOES THIS WORK???????????????????
|
110 |
+
blankArray.push(f)
|
111 |
+
console.log("made field")
|
112 |
+
|
113 |
+
// Cap the number of fields, avoids token limit in prompt
|
114 |
+
let blanks = document.querySelectorAll(".blank")
|
115 |
+
if (blanks.length > 5){
|
116 |
+
console.log(blanks.length)
|
117 |
+
addButton.style('visibility','hidden')
|
118 |
+
}
|
119 |
}
|
120 |
|
121 |
+
function getInputs(){
|
122 |
console.log('did test')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
+
// Map the list of blanks text values to a new list
|
125 |
|
126 |
+
let inputValues = blankArray.map(i => i.value())
|
127 |
+
console.log(inputValues)
|
|
|
|
|
|
|
|
|
128 |
}
|
129 |
|
130 |
+
// var modelResult = submitButton.mousePressed(runModel) = function(){
|
131 |
// // listens for the button to be clicked
|
132 |
// // run the prompt through the model here
|
133 |
// // modelResult = runModel()
|
|
|
139 |
// i = p5.createInput("");
|
140 |
// i.position(0, 300); //append to last blank and move buttons down
|
141 |
// i.size(200);
|
|
|
142 |
// }
|
143 |
});
|
144 |
|
style.css
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
* {
|
2 |
box-sizing: border-box;
|
3 |
-
padding:
|
4 |
margin: 0;
|
5 |
-
font-family:
|
6 |
}
|
7 |
|
8 |
html,
|
9 |
body {
|
|
|
10 |
height: 100%;
|
11 |
-
padding:
|
12 |
}
|
13 |
|
14 |
body,
|
@@ -19,6 +20,23 @@ body,
|
|
19 |
align-items: center;
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
#container {
|
23 |
position: relative;
|
24 |
gap: 0.4rem;
|
@@ -77,14 +95,39 @@ canvas {
|
|
77 |
}
|
78 |
|
79 |
input {
|
80 |
-
margin:
|
81 |
size: 200;
|
82 |
-
position: relative;
|
|
|
83 |
}
|
84 |
|
85 |
button {
|
86 |
-
|
|
|
87 |
margin: 1rem;
|
88 |
size: 50;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
* {
|
2 |
box-sizing: border-box;
|
3 |
+
padding: 1rem;
|
4 |
margin: 0;
|
5 |
+
font-family: "Fira Code VF", monospace;
|
6 |
}
|
7 |
|
8 |
html,
|
9 |
body {
|
10 |
+
margin: 0;
|
11 |
height: 100%;
|
12 |
+
padding: 0;
|
13 |
}
|
14 |
|
15 |
body,
|
|
|
20 |
align-items: center;
|
21 |
}
|
22 |
|
23 |
+
a {
|
24 |
+
color: #F1678E;
|
25 |
+
}
|
26 |
+
|
27 |
+
p {
|
28 |
+
padding: 1rem;
|
29 |
+
}
|
30 |
+
|
31 |
+
h1,h2,h3,h4,h5 {
|
32 |
+
color: #F1678E;
|
33 |
+
padding: 1rem;
|
34 |
+
}
|
35 |
+
|
36 |
+
div {
|
37 |
+
padding: 0;
|
38 |
+
}
|
39 |
+
|
40 |
#container {
|
41 |
position: relative;
|
42 |
gap: 0.4rem;
|
|
|
95 |
}
|
96 |
|
97 |
input {
|
98 |
+
margin: 1rem;
|
99 |
size: 200;
|
100 |
+
/* position: relative; */
|
101 |
+
font-size: 12pt;
|
102 |
}
|
103 |
|
104 |
button {
|
105 |
+
/* position: relative; */
|
106 |
+
font-size: 16px;
|
107 |
margin: 1rem;
|
108 |
size: 50;
|
109 |
+
padding: 1rem 2rem;
|
110 |
+
cursor: pointer;
|
111 |
+
border-radius: 4px;
|
112 |
+
border: 0;
|
113 |
+
}
|
114 |
+
|
115 |
+
button:hover {
|
116 |
+
background-color: #e3e3e3;
|
117 |
}
|
118 |
|
119 |
+
button:active {
|
120 |
+
background-color: #d7d7d7;
|
121 |
+
}
|
122 |
+
|
123 |
+
button.submit {
|
124 |
+
background-color: #F1678E;
|
125 |
+
}
|
126 |
+
|
127 |
+
button.submit:hover {
|
128 |
+
background-color: #df5f83;
|
129 |
+
}
|
130 |
+
|
131 |
+
button.submit:active {
|
132 |
+
background-color: #cb5677;
|
133 |
+
}
|