Spaces:
Running
Running
add blanks fields
Browse files
sketch.js
CHANGED
@@ -6,7 +6,7 @@ import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers
|
|
6 |
env.allowLocalModels = false;
|
7 |
|
8 |
// GLOBAL VARIABLES
|
9 |
-
let blankArray = ["woman", "man", "non-binary person"]
|
10 |
let PREPROMPT = `Please continue the story, and fill any [MASK] with your own words:`
|
11 |
// let PREPROMPT = `Please complete the phrase and fill in any [MASK]: `
|
12 |
let PROMPT_INPUT = `The [BLANK] has a job as a [MASK] but...` // a field for writing or changing a text value
|
@@ -30,7 +30,7 @@ async function textGenTask(pre, prompt, blanks){
|
|
30 |
|
31 |
// create combined fill prompt
|
32 |
let INPUT = promptArray.toString()
|
33 |
-
console.log(
|
34 |
// let INPUT = pre + prompt // simple concatenated input
|
35 |
// let INPUT = prompt // basic prompt input
|
36 |
|
@@ -149,6 +149,27 @@ new p5(function (p5){
|
|
149 |
pField.attribute('label', `Write a text prompt with one [MASK] that the model will fill in.`)
|
150 |
p5.createP(pField.attribute('label'))
|
151 |
pField.addClass("prompt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
|
154 |
function makeButtons(){
|
|
|
6 |
env.allowLocalModels = false;
|
7 |
|
8 |
// GLOBAL VARIABLES
|
9 |
+
let blankArray = [] // e.g. ["woman", "man", "non-binary person"]
|
10 |
let PREPROMPT = `Please continue the story, and fill any [MASK] with your own words:`
|
11 |
// let PREPROMPT = `Please complete the phrase and fill in any [MASK]: `
|
12 |
let PROMPT_INPUT = `The [BLANK] has a job as a [MASK] but...` // a field for writing or changing a text value
|
|
|
30 |
|
31 |
// create combined fill prompt
|
32 |
let INPUT = promptArray.toString()
|
33 |
+
console.log(INPUT)
|
34 |
// let INPUT = pre + prompt // simple concatenated input
|
35 |
// let INPUT = prompt // basic prompt input
|
36 |
|
|
|
149 |
pField.attribute('label', `Write a text prompt with one [MASK] that the model will fill in.`)
|
150 |
p5.createP(pField.attribute('label'))
|
151 |
pField.addClass("prompt")
|
152 |
+
|
153 |
+
fieldsDiv = p5.createDiv()
|
154 |
+
fieldsDiv.id('fieldsDiv')
|
155 |
+
|
156 |
+
addField()
|
157 |
+
}
|
158 |
+
|
159 |
+
function addField(){
|
160 |
+
let f = p5.createInput("")
|
161 |
+
f.class("blank")
|
162 |
+
f.parent("#fieldsDiv")
|
163 |
+
|
164 |
+
blankArray.push(f)
|
165 |
+
console.log("made field")
|
166 |
+
|
167 |
+
// Cap the number of fields, avoids token limit in prompt
|
168 |
+
let blanks = document.querySelectorAll(".blank")
|
169 |
+
if (blanks.length > 5){
|
170 |
+
console.log(blanks.length)
|
171 |
+
addButton.style('visibility','hidden')
|
172 |
+
}
|
173 |
}
|
174 |
|
175 |
function makeButtons(){
|