sarahciston commited on
Commit
60949e3
1 Parent(s): 5b9f0a6

Add static p5.js interface

Browse files
Files changed (1) hide show
  1. index.js +49 -3
index.js CHANGED
@@ -30,12 +30,58 @@ async function fillInTask(){
30
 
31
  // PROCESS MODEL OUTPUT
32
  // a generic function to pass in different model task functions
33
- async function getOutputs(mod){
34
- let output = await mod
35
 
36
  await output.forEach(o => {
37
  OUTPUT_LIST.push(o.sequence) // put only the full sequence in a list
38
  })
 
 
39
  }
40
 
41
- await getOutputs(fillInTask())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  // PROCESS MODEL OUTPUT
32
  // a generic function to pass in different model task functions
33
+ async function getOutputs(task){
34
+ let output = await task
35
 
36
  await output.forEach(o => {
37
  OUTPUT_LIST.push(o.sequence) // put only the full sequence in a list
38
  })
39
+
40
+ console.log(OUTPUT_LIST)
41
  }
42
 
43
+ // await getOutputs(fillInTask()) // getOutputs will run in the interface to display results
44
+
45
+
46
+
47
+ //// p5.js Instance
48
+
49
+ new p5(function (p5){
50
+ p5.setup = function(){
51
+ p5.noCanvas()
52
+ console.log('p5 instance loaded')
53
+ makeDisplayText()
54
+ makeFields()
55
+ makeButtons()
56
+ }
57
+
58
+ p5.draw = function(){
59
+ //
60
+ }
61
+
62
+ function makeDisplayText(){
63
+ let title = p5.createElement('h1','Critical AI Prompt Battle')
64
+ let subtitle = p5.createElement('h4','p5.js Critical AI Kit')
65
+ let caption = p5.createElement('caption',`This tool lets you run several AI chat prompts at once and compare their results. Use it to explore what models 'know' about various concepts, communities, and cultures. For more information on prompt programming and critical AI, see [Tutorial & extra info][TO-DO][XXX]`)
66
+ }
67
+
68
+ function makeFields(){
69
+ PROMPT_INPUT = p5.createInput(`The Black trans woman has a job as a [MASK].`) // access the text via PROMPT_INPUT.value()
70
+ promptInput.size(700)
71
+ promptInput.attribute('label', `Write a text prompt with at least one [MASK] that the model will fill in.`)
72
+ p5.createP(promptInput.attribute('label'))
73
+ promptInput.addClass("prompt")
74
+
75
+ }
76
+
77
+ function makeButtons(){
78
+ let submitButton = p5.createButton("SUBMIT")
79
+ submitButton.size(170)
80
+ submitButton.class('submit')
81
+ submitButton.mousePressed(getOutputs)
82
+ }
83
+
84
+ }
85
+
86
+
87
+