Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

434 edit delete assistants #510

Merged
merged 107 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
d3fbc32
add ui-test workflow
jalling97 Apr 24, 2024
8939555
add npm prefix
jalling97 Apr 24, 2024
d311db7
add trufflehog scans to workflows
jalling97 Apr 25, 2024
8d0bb03
Merge remote-tracking branch 'origin/main' into 407-ci-create-test-wo…
jalling97 Apr 25, 2024
488b65f
add UI linter to github workflows
jalling97 Apr 25, 2024
a62b4a8
add eslint to pre-commit
jalling97 Apr 25, 2024
bbfa0d4
fix: prettier and eslint issues
andrewrisse Apr 25, 2024
0f0cab6
add prettier to pre-commit
jalling97 Apr 26, 2024
4fc87ea
fix wording mistake
jalling97 Apr 26, 2024
03cdee8
change to npm ci vs install
jalling97 Apr 26, 2024
7021fcf
convert prettier to eslint plugin
jalling97 Apr 26, 2024
0b21f9c
update package.json and package-lock.json
jalling97 Apr 26, 2024
48c284e
merge in main and sync eslint between pre-commit and npm script
jalling97 Apr 29, 2024
0a42e8d
pin setup node actions version
jalling97 Apr 29, 2024
60a8e3b
Merge remote-tracking branch 'origin/main' into 407-ci-create-test-wo…
jalling97 Apr 29, 2024
228efdb
linting fixes
jalling97 Apr 29, 2024
2a0ac2d
fix: frontend eslint issues
andrewrisse Apr 29, 2024
02c3087
pin node version in package.json
jalling97 Apr 29, 2024
233537f
remove pre-commit comments
jalling97 Apr 29, 2024
beb9362
fix: merge conflicts, minor test update
andrewrisse Apr 30, 2024
bdb21f5
exclude .pre-commit-config.yaml from e2e workflow
jalling97 Apr 30, 2024
443e57c
catch .pre-commit-config.yaml in e2e-shim workflow
jalling97 Apr 30, 2024
81e8041
add ui-test-shim
jalling97 Apr 30, 2024
0ef7cc3
remove redundancy in secret-scan github action
jalling97 Apr 30, 2024
f5337cb
init - merge workflow branch and re-delete extra package-lock.json
andrewrisse Apr 30, 2024
7a4f26a
chore: refactor layouts and add layout for assistants page
andrewrisse Apr 30, 2024
ad0930d
wip: add initial tests and dynamic breadcrumbs
andrewrisse Apr 30, 2024
6770d81
change prettier
andrewrisse May 1, 2024
cfe43ec
chore: merge main and reformat
andrewrisse May 1, 2024
887f638
wip: add custom tooltip text input component
andrewrisse May 1, 2024
29321a5
fix: layout setup so footer can be on multiple pages
andrewrisse May 1, 2024
314d7c3
wip: add form
andrewrisse May 1, 2024
74796df
wip: add form 2
andrewrisse May 1, 2024
690a916
wip: form using svelte-forms-lib
andrewrisse May 1, 2024
47cf8bf
feat: assistants management page and create assistant
andrewrisse May 3, 2024
b63a934
feat: assistants management page and create assistant
andrewrisse May 3, 2024
241e907
Merge branch 'main' into 428-featui-assistants-management
andrewrisse May 3, 2024
d968ad8
fix: supabase secret naming
andrewrisse May 3, 2024
7a8e46c
fix: style when over 5 rows of card, causes slight page scroll
andrewrisse May 3, 2024
7fd0613
fix: footer styling
andrewrisse May 3, 2024
9acbfc1
fix: tooltip text
andrewrisse May 3, 2024
259e779
init
andrewrisse May 6, 2024
18e28ec
wip
andrewrisse May 6, 2024
f82cb8f
wip, use form action for avatar upload and assistant creation
andrewrisse May 7, 2024
34879ad
wip, pictograms
andrewrisse May 7, 2024
526e39b
pictograms working
andrewrisse May 8, 2024
31987aa
fix: mini avatar when pictogram
andrewrisse May 8, 2024
705bb53
lint
andrewrisse May 8, 2024
243c2ea
wip: design fixes
andrewrisse May 8, 2024
a578619
save validation
andrewrisse May 8, 2024
726e73c
fix: lots of ui style fixes and logic updates
andrewrisse May 8, 2024
49a000f
fix: validation
andrewrisse May 8, 2024
cd91ca6
chore: remove svelte forms lib, submit form normally
andrewrisse May 9, 2024
f544b62
fix: background color for avatar on assistant tile, add initial playw…
andrewrisse May 9, 2024
3565d29
e2es
andrewrisse May 9, 2024
1eef750
tests and formatting
andrewrisse May 10, 2024
9bf036e
fix: reduce number of icons for performance
andrewrisse May 10, 2024
25efa0a
fix: remove top dir node modules
andrewrisse May 10, 2024
2b8ec69
fix: add 'local-registry' target as dependency to 'build-ui'
YrrepNoj May 10, 2024
df3563a
chore: refactor package name from 'lfaiui' to 'leapfrogai-ui'
YrrepNoj May 10, 2024
de56fe1
chore: update default UI hostname from 'lfaiui' to 'ai'
YrrepNoj May 10, 2024
c2d7ba3
chore: update example keycloak_client_id
YrrepNoj May 10, 2024
a8fb7dc
fix: update default model for CPU bundles to not use a GPU model
YrrepNoj May 10, 2024
75b19ca
chore: merge main
andrewrisse May 10, 2024
40f486d
fix: add deleted supabase top level dir back in, minor code style upd…
andrewrisse May 10, 2024
0752c67
fix: lfaiui naming conventions
andrewrisse May 10, 2024
2d0cde2
fix: lfaiui naming conventions 2
andrewrisse May 10, 2024
c2eb836
fix: lfaiui naming conventions 3
andrewrisse May 10, 2024
613348e
fix: chat input box
andrewrisse May 10, 2024
d6529fc
fix: upload bug
andrewrisse May 10, 2024
362a314
fix: update subdomain and domain settings for UI deployment
YrrepNoj May 10, 2024
02933f5
Merge branch 'misc-ui-package-configuration-updates' into 434-edit-as…
andrewrisse May 10, 2024
8f6682d
fix: merge changes missed
andrewrisse May 10, 2024
43736fc
fix: remove comment
andrewrisse May 10, 2024
b64d7d5
chore: update keycloak client name
andrewrisse May 10, 2024
337087b
chore: merge main
andrewrisse May 10, 2024
e234333
fix: remove unused api route
andrewrisse May 10, 2024
d2204d8
chore: block save button during submit
andrewrisse May 10, 2024
383f7aa
Merge branch 'main' into 434-edit-assistant
andrewrisse May 10, 2024
6c9f669
chore: update ui migrations
andrewrisse May 10, 2024
bd6ab8f
fix: migrations in one file, lowercase assistants
andrewrisse May 13, 2024
254c344
fix: migrations in one file, lowercase assistants 2
andrewrisse May 13, 2024
9ec2b14
chore: remove rls rule for avatar storage
andrewrisse May 13, 2024
487562f
fix: Formatting for migrations file
andrewrisse May 13, 2024
fbf2ac8
fix: copy migrations to parent dir
andrewrisse May 13, 2024
2fd5841
init
andrewrisse May 13, 2024
b3adf86
chore: use sveltekit superforms and add form action tests
andrewrisse May 13, 2024
b181fd2
wip: update asssitants, remove assistants store
andrewrisse May 14, 2024
4c0c389
wip: remove debugger
andrewrisse May 14, 2024
d823175
wip: add overflow menu buttons and delete capability
andrewrisse May 14, 2024
218c3e7
feat: add cancel modal only when changes and navigating away)
andrewrisse May 14, 2024
a2a90af
chore: throw error if assistant not found
andrewrisse May 14, 2024
2d3006c
chore: merge main
andrewrisse May 14, 2024
b51af03
tests wip
andrewrisse May 14, 2024
1581a53
finish tests, fix chat input styling
andrewrisse May 14, 2024
b90dba6
feat: edit and delete assistants
andrewrisse May 14, 2024
574b1b1
fix: cancel modal
andrewrisse May 14, 2024
175cbc2
fix: cache control for image update
andrewrisse May 14, 2024
164f8d0
fix: typo in package.json script
andrewrisse May 15, 2024
94bf8fd
fix: card width override, prod bug only
andrewrisse May 15, 2024
5740024
fix: card width override, prod bug only 2
andrewrisse May 15, 2024
a37a976
fix: card width override, prod bug only 3
andrewrisse May 15, 2024
1ca3822
Fix assistant tile text cutoff
andrewrisse May 15, 2024
3640e45
fix: assistant tile text sizing bug
andrewrisse May 15, 2024
9186119
fix: remove avatar bug, schema alias, turn off autocomplete
andrewrisse May 15, 2024
c7bdd6f
fix: lint
andrewrisse May 15, 2024
87e8436
fix: id type for editassistantinput
andrewrisse May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
483 changes: 415 additions & 68 deletions src/leapfrogai_ui/package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/leapfrogai_ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"supabase:start": "supabase start && docker exec -u 0 supabase_auth_supabase /bin/sh -c \"echo '100.115.154.78 keycloak.admin.uds.dev' >> /etc/hosts\"",
"supabase:stop": "supabase stop",
"supabase:reset": "supabase db reset",
"supbase:migrate": "supbase migration up"
"supbase:migrate": "supabase migration up"
},
"devDependencies": {
"@commitlint/cli": "^19.1.0",
Expand Down Expand Up @@ -78,6 +78,7 @@
"openai": "^4.41.1",
"playwright": "^1.42.1",
"svelte-forms-lib": "^2.0.1",
"sveltekit-superforms": "^2.13.1",
"uuid": "^9.0.1",
"yup": "^1.4.0"
}
Expand Down
1 change: 1 addition & 0 deletions src/leapfrogai_ui/src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare global {
// profile?: any;
conversations?: Conversation[];
assistants?: Assistant[];
assistant?: Assistant;
}
// interface PageState {}
// interface Platform {}
Expand Down
11 changes: 8 additions & 3 deletions src/leapfrogai_ui/src/lib/components/AssistantAvatar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import { AVATAR_FILE_SIZE_ERROR_TEXT, MAX_AVATAR_SIZE, NO_FILE_ERROR_TEXT } from '$lib/constants';

export let files: File[];
export let avatarUrl = '';
export let selectedPictogramName: string;

let tempAvatarUrl = avatarUrl;
let tempFiles: File[] = [];
let tempPictogram = '';
let tempPictogram = selectedPictogramName || 'default';
let modalOpen = false;
let selectedRadioButton: 'upload' | 'pictogram' = 'pictogram';
let shouldValidate = false;
Expand All @@ -24,10 +26,11 @@

$: fileNotUploaded = !tempFiles[0]; // if on upload tab, you must upload a file to enable save
$: fileTooBig = tempFiles[0]?.size > MAX_AVATAR_SIZE;
$: hideUploader = tempFiles.length > 0;
$: hideUploader = tempAvatarUrl ? true : tempFiles.length > 0;

const handleRemove = () => {
tempFiles = [];
tempAvatarUrl = '';
tempPictogram = 'default';
shouldValidate = false;
};
Expand Down Expand Up @@ -67,13 +70,15 @@
// pictogram tab
selectedPictogramName = tempPictogram;
files = []; // remove saved avatar
tempFiles = [];
modalOpen = false;
shouldValidate = false;
}
};

$: tempImagePreviewUrl = tempFiles?.length > 0 ? URL.createObjectURL(tempFiles[0]) : '';
$: savedImagePreviewUrl = files?.length > 0 ? URL.createObjectURL(files[0]) : '';
$: savedImagePreviewUrl =
files?.length > 0 ? URL.createObjectURL(files[0]) : tempAvatarUrl ? tempAvatarUrl : '';
</script>

<div class="container">
Expand Down
235 changes: 235 additions & 0 deletions src/leapfrogai_ui/src/lib/components/AssistantForm.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
<script lang="ts">
import {
ASSISTANTS_DESCRIPTION_MAX_LENGTH,
ASSISTANTS_INSTRUCTIONS_MAX_LENGTH,
ASSISTANTS_NAME_MAX_LENGTH
} from '$lib/constants';
import { superForm } from 'sveltekit-superforms';
import { Add } from 'carbon-icons-svelte';
import { page } from '$app/stores';
import { beforeNavigate, goto } from '$app/navigation';
import { Button, Modal, Slider, TextArea, TextInput } from 'carbon-components-svelte';
import AssistantAvatar from '$components/AssistantAvatar.svelte';
import { yup } from 'sveltekit-superforms/adapters';

import { toastStore } from '$stores';
import InputTooltip from '$components/InputTooltip.svelte';
import { env } from '$env/dynamic/public';
import { editAssistantInputSchema, supabaseAssistantInputSchema } from '$lib/schemas/assistants';
import type { NavigationTarget } from '@sveltejs/kit';

export let data;

let isEditMode = $page.url.pathname.includes('edit');
let bypassCancelWarning = false;

const { form, errors, enhance, submitting, isTainted } = superForm(data.form, {
validators: yup(isEditMode ? editAssistantInputSchema : supabaseAssistantInputSchema),
onResult({ result }) {
if (result.type === 'redirect') {
toastStore.addToast({
kind: 'success',
title: `Assistant ${isEditMode ? 'Updated' : 'Created'}.`,
subtitle: ''
});
bypassCancelWarning = true;
goto(result.location);
} else if (result.type === 'failure') {
// 400 errors will show errors for the respective fields, do not show toast
if (result.status !== 400) {
toastStore.addToast({
kind: 'error',
title: `Error ${isEditMode ? 'Editing' : 'Creating'} Assistant`,
subtitle: result.data?.message || 'An unknown error occurred.'
});
}
} else if (result.type === 'error') {
toastStore.addToast({
kind: 'error',
title: `Error ${isEditMode ? 'Editing' : 'Creating'} Assistant`,
subtitle: result.error?.message || 'An unknown error occurred.'
});
}
}
});

let cancelModalOpen = false;
let files: File[] = [];
let selectedPictogramName = isEditMode ? data.assistant.metadata.pictogram : 'default';
let avatarPath = isEditMode ? data.assistant.metadata.avatar : '';

let navigateTo: NavigationTarget;
let leavePageConfirmed = false;

// Get image url for Avatar if the assistant has an avatar
$: avatarUrl = avatarPath
? `${env.PUBLIC_SUPABASE_URL}/storage/v1/object/public/assistant_avatars/${avatarPath}`
: '';

// Show cancel modal if form is tainted and user attempts to navigate away
beforeNavigate(({ cancel, to, type }) => {
if (to) {
navigateTo = to;
}
if (!leavePageConfirmed && isTainted() && !bypassCancelWarning) {
cancel();
leavePageConfirmed = false; // reset
if (type !== 'leave') {
// if leaving app, don't show cancel modal (ex. refresh page), triggers the native browser unload confirmation dialog.
cancelModalOpen = true;
}
}
});
</script>

<form method="POST" enctype="multipart/form-data" use:enhance class="assistant-form">
<div class="container">
<div class="inner-container">
<div class="top-row">
<div class="title">{`${isEditMode ? 'Edit' : 'New'} Assistant`}</div>
<AssistantAvatar bind:files bind:selectedPictogramName {avatarUrl} />
</div>
<input type="hidden" name="id" value={$form.id} />
<TextInput
name="name"
autocomplete="off"
labelText="Name"
placeholder="Assistant name"
bind:value={$form.name}
maxlength={ASSISTANTS_NAME_MAX_LENGTH}
invalid={!!$errors.name}
invalidText={$errors.name?.toString()}
/>

<InputTooltip
name="description"
labelText="Tagline"
tooltipText="Taglines display on assistant tiles"
/>

<TextInput
name="description"
autocomplete="off"
placeholder="Here to help..."
labelText="Description"
hideLabel
bind:value={$form.description}
maxlength={ASSISTANTS_DESCRIPTION_MAX_LENGTH}
invalid={!!$errors.description}
invalidText={$errors.description?.toString()}
/>

<InputTooltip
name="instructions"
labelText="Instructions"
tooltipText="Detailed instructions to guide your assistant's responses and behavior"
/>

<TextArea
name="instructions"
autocomplete="off"
labelText="Instructions"
bind:value={$form.instructions}
rows={6}
placeholder="You'll act as..."
hideLabel
invalid={!!$errors.instructions}
invalidText={$errors.instructions?.toString()}
maxlength={ASSISTANTS_INSTRUCTIONS_MAX_LENGTH}
/>

<InputTooltip
name="temperature"
labelText="Temperature"
tooltipText="Adjust the slider to set the creativity level of your assistant's responses"
/>
<Slider
name="temperature"
bind:value={$form.temperature}
hideLabel
hideTextInput
fullWidth
min={0}
max={1}
step={0.1}
minLabel="Min"
maxLabel="Max"
invalid={!!$errors.temperature}
/>

<!--Note - Data Sources is a placeholder and will be completed in a future story-->
<InputTooltip
name="data_sources"
labelText="Data Sources"
tooltipText="Specific files your assistant can search and reference"
/>
<div>
<Button icon={Add} kind="secondary" size="small"
>Add <input name="data_sources" type="hidden" /></Button
>
</div>

<div>
<Button
kind="secondary"
size="small"
on:click={() => {
bypassCancelWarning = true;
goto('/chat/assistants-management');
}}>Cancel</Button
>
<Button kind="primary" size="small" type="submit" disabled={$submitting}>Save</Button>
</div>
</div>
</div>
</form>

<div class="cancel-modal">
<Modal
bind:open={cancelModalOpen}
modalHeading="Unsaved Changes"
primaryButtonText="Leave this page"
secondaryButtonText="Stay on page"
on:click:button--secondary={() => (cancelModalOpen = false)}
andrewrisse marked this conversation as resolved.
Show resolved Hide resolved
on:submit={() => {
leavePageConfirmed = true;
if (navigateTo) goto(navigateTo.url.href);
}}
><p>
You have unsaved changes. Do you want to leave this page? Unsaved changes will be deleted.
</p></Modal
>
</div>

<style lang="scss">
.assistant-form {
.container {
display: flex;
justify-content: center;
}
.inner-container {
display: flex;
flex-direction: column;
gap: 1.5rem;
width: 50%;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.top-row {
display: flex;
justify-content: space-between;
align-items: center;
}

.title {
@include type.type-style('heading-05');
}

.cancel-modal {
:global(.bx--modal-container) {
position: absolute;
top: 25%;
}
}
}
</style>
Loading