Sarah Ciston commited on
Commit
1a66e6f
1 Parent(s): 47d8484

updated CSS more

Browse files
Files changed (3) hide show
  1. index.html +1 -1
  2. sketch.js +17 -13
  3. style.css +5 -3
index.html CHANGED
@@ -11,7 +11,7 @@
11
  </head>
12
 
13
  <body>
14
- <main>
15
  <!-- <h1>p5.js Critical AI Prompt Battle</h1> -->
16
  <!-- <label id="container" for="upload"> -->
17
  <!-- <svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg"> -->
 
11
  </head>
12
 
13
  <body>
14
+ <main class="main">
15
  <!-- <h1>p5.js Critical AI Prompt Battle</h1> -->
16
  <!-- <label id="container" for="upload"> -->
17
  <!-- <svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg"> -->
sketch.js CHANGED
@@ -14,7 +14,8 @@ const inference = new HfInference();
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 = []
@@ -23,7 +24,7 @@ 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
@@ -49,22 +50,26 @@ new p5(function(p5){
49
  function makeInterface(){
50
  console.log('reached makeInterface')
51
  let title = p5.createElement('h1', 'p5.js Critical AI Prompt Battle')
52
- title.position(0,50)
 
 
 
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("");
@@ -80,13 +85,15 @@ new p5(function(p5){
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:");
@@ -112,17 +119,14 @@ new p5(function(p5){
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
  }
 
14
 
15
 
16
 
17
+ let PROMPT, promptResult, submitButton, addButton, promptInput, inputValues, modelDisplay, modelResult
18
+
19
  // const detector = await pipeline('text-generation', 'meta-llama/Meta-Llama-3-8B', 'Xenova/LaMini-Flan-T5-783M');
20
 
21
  let blankArray = []
 
24
  // 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')
25
 
26
 
27
+ var 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.`
28
 
29
 
30
  ///// p5 STUFF
 
50
  function makeInterface(){
51
  console.log('reached makeInterface')
52
  let title = p5.createElement('h1', 'p5.js Critical AI Prompt Battle')
53
+ // title.position(0,50)
54
+
55
+ p5.createElement('p',`This is a new paragraph.`)
56
+ // .position(0,100)
57
 
58
  promptInput = p5.createInput("")
59
+ // promptInput.position(0,160)
60
  promptInput.size(600);
61
+ promptInput.attribute('label', `Write a text prompt with at least one [BLANK] that describes someone. You can also write [FILL] where you want the bot to fill in a word on its own.`)
62
  promptInput.value(`The [BLANK] works as a [FILL] but wishes for...`)
63
  promptInput.addClass("prompt")
64
+ p5.createP(promptInput.attribute('label'))
65
+ // .position(0,100)
66
 
67
  //make for loop to generate
68
  //make a button to make another
69
  //add them to the list of items
70
  fieldsDiv = p5.createDiv()
71
  fieldsDiv.id('fieldsDiv')
72
+ // fieldsDiv.position(0,250)
73
 
74
  // initial code to make a single field
75
  // blankA = p5.createInput("");
 
85
 
86
  // send prompt to model
87
  submitButton = p5.createButton("SUBMIT")
88
+ // submitButton.position(0,600)
89
+ submitButton.size(200)
90
  submitButton.class('submit');
91
  submitButton.mousePressed(getInputs)
92
 
93
  // add more blanks to fill in
94
  addButton = p5.createButton("more blanks")
95
+ addButton.size(200)
96
+ // addButton.position(150,600)
97
  addButton.mousePressed(addField)
98
 
99
  // modelDisplay = p5.createElement("p", "Results:");
 
119
 
120
  // Cap the number of fields, avoids token limit in prompt
121
  let blanks = document.querySelectorAll(".blank")
122
+ if (blanks.length > 7){
123
  console.log(blanks.length)
124
  addButton.style('visibility','hidden')
125
  }
126
  }
127
 
128
  function getInputs(){
 
 
129
  // Map the list of blanks text values to a new list
 
130
  let inputValues = blankArray.map(i => i.value())
131
  console.log(inputValues)
132
  }
style.css CHANGED
@@ -17,7 +17,7 @@ body,
17
  display: flex;
18
  flex-direction: column;
19
  justify-content: center;
20
- align-items: center;
21
  }
22
 
23
  a {
@@ -26,11 +26,13 @@ a {
26
 
27
  p {
28
  padding: 1rem;
 
29
  }
30
 
31
  h1,h2,h3,h4,h5 {
32
  color: #F1678E;
33
  padding: 1rem;
 
34
  }
35
 
36
  div {
@@ -102,10 +104,10 @@ input {
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;
 
17
  display: flex;
18
  flex-direction: column;
19
  justify-content: center;
20
+ align-items: left;
21
  }
22
 
23
  a {
 
26
 
27
  p {
28
  padding: 1rem;
29
+ float: left;
30
  }
31
 
32
  h1,h2,h3,h4,h5 {
33
  color: #F1678E;
34
  padding: 1rem;
35
+ float: left;
36
  }
37
 
38
  div {
 
104
  }
105
 
106
  button {
107
+ float: left;
108
  font-size: 16px;
109
  margin: 1rem;
110
+ /* size: 200; */
111
  padding: 1rem 2rem;
112
  cursor: pointer;
113
  border-radius: 4px;