diff --git a/ui/.eslintrc.cjs b/ui/.eslintrc.cjs
index ebc1958..bcbbb98 100644
--- a/ui/.eslintrc.cjs
+++ b/ui/.eslintrc.cjs
@@ -17,14 +17,5 @@ module.exports = {
browser: true,
es2017: true,
node: true
- },
- overrides: [
- {
- files: ['*.svelte'],
- parser: 'svelte-eslint-parser',
- parserOptions: {
- parser: '@typescript-eslint/parser'
- }
- }
- ]
+ }
};
diff --git a/ui/.gitignore b/ui/.gitignore
index 6635cf5..b57c59b 100644
--- a/ui/.gitignore
+++ b/ui/.gitignore
@@ -8,3 +8,5 @@ node_modules
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
+
+archive/
\ No newline at end of file
diff --git a/ui/package-lock.json b/ui/package-lock.json
index 66191e6..3c8edb5 100644
--- a/ui/package-lock.json
+++ b/ui/package-lock.json
@@ -8,7 +8,7 @@
"name": "ui",
"version": "0.0.1",
"devDependencies": {
- "@candlecorp/wick": "^0.2.1",
+ "@candlecorp/wick": "^0.2.2",
"@msgpack/msgpack": "^3.0.0-beta2",
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-static": "^2.0.3",
@@ -148,9 +148,9 @@
}
},
"node_modules/@candlecorp/wick": {
- "version": "0.2.1",
- "resolved": "https://registry.npmjs.org/@candlecorp/wick/-/wick-0.2.1.tgz",
- "integrity": "sha512-z66WJDw/thYX20sBoBtqPE7ozm51aGWSFiA6NsHv3PQ9UaAXSyhfavA5BmRp7Yyjy/RXPA/Hl38Ev0BprZUm+w==",
+ "version": "0.2.2",
+ "resolved": "https://registry.npmjs.org/@candlecorp/wick/-/wick-0.2.2.tgz",
+ "integrity": "sha512-/c90iwyL/b66GYDrgaIGq7p8+zxQL1Wn8lflJNLSoub+wpi4DbAyKKLdRn3XBHVIaKuyfwfLjIKqrS/gOGJjNg==",
"dev": true,
"dependencies": {
"@candlecorp/rsocket-adapter-rxjs": "^0.0.1",
diff --git a/ui/package.json b/ui/package.json
index 309f6c9..e5ac2c0 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -12,7 +12,7 @@
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
- "@candlecorp/wick": "^0.2.1",
+ "@candlecorp/wick": "^0.2.2",
"@msgpack/msgpack": "^3.0.0-beta2",
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-static": "^2.0.3",
diff --git a/ui/src/components/BundleDownload.svelte b/ui/src/components/BundleDownload.svelte
index f6c65ac..07b59f8 100644
--- a/ui/src/components/BundleDownload.svelte
+++ b/ui/src/components/BundleDownload.svelte
@@ -77,8 +77,8 @@
pill
class="mt-2"
on:click={startDownload}
- type="submit"
- disabled={(bundles[selectedBundle] || {}).ready}>Download FilesDownload Bundle
{/if}
diff --git a/ui/src/components/DemoItem.svelte b/ui/src/components/DemoItem.svelte
new file mode 100644
index 0000000..c187393
--- /dev/null
+++ b/ui/src/components/DemoItem.svelte
@@ -0,0 +1,13 @@
+
+
+
diff --git a/ui/src/components/Header.svelte b/ui/src/components/Header.svelte
index 0d7d536..53ea1e7 100644
--- a/ui/src/components/Header.svelte
+++ b/ui/src/components/Header.svelte
@@ -7,25 +7,32 @@
NavHamburger,
Dropdown,
DropdownItem,
- DropdownDivider
} from 'flowbite-svelte';
- import { GithubSolid } from 'flowbite-svelte-icons';
import { ChevronDownOutline } from 'flowbite-svelte-icons';
import { page } from '$app/stores';
$: activeUrl = $page.url.pathname;
-
-
-
+
+
+
+
+
+
-
Home
- Llama2
+ Text Generation
Object detection
@@ -35,14 +42,12 @@
-
-
Home
Examples
- Llama Text Generation
+ Text Generation
Object detection
Text Redaction
diff --git a/ui/src/components/Section.svelte b/ui/src/components/Section.svelte
new file mode 100644
index 0000000..64a1133
--- /dev/null
+++ b/ui/src/components/Section.svelte
@@ -0,0 +1,13 @@
+
+
+
+ {#if header}
+
{header}
+ {/if}
+
+
+
+
diff --git a/ui/src/components/Terminal.svelte b/ui/src/components/Terminal.svelte
new file mode 100644
index 0000000..59666a0
--- /dev/null
+++ b/ui/src/components/Terminal.svelte
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {#each lines as line}
+
+ >
+ {line.command}
+
+
+ {#if line.output}
+
+ {#each line.output.split('\n') as outputLine}
+ {outputLine}
+ {/each}
+
+ {/if}
+ {/each}
+
+
+
diff --git a/ui/src/routes/+layout.svelte b/ui/src/routes/+layout.svelte
index 33d8336..1e244ff 100644
--- a/ui/src/routes/+layout.svelte
+++ b/ui/src/routes/+layout.svelte
@@ -4,8 +4,8 @@
-
-
+
diff --git a/ui/src/routes/+page.svelte b/ui/src/routes/+page.svelte
index 4ae138a..2f3931e 100644
--- a/ui/src/routes/+page.svelte
+++ b/ui/src/routes/+page.svelte
@@ -1,32 +1,39 @@
-
- Unleash the true potential of WebAssembly. Run the same code on the server, client, mobile,
- command line, APIs, workers, anywhere.
-
+
Bring WebAssembly Everywhere.
+
Run the same binaries on the server, client, mobile, CLI, APIs, workers, and beyond.
-
+
+
-
-
Llama2
-
- Dramatically reduce server compute costs with Wick by running the same models on the client
- as you do the server.
-
-
Llama2 Example
-
-
-
-
Text Redaction
-
- Consistent redact PII across different languages and different environments, from server to
- edge to client.
-
-
Redaction Example
-
+ {#each demos as demo}
+
+ {/each}
-
+
diff --git a/ui/src/routes/llama2/+page.svelte b/ui/src/routes/llama2/+page.svelte
index 6c9dffa..3d29345 100644
--- a/ui/src/routes/llama2/+page.svelte
+++ b/ui/src/routes/llama2/+page.svelte
@@ -3,12 +3,14 @@
import { Alert, Button, Textarea } from 'flowbite-svelte';
import { writable, type Writable } from 'svelte/store';
- import { decode, encode } from '@msgpack/msgpack';
- import { from } from 'rxjs';
- import { Packet, WasmRsComponent } from '@candlecorp/wick';
- import { instantiateComponentWorker } from '$lib/workers';
+ import { decode } from '@msgpack/msgpack';
import { bundles } from './bundles.js';
import { onDestroy } from 'svelte';
+ import { cleanup, invoke } from './processor.js';
+ import Section from '../../components/Section.svelte';
+ import Terminal from '../../components/Terminal.svelte';
+ import { cli } from './wick-output.js';
+ import { description, header } from '../../styles';
let selectedBundle = 'stories15M';
@@ -40,35 +42,17 @@
{ sender: 'prompt', message: prompt.trim() },
{ sender: 'response', message: '' }
]);
- const aiMessageIndex = $generationHistory.length;
- await invoke(prompt, aiMessageIndex - 1);
- }
-
- let component: WasmRsComponent | undefined;
-
- async function invoke(input: string, aiMessageIndex: number): Promise
{
- if (!component) {
- const c = await instantiateComponentWorker('/components/llama.signed.wasm');
-
- component = c;
- }
- const instance = await component.instantiate({
- config: {
- model_dir: '/',
- model: `${selectedBundle}.bin`,
- tokenizer: 'tokenizer.json'
- }
- });
-
- const stream = from([new Packet('prompt', encode(input)), Packet.Done('prompt')]);
- const result = await instance.invoke('generate', stream, { max_length: 512 });
+ const aiMessageIndex = $generationHistory.length - 1;
+ const output = await invoke(selectedBundle, prompt);
state = State.Responding;
- result.subscribe({
+ output.subscribe({
next(packet) {
if (!packet.data) {
console.log('no data');
return;
}
+ console.log({ packet });
+
const word = decode(packet.data);
generationHistory.update((value) => {
const updatedValue = [...value];
@@ -95,64 +79,83 @@
}
}
- onDestroy(() => {
- if (component) {
- component.terminate();
- }
- });
+ onDestroy(cleanup);
-
-
-
-
-
+
+
+
+
+
+
-
-
-
- {#each $generationHistory as { sender, message }, index}
- {#if sender === 'prompt'}
- {message}
- {:else}
- {message}
-
-
- {/if}
- {/each}
-
+
+
+
+
+ {#each $generationHistory as { sender, message }, index}
+ {#if sender === 'prompt'}
+ {message}
+ {:else}
+ {message}
+
+
+ {/if}
+ {/each}
-
+
+
+ Use the following command to run this in your terminal:
+
+ For example:
+
+
diff --git a/ui/src/routes/llama2/processor.ts b/ui/src/routes/llama2/processor.ts
new file mode 100644
index 0000000..9ce84c8
--- /dev/null
+++ b/ui/src/routes/llama2/processor.ts
@@ -0,0 +1,32 @@
+import { instantiateComponentWorker } from '$lib/workers';
+import { Packet, type WasmRsComponent } from '@candlecorp/wick';
+import { encode } from '@msgpack/msgpack';
+import { Observable, from } from 'rxjs';
+
+let component: WasmRsComponent | undefined;
+
+export async function invoke(model: string, input: string): Promise
> {
+ if (!component) {
+ const c = await instantiateComponentWorker('/components/llama.signed.wasm');
+
+ component = c;
+ }
+ const instance = await component.instantiate({
+ config: {
+ model_dir: '/',
+ model: `${model}.bin`,
+ tokenizer: 'tokenizer.json'
+ }
+ });
+
+ const stream = from([new Packet('prompt', encode(input)), Packet.Done('prompt')]);
+ const result = await instance.invoke('generate', stream, { max_length: 512 });
+ return result;
+}
+
+export function cleanup() {
+ if (component) {
+ component.terminate();
+ component = undefined;
+ }
+}
diff --git a/ui/src/routes/llama2/wick-output.ts b/ui/src/routes/llama2/wick-output.ts
new file mode 100644
index 0000000..9129782
--- /dev/null
+++ b/ui/src/routes/llama2/wick-output.ts
@@ -0,0 +1,265 @@
+import type { Line } from '../../components/Terminal.svelte';
+
+export const cli: Line[] = [
+ {
+ command:
+ 'wick invoke candle_ml/llama2:0.0.1 generate --with=@config.json -- --prompt="One day"',
+ output: [
+ { payload: { value: ',' }, port: 'output' },
+ { payload: { value: ' a' }, port: 'output' },
+ { payload: { value: ' little' }, port: 'output' },
+ { payload: { value: ' girl' }, port: 'output' },
+ { payload: { value: ' named' }, port: 'output' },
+ { payload: { value: ' L' }, port: 'output' },
+ { payload: { value: 'ily' }, port: 'output' },
+ { payload: { value: ' went' }, port: 'output' },
+ { payload: { value: ' to' }, port: 'output' },
+ { payload: { value: ' the' }, port: 'output' },
+ { payload: { value: ' park' }, port: 'output' },
+ { payload: { value: ' with' }, port: 'output' },
+ { payload: { value: ' her' }, port: 'output' },
+ { payload: { value: ' mom' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' They' }, port: 'output' },
+ { payload: { value: ' saw' }, port: 'output' },
+ { payload: { value: ' a' }, port: 'output' },
+ { payload: { value: ' big' }, port: 'output' },
+ { payload: { value: ' tree' }, port: 'output' },
+ { payload: { value: ' with' }, port: 'output' },
+ { payload: { value: ' many' }, port: 'output' },
+ { payload: { value: ' leaves' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' L' }, port: 'output' },
+ { payload: { value: 'ily' }, port: 'output' },
+ { payload: { value: ' wanted' }, port: 'output' },
+ { payload: { value: ' to' }, port: 'output' },
+ { payload: { value: ' clim' }, port: 'output' },
+ { payload: { value: 'b' }, port: 'output' },
+ { payload: { value: ' the' }, port: 'output' },
+ { payload: { value: ' tree' }, port: 'output' },
+ { payload: { value: ' and' }, port: 'output' },
+ { payload: { value: ' see' }, port: 'output' },
+ { payload: { value: ' how' }, port: 'output' },
+ { payload: { value: ' high' }, port: 'output' },
+ { payload: { value: ' she' }, port: 'output' },
+ { payload: { value: ' could' }, port: 'output' },
+ { payload: { value: ' go' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' Her' }, port: 'output' },
+ { payload: { value: ' mom' }, port: 'output' },
+ { payload: { value: ' said' }, port: 'output' },
+ { payload: { value: ',' }, port: 'output' },
+ { payload: { value: ' "' }, port: 'output' },
+ { payload: { value: 'Be' }, port: 'output' },
+ { payload: { value: ' careful' }, port: 'output' },
+ { payload: { value: ',' }, port: 'output' },
+ { payload: { value: ' L' }, port: 'output' },
+ { payload: { value: 'ily' }, port: 'output' },
+ { payload: { value: '!"' }, port: 'output' },
+ { payload: { value: '\n' }, port: 'output' },
+ { payload: { value: 'L' }, port: 'output' },
+ { payload: { value: 'ily' }, port: 'output' },
+ { payload: { value: ' started' }, port: 'output' },
+ { payload: { value: ' to' }, port: 'output' },
+ { payload: { value: ' clim' }, port: 'output' },
+ { payload: { value: 'b' }, port: 'output' },
+ { payload: { value: ' the' }, port: 'output' },
+ { payload: { value: ' tree' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' She' }, port: 'output' },
+ { payload: { value: ' was' }, port: 'output' },
+ { payload: { value: ' very' }, port: 'output' },
+ { payload: { value: ' happy' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' But' }, port: 'output' },
+ { payload: { value: ' then' }, port: 'output' },
+ { payload: { value: ',' }, port: 'output' },
+ { payload: { value: ' she' }, port: 'output' },
+ { payload: { value: ' saw' }, port: 'output' },
+ { payload: { value: ' a' }, port: 'output' },
+ { payload: { value: ' small' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: ' on' }, port: 'output' },
+ { payload: { value: ' a' }, port: 'output' },
+ { payload: { value: ' branch' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' The' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: ' looked' }, port: 'output' },
+ { payload: { value: ' sad' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' L' }, port: 'output' },
+ { payload: { value: 'ily' }, port: 'output' },
+ { payload: { value: ' asked' }, port: 'output' },
+ { payload: { value: ' the' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: ',' }, port: 'output' },
+ { payload: { value: ' "' }, port: 'output' },
+ { payload: { value: 'Why' }, port: 'output' },
+ { payload: { value: ' are' }, port: 'output' },
+ { payload: { value: ' you' }, port: 'output' },
+ { payload: { value: ' sad' }, port: 'output' },
+ { payload: { value: '?"' }, port: 'output' },
+ { payload: { value: ' The' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: ' said' }, port: 'output' },
+ { payload: { value: ',' }, port: 'output' },
+ { payload: { value: ' "' }, port: 'output' },
+ { payload: { value: 'I' }, port: 'output' },
+ { payload: { value: ' lost' }, port: 'output' },
+ { payload: { value: ' my' }, port: 'output' },
+ { payload: { value: ' friend' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' I' }, port: 'output' },
+ { payload: { value: ' can' }, port: 'output' },
+ { payload: { value: "'" }, port: 'output' },
+ { payload: { value: 't' }, port: 'output' },
+ { payload: { value: ' find' }, port: 'output' },
+ { payload: { value: ' her' }, port: 'output' },
+ { payload: { value: '."' }, port: 'output' },
+ { payload: { value: '\n' }, port: 'output' },
+ { payload: { value: 'L' }, port: 'output' },
+ { payload: { value: 'ily' }, port: 'output' },
+ { payload: { value: ' wanted' }, port: 'output' },
+ { payload: { value: ' to' }, port: 'output' },
+ { payload: { value: ' help' }, port: 'output' },
+ { payload: { value: ' the' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' She' }, port: 'output' },
+ { payload: { value: ' clim' }, port: 'output' },
+ { payload: { value: 'bed' }, port: 'output' },
+ { payload: { value: ' down' }, port: 'output' },
+ { payload: { value: ' the' }, port: 'output' },
+ { payload: { value: ' tree' }, port: 'output' },
+ { payload: { value: ' and' }, port: 'output' },
+ { payload: { value: ' went' }, port: 'output' },
+ { payload: { value: ' to' }, port: 'output' },
+ { payload: { value: ' look' }, port: 'output' },
+ { payload: { value: ' for' }, port: 'output' },
+ { payload: { value: ' the' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: "'" }, port: 'output' },
+ { payload: { value: 's' }, port: 'output' },
+ { payload: { value: ' friend' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' They' }, port: 'output' },
+ { payload: { value: ' looked' }, port: 'output' },
+ { payload: { value: ' everywhere' }, port: 'output' },
+ { payload: { value: ' but' }, port: 'output' },
+ { payload: { value: ' could' }, port: 'output' },
+ { payload: { value: ' not' }, port: 'output' },
+ { payload: { value: ' find' }, port: 'output' },
+ { payload: { value: ' them' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' Then' }, port: 'output' },
+ { payload: { value: ',' }, port: 'output' },
+ { payload: { value: ' L' }, port: 'output' },
+ { payload: { value: 'ily' }, port: 'output' },
+ { payload: { value: ' saw' }, port: 'output' },
+ { payload: { value: ' a' }, port: 'output' },
+ { payload: { value: ' big' }, port: 'output' },
+ { payload: { value: ' branch' }, port: 'output' },
+ { payload: { value: ' with' }, port: 'output' },
+ { payload: { value: ' many' }, port: 'output' },
+ { payload: { value: ' birds' }, port: 'output' },
+ { payload: { value: ' on' }, port: 'output' },
+ { payload: { value: ' it' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' She' }, port: 'output' },
+ { payload: { value: ' thought' }, port: 'output' },
+ { payload: { value: ' the' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: "'" }, port: 'output' },
+ { payload: { value: 's' }, port: 'output' },
+ { payload: { value: ' friend' }, port: 'output' },
+ { payload: { value: ' was' }, port: 'output' },
+ { payload: { value: ' there' }, port: 'output' },
+ { payload: { value: '!' }, port: 'output' },
+ { payload: { value: ' But' }, port: 'output' },
+ { payload: { value: ' when' }, port: 'output' },
+ { payload: { value: ' she' }, port: 'output' },
+ { payload: { value: ' got' }, port: 'output' },
+ { payload: { value: ' closer' }, port: 'output' },
+ { payload: { value: ',' }, port: 'output' },
+ { payload: { value: ' she' }, port: 'output' },
+ { payload: { value: ' saw' }, port: 'output' },
+ { payload: { value: ' that' }, port: 'output' },
+ { payload: { value: ' the' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: "'" }, port: 'output' },
+ { payload: { value: 's' }, port: 'output' },
+ { payload: { value: ' friend' }, port: 'output' },
+ { payload: { value: ' was' }, port: 'output' },
+ { payload: { value: ' not' }, port: 'output' },
+ { payload: { value: ' alone' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' The' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: ' had' }, port: 'output' },
+ { payload: { value: ' a' }, port: 'output' },
+ { payload: { value: ' baby' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: ' in' }, port: 'output' },
+ { payload: { value: ' its' }, port: 'output' },
+ { payload: { value: ' nest' }, port: 'output' },
+ { payload: { value: '!' }, port: 'output' },
+ { payload: { value: '\n' }, port: 'output' },
+ { payload: { value: 'L' }, port: 'output' },
+ { payload: { value: 'ily' }, port: 'output' },
+ { payload: { value: ' and' }, port: 'output' },
+ { payload: { value: ' her' }, port: 'output' },
+ { payload: { value: ' mom' }, port: 'output' },
+ { payload: { value: ' were' }, port: 'output' },
+ { payload: { value: ' surprised' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' They' }, port: 'output' },
+ { payload: { value: ' took' }, port: 'output' },
+ { payload: { value: ' the' }, port: 'output' },
+ { payload: { value: ' baby' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: ' home' }, port: 'output' },
+ { payload: { value: ' and' }, port: 'output' },
+ { payload: { value: ' put' }, port: 'output' },
+ { payload: { value: ' it' }, port: 'output' },
+ { payload: { value: ' back' }, port: 'output' },
+ { payload: { value: ' in' }, port: 'output' },
+ { payload: { value: ' the' }, port: 'output' },
+ { payload: { value: ' tree' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' The' }, port: 'output' },
+ { payload: { value: ' baby' }, port: 'output' },
+ { payload: { value: ' bird' }, port: 'output' },
+ { payload: { value: ' was' }, port: 'output' },
+ { payload: { value: ' happy' }, port: 'output' },
+ { payload: { value: ' again' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: ' L' }, port: 'output' },
+ { payload: { value: 'ily' }, port: 'output' },
+ { payload: { value: ' learned' }, port: 'output' },
+ { payload: { value: ' that' }, port: 'output' },
+ { payload: { value: ' sometimes' }, port: 'output' },
+ { payload: { value: ',' }, port: 'output' },
+ { payload: { value: ' unexpected' }, port: 'output' },
+ { payload: { value: ' things' }, port: 'output' },
+ { payload: { value: ' can' }, port: 'output' },
+ { payload: { value: ' happen' }, port: 'output' },
+ { payload: { value: ' when' }, port: 'output' },
+ { payload: { value: ' you' }, port: 'output' },
+ { payload: { value: ' help' }, port: 'output' },
+ { payload: { value: ' others' }, port: 'output' },
+ { payload: { value: '.' }, port: 'output' },
+ { payload: { value: '' }, port: 'output' },
+ { payload: { value: ' Once' }, port: 'output' },
+ { payload: { value: ' upon' }, port: 'output' },
+ { payload: { value: ' a' }, port: 'output' },
+ { payload: { value: ' time' }, port: 'output' },
+ { payload: { value: ',' }, port: 'output' },
+ { payload: { value: ' there' }, port: 'output' },
+ { payload: { value: ' was' }, port: 'output' },
+ { payload: { value: ' a' }, port: 'output' }
+ ]
+ .map((json) => JSON.stringify(json))
+ .join('\n')
+ }
+];
diff --git a/ui/src/routes/redact/+page.svelte b/ui/src/routes/redact/+page.svelte
index 0dd0947..5ace97f 100644
--- a/ui/src/routes/redact/+page.svelte
+++ b/ui/src/routes/redact/+page.svelte
@@ -3,12 +3,16 @@
import { Button, Textarea } from 'flowbite-svelte';
import { from } from 'rxjs';
import { Packet, WasmRsComponent } from '@candlecorp/wick';
- import { getComponentInstance, instantiateComponentWorker } from '$lib/workers';
+ import { instantiateComponentWorker } from '$lib/workers';
import { onDestroy } from 'svelte';
+ import Section from '../../components/Section.svelte';
+ import { description, header } from '../../styles';
+ import Terminal from '../../components/Terminal.svelte';
+ import { cli } from './wick-output.js';
let inputObj = {
name: 'John',
- age: 'thirty',
+ age: 30,
email: 'john@somewhere.com',
ssn: '123-45-6789',
ccn: '1234-5678-9012-3456'
@@ -30,7 +34,6 @@
const stream = from([new Packet('input', encode(sampleInput)), Packet.Done('input')]);
const result = await instance.invoke('regex', stream, {
- append_hash: true,
patterns: [
'\\b\\d\\d\\d-\\d\\d-\\d\\d\\d\\d\\b',
'\\b\\d\\d\\d\\d-\\d\\d\\d\\d-\\d\\d\\d\\d-\\d\\d\\d\\d\\b',
@@ -62,30 +65,40 @@
});
-
-
-
-
-
+
+
+
+ This demo uses the common/redact Wick component to redact text matching an expression.
+
+
+ It uses the
+ Wick framework to compile a regular expression engine
+ into WebAssembly. It demonstrates a way to have 100% consistent processing across environments using
+ the same configuration.
+
+
+
+
+
+ Redact
+
- Validate
-
-
+
+
+ Use the following command to run this in your terminal:
+
+ For example:
+
+
diff --git a/ui/src/routes/redact/wick-output.ts b/ui/src/routes/redact/wick-output.ts
new file mode 100644
index 0000000..0f7a353
--- /dev/null
+++ b/ui/src/routes/redact/wick-output.ts
@@ -0,0 +1,19 @@
+import type { Line } from '../../components/Terminal.svelte';
+
+export const cli: Line[] = [
+ {
+ command: 'cat config.json',
+ output: `{
+ "patterns": [
+ "\\b\\d\\d\\d-\\d\\d-\\d\\d\\d\\d\\b",
+ "\\b\\d\\d\\d\\d-\\d\\d\\d\\d-\\d\\d\\d\\d-\\d\\d\\d\\d\\b",
+ "\\b[a-zA-Z-.]+@([a-zA-Z-]+.)+[a-zA-Z-]{2,}\\b"
+ ]
+}`
+ },
+ {
+ command:
+ 'wick invoke common/redact:0.0.1 --op-with=@config.json regex -- --input="003-68-5339"',
+ output: '{"payload":{"value":"XXXXXXXXXXX"},"port":"output"}'
+ }
+];
diff --git a/ui/src/routes/yolo/+page.svelte b/ui/src/routes/yolo/+page.svelte
index 572f7d5..c011766 100644
--- a/ui/src/routes/yolo/+page.svelte
+++ b/ui/src/routes/yolo/+page.svelte
@@ -1,25 +1,14 @@
-
-
-
Select demo model
-
- Detect
-
-
-
-
+
+
+
+
{
@@ -241,7 +109,7 @@
on:change={onChange}
class="flex flex-col justify-center items-center w-full bg-gray-50 h-fit rounded-lg border-2 border-gray-300 border-dashed cursor-pointer dark:hover:bg-bray-800 dark:bg-gray-700 hover:bg-gray-100 dark:border-gray-600 dark:hover:border-gray-500 dark:hover:bg-gray-600"
>
- {#if !img}
+ {#if !chosenImage}
{/if}
-
-
- {#each examples as example, i}
-
exampleClick(i)}>
-
-
- {/each}
-
+ Or choose a sample image below
+
+ {#each examples as example, i}
+
exampleClick(i)} class="">
+
+
+ {/each}
+
+
+
+ Use the following command to run this in your terminal:
+
+ For example:
+
+