Skip to content

Commit

Permalink
Merge pull request #19 from elwood-software/feature/ai-assistant
Browse files Browse the repository at this point in the history
updates to AI
  • Loading branch information
traviskuhl authored Jun 6, 2024
2 parents 5ad4c15 + a487f4d commit e554d40
Show file tree
Hide file tree
Showing 45 changed files with 2,217 additions and 1,656 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm type-check --filter=./packages/*
TURBO_UI=0 pnpm type-check
8 changes: 4 additions & 4 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@
"@elwood/typescript-config": "workspace:*",
"@elwood/ui": "workspace:*",
"@tanstack/react-query": "^5.40.1",
"@types/node": "^20.14.1",
"@types/node": "^20.14.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.0",
"autoprefixer": "^10.4.19",
"electron": "^30.0.9",
"electron": "^30.1.0",
"electron-builder": "^24.13.3",
"electron-log": "^5.1.5",
"electron-vite": "^2.2.0",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.2",
"lowdb": "^7.0.1",
"postcss": "^8.4.38",
"prettier": "^3.3.0",
"prettier": "^3.3.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.23.1",
"react-use": "^17.5.0",
"tailwindcss": "^3.4.3",
"tailwindcss": "^3.4.4",
"typescript": "^5.4.5",
"vite": "^5.2.12",
"zod": "^3.23.8"
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@markdoc/next.js": "^0.3.7",
"@sindresorhus/slugify": "^2.2.1",
"@tailwindcss/typography": "^0.5.13",
"@types/node": "^20.14.1",
"@types/node": "^20.14.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-highlight-words": "^0.20.0",
Expand All @@ -37,7 +37,7 @@
"react-dom": "^18.3.1",
"react-highlight-words": "^0.20.0",
"simple-functional-loader": "^1.2.1",
"tailwindcss": "^3.4.3",
"tailwindcss": "^3.4.4",
"typescript": "^5.4.5"
},
"devDependencies": {
Expand All @@ -47,7 +47,7 @@
"eslint-config-next": "latest",
"eslint-plugin-next": "^0.0.0",
"postcss": "^8.4.38",
"prettier": "^3.3.0",
"prettier": "^3.3.1",
"sharp": "0.33.4"
}
}
4 changes: 2 additions & 2 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-use": "^17.5.0",
"tailwindcss": "^3.4.3",
"tailwindcss": "^3.4.4",
"zod": "^3.23.8"
},
"devDependencies": {
"@elwood/eslint-config": "workspace:*",
"@elwood/typescript-config": "workspace:*",
"@next/eslint-plugin-next": "^14.2.3",
"@types/node": "^20.14.1",
"@types/node": "^20.14.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 1 addition & 1 deletion apps/web/turbo.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": ["//"],
"globalEnv": [],
"pipeline": {
"tasks": {
"build": {
"outputs": [".next/**", "!.next/cache/**"]
}
Expand Down
4 changes: 2 additions & 2 deletions apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"react-router-dom": "^6.23.1",
"react-use": "^17.5.0",
"tailwind-merge": "^2.3.0",
"tailwindcss": "^3.4.3",
"tailwindcss": "^3.4.4",
"zod": "^3.23.8"
},
"devDependencies": {
"@elwood/eslint-config": "workspace:*",
"@elwood/typescript-config": "workspace:*",
"@next/eslint-plugin-next": "^14.2.3",
"@types/node": "^20.14.1",
"@types/node": "^20.14.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"typescript": "^5.4.5"
Expand Down
84 changes: 84 additions & 0 deletions apps/www/src/app/ai/demo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
'use client';

import {useEffect, useState} from 'react';
import {createMemoryRouter} from 'react-router-dom';
import {
Router,
ElwoodProvider,
useAssistant,
dashboardRoutes,
Assistant,
} from '@elwood/react';
import {Spinner} from '@elwood/ui';
import {type ElwoodClient, createClient, type User} from '@elwood/js';

export function Demo() {
const [router] = useState(createMemoryRouter(dashboardRoutes));
const [client, setClient] = useState<ElwoodClient | null>(null);
const [_user, setUser] = useState<User | null>(null);
const [loading, setLoading] = useState(true);

useEffect(() => {
if (client) {
return;
}

setLoading(true);
const localClient = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
);

localClient.auth.getSession().then(({data}) => {
if (data.session) {
setClient(localClient);
setLoading(false);
return;
}

return localClient.auth
.signInWithPassword({
email: process.env.NEXT_PUBLIC_DEMO_USER_EMAIL!,
password: process.env.NEXT_PUBLIC_DEMO_USER_PW!,
})
.then(response => {
setUser(response.data?.user ?? null);
})
.catch(error => {
console.log(error.message);
})
.finally(() => {
setClient(localClient);
setLoading(false);
});
});
}, []);

const workspaceName = 'Dunder Mifflin';

const loadingComponent = (
<Assistant messages={[]}>
<Spinner />
</Assistant>
);

if (!client || loading) {
return loadingComponent;
}

return (
<ElwoodProvider
loadingComponent={loadingComponent}
workspaceName={workspaceName}
client={client}
onLogout={() => {}}>
<AssistantDemo />
</ElwoodProvider>
);
}

function AssistantDemo() {
const assistant = useAssistant({});

return <>{assistant}</>;
}
47 changes: 47 additions & 0 deletions apps/www/src/app/ai/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type {PropsWithChildren} from 'react';

import Link from 'next/link';
import {Logo, Button, StarIcon, FileIcon, ExternalLinkIcon} from '@elwood/ui';
import {type Metadata} from 'next';
import {Demo} from './demo';

import Grid from '@/components/grid';

export const metadata: Metadata = {
title: 'Elwood AI',
};

export default async function Page() {
return (
<div className="w-full h-full flex flex-col">
<Grid className="z-0" />
<div className="container lg:max-w-[40vw] md:max-w-[60vw] size-full relative flex flex-col max-h-[80vh]">
<header className="w-full flex flex-col items-center pt-12 pb-3 text-center">
<div className="size-12 mb-6">
<Link href="/">
<Logo className="size-full fill-brand dark:fill-current" />
<span className="sr-only">Elwood</span>
</Link>
</div>
<h1 className="text-5xl md:text-7xl font-extrabold relative z-10 mb-1.5">
Elwood AI
</h1>
<h2 className="text-xl font-thin text-foreground/80">
<strong>Talk to your files.</strong> With Elwood AI, you can go
beyond simple search & filters. Your custom trained AI assistant can
help you find, organize, understand, and act on all of your team's
files.
</h2>
</header>
<main className="flex-grow flex flex-col items-center relative z-10">
<div className="shadow-splash border rounded-md bg-background mt-6 size-full">
<Demo />
</div>
</main>
</div>
<footer className="text-center text-muted-foreground/50 text-xs pb-2 pt-12">
&copy; The Elwood Technology Company
</footer>
</div>
);
}
36 changes: 20 additions & 16 deletions apps/www/src/app/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,29 @@ export function Demo() {
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
);

localClient.auth
.signInWithPassword({
email: process.env.NEXT_PUBLIC_DEMO_USER_EMAIL!,
password: process.env.NEXT_PUBLIC_DEMO_USER_PW!,
})
.then(response => {
setUser(response.data?.user ?? null);
})
.catch(error => {
console.log(error.message);
})
.finally(() => {
localClient.auth.getSession().then(({data}) => {
if (data.session) {
setClient(localClient);
setLoading(false);
});
return;
}

return function unload() {
localClient.auth.signOut();
};
return localClient.auth
.signInWithPassword({
email: process.env.NEXT_PUBLIC_DEMO_USER_EMAIL!,
password: process.env.NEXT_PUBLIC_DEMO_USER_PW!,
})
.then(response => {
setUser(response.data?.user ?? null);
})
.catch(error => {
console.log(error.message);
})
.finally(() => {
setClient(localClient);
setLoading(false);
});
});
}, []);

const workspaceName = 'Dunder Mifflin';
Expand Down
5 changes: 5 additions & 0 deletions apps/www/src/app/desktop/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {PropsWithChildren} from 'react';
import {type Metadata} from 'next';

import Link from 'next/link';
import {Logo, Button, StarIcon, FileIcon, ExternalLinkIcon} from '@elwood/ui';
Expand All @@ -9,6 +10,10 @@ import {Demo} from '../demo';
import Grid from '@/components/grid';
import {getReleases} from './get-releases';

export const metadata: Metadata = {
title: 'Elwood for Mac',
};

export default async function Layout(props: PropsWithChildren) {
const release = await getReleases(new URLSearchParams(''));

Expand Down
2 changes: 1 addition & 1 deletion apps/www/turbo.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": ["//"],
"globalEnv": [],
"pipeline": {
"tasks": {
"build": {
"outputs": [".next/**", "!.next/cache/**"]
}
Expand Down
2 changes: 1 addition & 1 deletion config/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"devDependencies": {
"@vercel/style-guide": "^6.0.0",
"eslint": "8.57.0",
"eslint-config-turbo": "^1.13.3",
"eslint-config-turbo": "^1.13.4",
"eslint-plugin-mdx": "^3.1.5",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-storybook": "^0.8.0"
Expand Down
2 changes: 1 addition & 1 deletion config/jest-presets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"ts-jest": "^29.1.4"
},
"devDependencies": {
"@types/node": "^20.14.1",
"@types/node": "^20.14.2",
"jest-environment-jsdom": "^29.7.0"
}
}
Loading

0 comments on commit e554d40

Please sign in to comment.