Sarah Ciston
commited on
Commit
·
9a92806
1
Parent(s):
283a922
back to new pipeline test og
Browse files
sketch.js
CHANGED
@@ -16,7 +16,12 @@ import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers
|
|
16 |
|
17 |
// establish global variables
|
18 |
|
19 |
-
let
|
|
|
|
|
|
|
|
|
|
|
20 |
modelDisplay,
|
21 |
modelResult;
|
22 |
|
@@ -89,14 +94,14 @@ new p5(function (p5) {
|
|
89 |
// // BUTTONS // //
|
90 |
|
91 |
// send prompt to model
|
92 |
-
|
93 |
// submitButton.position(0,500)
|
94 |
submitButton.size(200)
|
95 |
submitButton.class('submit');
|
96 |
submitButton.mousePressed(getInputs)
|
97 |
|
98 |
// add more blanks to fill in
|
99 |
-
|
100 |
addButton.size(200)
|
101 |
// addButton.position(220,500)
|
102 |
addButton.mousePressed(addField)
|
@@ -130,21 +135,21 @@ new p5(function (p5) {
|
|
130 |
console.log(INPUTVALUES)
|
131 |
|
132 |
// Do model stuff in this function instead of in general
|
133 |
-
|
134 |
|
135 |
// BLANKS = inputValues // get ready to feed array list into model
|
136 |
|
137 |
-
|
138 |
|
139 |
// we pass PROMPT and PREPROMPT to the model function, don't need to pass INPUTVALUES bc it's passed into the PREPROMPT already here
|
140 |
|
141 |
modelResult = await runModel(PREPROMPT, PROMPT)
|
142 |
|
143 |
-
displayModel(modelResult)
|
144 |
}
|
145 |
|
146 |
async function displayModel(m){
|
147 |
-
|
148 |
await modelDisplay.html(m)
|
149 |
}
|
150 |
|
|
|
16 |
|
17 |
// establish global variables
|
18 |
|
19 |
+
let PROMPT,
|
20 |
+
PREPROMPT,
|
21 |
+
promptResult,
|
22 |
+
submitButton,
|
23 |
+
addButton,
|
24 |
+
promptInput,
|
25 |
modelDisplay,
|
26 |
modelResult;
|
27 |
|
|
|
94 |
// // BUTTONS // //
|
95 |
|
96 |
// send prompt to model
|
97 |
+
submitButton = p5.createButton("SUBMIT")
|
98 |
// submitButton.position(0,500)
|
99 |
submitButton.size(200)
|
100 |
submitButton.class('submit');
|
101 |
submitButton.mousePressed(getInputs)
|
102 |
|
103 |
// add more blanks to fill in
|
104 |
+
addButton = p5.createButton("more blanks")
|
105 |
addButton.size(200)
|
106 |
// addButton.position(220,500)
|
107 |
addButton.mousePressed(addField)
|
|
|
135 |
console.log(INPUTVALUES)
|
136 |
|
137 |
// Do model stuff in this function instead of in general
|
138 |
+
PROMPT = promptInput.value() // updated check of the prompt field
|
139 |
|
140 |
// BLANKS = inputValues // get ready to feed array list into model
|
141 |
|
142 |
+
PREPROMPT = `Please return an array of sentences. In each sentence, fill in the [BLANK] in the following sentence with each word I provide in the array ${INPUTVALUES}. Replace any [FILL] with an appropriate word of your choice.`
|
143 |
|
144 |
// we pass PROMPT and PREPROMPT to the model function, don't need to pass INPUTVALUES bc it's passed into the PREPROMPT already here
|
145 |
|
146 |
modelResult = await runModel(PREPROMPT, PROMPT)
|
147 |
|
148 |
+
await displayModel(modelResult)
|
149 |
}
|
150 |
|
151 |
async function displayModel(m){
|
152 |
+
modelDisplay = p5.createElement("p", "Results:");
|
153 |
await modelDisplay.html(m)
|
154 |
}
|
155 |
|