Sarah Ciston
commited on
Commit
·
d483a10
1
Parent(s):
37c8ccd
remove global vars and awaits
Browse files- sketch.js +6 -9
- tutorial.mdx +21 -7
sketch.js
CHANGED
@@ -18,9 +18,6 @@ import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers
|
|
18 |
|
19 |
let PROMPT,
|
20 |
PREPROMPT,
|
21 |
-
promptResult,
|
22 |
-
submitButton,
|
23 |
-
addButton,
|
24 |
promptInput,
|
25 |
modelDisplay,
|
26 |
modelResult;
|
@@ -94,14 +91,14 @@ new p5(function (p5) {
|
|
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)
|
@@ -145,12 +142,12 @@ new p5(function (p5) {
|
|
145 |
|
146 |
modelResult = await runModel(PREPROMPT, PROMPT)
|
147 |
|
148 |
-
|
149 |
}
|
150 |
|
151 |
-
|
152 |
-
modelDisplay = p5.createElement("p", "Results:");
|
153 |
-
|
154 |
}
|
155 |
|
156 |
// async function showResults(){
|
|
|
18 |
|
19 |
let PROMPT,
|
20 |
PREPROMPT,
|
|
|
|
|
|
|
21 |
promptInput,
|
22 |
modelDisplay,
|
23 |
modelResult;
|
|
|
91 |
// // BUTTONS // //
|
92 |
|
93 |
// send prompt to model
|
94 |
+
let submitButton = p5.createButton("SUBMIT")
|
95 |
// submitButton.position(0,500)
|
96 |
submitButton.size(200)
|
97 |
submitButton.class('submit');
|
98 |
submitButton.mousePressed(getInputs)
|
99 |
|
100 |
// add more blanks to fill in
|
101 |
+
let addButton = p5.createButton("more blanks")
|
102 |
addButton.size(200)
|
103 |
// addButton.position(220,500)
|
104 |
addButton.mousePressed(addField)
|
|
|
142 |
|
143 |
modelResult = await runModel(PREPROMPT, PROMPT)
|
144 |
|
145 |
+
displayModel(modelResult)
|
146 |
}
|
147 |
|
148 |
+
function displayModel(m){
|
149 |
+
let modelDisplay = p5.createElement("p", "Results:");
|
150 |
+
modelDisplay.html(m) // do these need to be async??
|
151 |
}
|
152 |
|
153 |
// async function showResults(){
|
tutorial.mdx
CHANGED
@@ -1,9 +1,14 @@
|
|
1 |
---
|
2 |
title: Critical AI Prompt Battle
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
5 |
---
|
6 |
|
|
|
|
|
7 |
# p5.js Critical AI Prompt Battle
|
8 |
By Sarah Ciston
|
9 |
With Emily Martinez and Minne Atairu
|
@@ -28,18 +33,27 @@ Unfortunately, the sleek chatbot interface hides all the decision-making that le
|
|
28 |
|
29 |
Steps
|
30 |
|
31 |
-
1. Make a copy of your toolkit prototype from Tutorial One and rename it "Critical AI Prompt Battle" to follow along. To jump ahead, you can make a copy of the finished example
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
|
36 |
|
37 |
-
|
38 |
Set PREPROMPT = `Return an array of sentences. In each sentence, fill in the [BLANK] in the following sentence with each word I provide in the array ${blankArray}. Replace any [FILL] with an appropriate word of your choice.`
|
39 |
|
40 |
|
41 |
|
42 |
-
5. [PSEUDOCODE] Add async function runModel() wrapping HF API await
|
43 |
|
44 |
6. [PSEUDOCODE] Add model results processing with await
|
45 |
|
|
|
1 |
---
|
2 |
title: Critical AI Prompt Battle
|
3 |
+
author: Sarah Ciston
|
4 |
+
editors:
|
5 |
+
- Emily Martinez
|
6 |
+
- Minne Atairu
|
7 |
+
category: critical-ai
|
8 |
---
|
9 |
|
10 |
+
<!-- more background: https://huggingface.co/tasks/text-generation -->
|
11 |
+
|
12 |
# p5.js Critical AI Prompt Battle
|
13 |
By Sarah Ciston
|
14 |
With Emily Martinez and Minne Atairu
|
|
|
33 |
|
34 |
Steps
|
35 |
|
36 |
+
1. Make a copy of your toolkit prototype from [Tutorial One]([XXX]) and rename it "Critical AI Prompt Battle" to follow along. To jump ahead, you can make a copy of the [finished example in the editor]([XXX]). But we really encourage you to type along with us!
|
37 |
+
|
38 |
+
2. [PSEUDOCODE] Add the inference/pipeline module to the top.
|
39 |
+
|
40 |
+
- Create global variables to use later. Declare these now so that they can be used in various functions throughout the project. (eg MODEL, PROMPT, PREPROMPT, BLANKS, blankArray, etc)
|
41 |
|
42 |
+
```javascript
|
43 |
+
let PREPROMPT,
|
44 |
+
promptInput,
|
45 |
+
modelDisplay,
|
46 |
+
modelResult;
|
47 |
+
```
|
48 |
|
49 |
+
1. [PSEUDOCODE] Add the model of choice to the README.md and sketch.js
|
50 |
|
51 |
+
2. [PSEUDOCODE] Write instructions for your model.
|
52 |
Set PREPROMPT = `Return an array of sentences. In each sentence, fill in the [BLANK] in the following sentence with each word I provide in the array ${blankArray}. Replace any [FILL] with an appropriate word of your choice.`
|
53 |
|
54 |
|
55 |
|
56 |
+
5. [PSEUDOCODE] Add async function runModel() wrapping HF API await. {// explain link to await} explain
|
57 |
|
58 |
6. [PSEUDOCODE] Add model results processing with await
|
59 |
|