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

feat(ui): Assistant Avatars #494

Merged
merged 86 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 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
553502a
fix: add allow all policy for assistant avatars
andrewrisse May 13, 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
2 changes: 1 addition & 1 deletion packages/supabase/chart/templates/uds-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ .Values.leapfrogai.package.name }}
spec:
sso:
- name: Supabase
- name: Leapfrog AI
description: Client for logging into Supabase
clientId: {{ .Values.leapfrogai.sso.clientId }}
redirectUris:
Expand Down
196 changes: 66 additions & 130 deletions packages/supabase/migrations/20240322174521_ui_sql_schema.sql
Original file line number Diff line number Diff line change
@@ -1,188 +1,124 @@
-- Create tables
create table conversations (
id uuid primary key DEFAULT uuid_generate_v4(),
user_id uuid references auth.users not null,
label text,
inserted_at timestamp with time zone default timezone('utc'::text, now()) not null
id uuid primary key DEFAULT uuid_generate_v4(),
user_id uuid references auth.users not null,
label text,
inserted_at timestamp with time zone default timezone('utc'::text, now()) not null
);


create table messages (
id uuid primary key DEFAULT uuid_generate_v4(),
user_id uuid references auth.users not null,
conversation_id uuid references conversations on delete cascade not null,
role text check (role in ('system', 'user', 'assistant', 'function', 'data', 'tool')),
content text,
inserted_at timestamp with time zone default timezone('utc'::text, now()) not null
id uuid primary key DEFAULT uuid_generate_v4(),
user_id uuid references auth.users not null,
conversation_id uuid references conversations on delete cascade not null,
role text check (role in ('system', 'user', 'assistant', 'function', 'data', 'tool')),
content text,
inserted_at timestamp with time zone default timezone('utc'::text, now()) not null
);

-- Create a table for public profiles

create table profiles (
id uuid references auth.users not null primary key,
updated_at timestamp with time zone,
username text unique,
full_name text,
avatar_url text,
website text,

constraint username_length check (char_length(username) >= 3)
id uuid references auth.users not null primary key,
updated_at timestamp with time zone,
username text unique,
full_name text,
avatar_url text,
website text,
constraint username_length check (char_length(username) >= 3)
);

alter table conversations enable row level security;

alter table messages enable row level security;

alter table profiles enable row level security;

-- Policies for conversations
create policy "Individuals can create conversations." on conversations for
insert with check (auth.uid() = user_id);
create policy "Individuals can view their own conversations. " on conversations for
select using (auth.uid() = user_id);
create policy "Individuals can update their own conversations." on conversations for
update using (auth.uid() = user_id);
create policy "Individuals can delete their own conversations." on conversations for
delete using (auth.uid() = user_id);

-- Policies for messages
create policy "Individuals can view their own messages." on messages for
select using (auth.uid() = user_id);
create policy "Individuals can create messages." on messages for
insert with check (auth.uid() = user_id);
create policy "Individuals can update their own messages." on messages for
update using (auth.uid() = user_id);
create policy "Individuals can delete their own messages." on messages for
delete using (auth.uid() = user_id);

-- Policies for profiles
create policy "Public profiles are viewable by everyone." on profiles
for select using (true);

create policy "Users can insert their own profile." on profiles
for insert with check (auth.uid() = id);

create policy "Users can update own profile." on profiles
for update using (auth.uid() = id);

-- Set up access controls for storage.
-- See https://supabase.com/docs/guides/storage/security/access-control#policy-examples for more details.
create policy "Avatar images are publicly accessible." on storage.objects
for select using (bucket_id = 'avatars');

create policy "Anyone can upload an avatar." on storage.objects
for insert with check (bucket_id = 'avatars');

create policy "Anyone can update their own avatar." on storage.objects
for update using (auth.uid() = owner) with check (bucket_id = 'avatars');


-- This trigger automatically creates a profile entry when a new user signs up via Supabase Auth.
-- See https://supabase.com/docs/guides/auth/managing-user-data#using-triggers for more details.
create function public.handle_new_user()
returns trigger as $$
begin
insert into public.profiles (id, full_name, avatar_url)
values (new.id, new.raw_user_meta_data->>'full_name', new.raw_user_meta_data->>'avatar_url');
return new;
end;
$$ language plpgsql security definer;
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();
create table assistants (
id uuid primary key DEFAULT uuid_generate_v4(),
object text check (object in ('assistant')),
name varchar(255),
description varchar(512),
model varchar(255) not null,
instructions TEXT,
tools jsonb,
tool_resources jsonb,
metadata jsonb,
temperature float,
top_p float,
response_format jsonb,
created_at timestamp with time zone default timezone('utc'::text, now()) not null
);

-- Set up Storage!
insert into storage.buckets
(id, name, public)
values
('assistant_avatars', 'assistant_avatars', true);

-- These are user profiles avatars, currently not used by app and will be removed soon
insert into storage.buckets (id, name)
values ('avatars', 'avatars');
values ('avatars', 'avatars');

-- RLS policies
alter table conversations enable row level security;

alter table messages enable row level security;

alter table profiles enable row level security;
alter table assistants enable row level security;

-- Policies for conversations
create policy "Individuals can create conversations." on conversations for
insert with check (auth.uid() = user_id);
create policy "Individuals can view their own conversations. " on conversations for
select using (auth.uid() = user_id);
select using (auth.uid() = user_id);
create policy "Individuals can update their own conversations." on conversations for
update using (auth.uid() = user_id);
update using (auth.uid() = user_id);
create policy "Individuals can delete their own conversations." on conversations for
delete using (auth.uid() = user_id);

-- Policies for messages
create policy "Individuals can view their own messages." on messages for
select using (auth.uid() = user_id);
select using (auth.uid() = user_id);
create policy "Individuals can create messages." on messages for
insert with check (auth.uid() = user_id);
create policy "Individuals can update their own messages." on messages for
update using (auth.uid() = user_id);
update using (auth.uid() = user_id);
create policy "Individuals can delete their own messages." on messages for
delete using (auth.uid() = user_id);

-- Policies for profiles
create policy "Public profiles are viewable by everyone." on profiles
for select using (true);

create policy "Users can insert their own profile." on profiles
for insert with check (auth.uid() = id);

create policy "Users can update own profile." on profiles
for update using (auth.uid() = id);

-- Set up access controls for storage.
-- See https://supabase.com/docs/guides/storage/security/access-control#policy-examples for more details.
create policy "Avatar images are publicly accessible." on storage.objects
for select using (bucket_id = 'avatars');

create policy "Anyone can upload an avatar." on storage.objects
for insert with check (bucket_id = 'avatars');

create policy "Anyone can update their own avatar." on storage.objects
for update using (auth.uid() = owner) with check (bucket_id = 'avatars');


-- Policies for assistants
CREATE POLICY "Individuals can view their own assistants." ON assistants
FOR SELECT USING ((metadata ->> 'created_by') = auth.uid()::text);
create policy "Individuals can view their own assistants." ON assistants
for select using ((metadata ->> 'created_by') = auth.uid()::text);
create policy "Individuals can create assistants." on assistants for
insert with check ((metadata ->> 'created_by') = auth.uid()::text);
create policy "Individuals can update their own assistants." on assistants for
update using ((metadata ->> 'created_by') = auth.uid()::text);
create policy "Individuals can delete their own assistants." on assistants for
delete using ((metadata ->> 'created_by') = auth.uid()::text);

-- Policies for storage.
create policy "Avatar images are publicly accessible." on storage.objects
for select using (bucket_id = 'avatars');
create policy "Anyone can upload an avatar." on storage.objects
for insert with check (bucket_id = 'avatars');
create policy "Anyone can update their own avatar." on storage.objects
for update using (auth.uid() = owner) with check (bucket_id = 'avatars');

create policy "Anyone can upload an assistant avatar." on storage.objects
for insert with check (bucket_id = 'assistant_avatars');

-- This trigger automatically creates a profile entry when a new user signs up via Supabase Auth.
-- See https://supabase.com/docs/guides/auth/managing-user-data#using-triggers for more details.
create function public.handle_new_user()
returns trigger as $$
returns trigger as $$
begin
insert into public.profiles (id, full_name, avatar_url)
values (new.id, new.raw_user_meta_data->>'full_name', new.raw_user_meta_data->>'avatar_url');
return new;
insert into public.profiles (id, full_name, avatar_url)
values (new.id, new.raw_user_meta_data->>'full_name', new.raw_user_meta_data->>'avatar_url');
return new;
end;
$$ language plpgsql security definer;
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();
after insert on auth.users
for each row execute procedure public.handle_new_user();


-- Set up Storage!
insert into storage.buckets (id, name)
values ('avatars', 'avatars');


CREATE TABLE Assistants (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
object text CHECK (object in ('assistant')),
name VARCHAR(255),
description VARCHAR(512),
model VARCHAR(255) NOT NULL,
instructions TEXT,
tools jsonb,
tool_resources jsonb,
metadata jsonb,
temperature FLOAT,
top_p FLOAT,
response_format jsonb,
created_at timestamp with time zone default timezone('utc'::text, now()) not null
);
2 changes: 1 addition & 1 deletion src/leapfrogai_ui/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PUBLIC DYNAMIC
PUBLIC_SUPABASE_URL=http://localhost:54321
PUBLIC_SUPABASE_URL=http://127.0.0.1:54321
PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
PUBLIC_DISABLE_KEYCLOAK=false
PUBLIC_MESSAGE_LENGTH_LIMIT=10000
Expand Down
23 changes: 15 additions & 8 deletions src/leapfrogai_ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/leapfrogai_ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
},
"type": "module",
"dependencies": {
"@carbon/colors": "^11.21.0",
"@carbon/layout": "^11.20.0",
"@carbon/themes": "^11.32.0",
"@carbon/type": "^11.26.0",
Expand All @@ -70,6 +71,7 @@
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"@testing-library/user-event": "^14.5.2",
"ai": "^3.0.13",
"carbon-pictograms-svelte": "^12.10.0",
"concurrently": "^8.2.2",
"fuse.js": "^7.0.0",
"msw": "^2.2.14",
Expand Down
Loading