website/README.md
<a href="https://github-com.translate.goog/LAION-AI/Open-Assistant/blob/main/website/README.md?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp"></a>
This provides a comprehensive webapp interface for LAION's Open Assistant project. Initially it will support:
This interface compliments the Discord bot and will give access to the same underlying tasks.
This website is built using:
To contribute to the website, make sure you have the following setup and installed:
nvm use 16)If you're doing active development we suggest the following workflow:
docker compose --profile frontend-dev up --build --attach-dependencies. You can optionally include -d to
detach and later track the logs if desired.
docker compose --profile frontend-dev --profile inference up --build --attach-dependencies${OPEN_ASSISTANT_ROOT/website.npm cinpx prisma db push (This is also needed when you restart the docker stack from scratch).npm run dev. Now the website is up and running locally at http://localhost:3000.http://localhost:1080. Check
the email listed and click the log in link. You're now logged in and authenticated.
Note: when running on MacOS with an M1 chip you have to use:
DB_PLATFORM=linux/x86_64 docker compose ...
You can use the debug credentials provider to log in without fancy emails or OAuth.
npm run dev. In case you want to do the
same with a production build (for example, the docker image), then run the website with environment variable
DEBUG_LOGIN=true.Login button in the top right to go to the login page.Create a docker-compose.override.yml in the root of the repo, and add the following to it
services:
inference-server:
environment:
# fill out these variables, you would need to create an app from the corresponding provider(s)
# you can fill only one of them if you want to
AUTH_DISCORD_CLIENT_ID:
AUTH_DISCORD_CLIENT_SECRET:
AUTH_GITHUB_CLIENT_ID:
AUTH_GITHUB_CLIENT_SECRET:
And now when you start all containers, the possibility to login to inference through these providers will be available.
To develop components using Storybook run npm run storybook. Then navigate to in your
browser to http://localhost:6006.
To create a new story create a file named [componentName].stories.tsx. An example how such a story could look like,
see Header.stories.tsx.
All react code is under src/ with a few sub directories:
pages/: All pages a user could navigate too and API URLs which are under pages/api/.components/: All re-usable React components. If something gets used twice we should create a component and put it
here.lib/: A generic place to store library files that are used anywhere. This doesn't have much structure yet.NOTE: styles/ can be ignored for now.
All database configurations are stored in prisma/schema.prisma.
All static images, fonts, svgs, etc are stored in public/.
We're not really using CSS styles. styles/ can be ignored.
Cypress is used for end-to-end (e2e) and component testing and is configured in ./cypress.config.ts. The ./cypress
folder is used for supporting configuration files etc.
./cypress/e2e folder../src/components/Layout.tsx then store the test file at ./src/components/Layout.cy.tsx.A few npm scripts are available for convenience:
npm run cypress: Useful for development, it opens Cypress and allows you to explore, run and debug tests. It assumes
you have the NextJS site running at localhost:3000.npm run cypress:run: Runs all tests. Useful for a quick sanity check before sending a PR or to run in CI pipelines.npm run cypress:image-baseline: If you have tests failing because of visual changes that was expected, this command
will update the baseline images stored in ./cypress-visual-screenshots/baseline with those from the adjacent
comparison folder. More can be found in the
docs of uktrade/cypress-image-diff.Read more in the ./cypress README.
Jest and React Testing Library are used for unit testing JS/TS/TSX code.
.test.ts for non-React code
or .test.tsx for React code.npm run jest: automatically runs tests and watches for any relevant changes to rerun tests.Read more in the ./src/README.md.
When writing code for the website, we have a few best practices:
When working on new features or making significant changes that can't be done within a single Pull Request, we ask that you make use of Feature Flags.
We've set up react-feature-flags to make this easier. To get
started:
website/src/flags.ts. We have an example flag you can copy as an example. Be sure to
isActive to true when testing your features but false when submitting your PR.import { Flags } from "react-feature-flags";
...
<Flags authorizedFlags={["yourFlagName"]}>
<YourNewComponent />
</Flags>
You can see an example of how this works by checking `website/src/components/Header/Headers.tsx` where we use `flagTest`.
Flag
wrappers around your component and the entry in flags.ts.To use stable and consistent URL paths, we recommend the following strategy for new tasks:
website/src/pages/create with a page
name matching the task type, such as initial_prompt.tsx.website/src/pages/evaluate with a page
name matching the task type such as rank_initial_prompts.tsx.With this we'll be able to ensure these contribution pages are hidden from logged out users but accessible to logged in users.
To learn more about Next.js, take a look at the following resources: