This project implements a simple text annotation application using FastHTML, showcasing dynamic updates, database integration, and a user-friendly interface for annotating text data.
Contributed by: @altryne
- View and navigate through text samples
- Annotate texts as correct or incorrect
- Add notes to each text sample
- Real-time updates without page reloads
- SQLite database integration
- Automatic loading of dummy data
- FastHTML: A Python framework for building dynamic web applications
- HTMX: For seamless client-side updates without full page reloads
- SQLite: For persistent data storage
- DaisyUI and Tailwind CSS: For styling and UI components
The app is set up using FastHTML's fast_app function, which creates the application, routing, database connection, and data model in a single line:
app, rt, texts_db, Item = fast_app('texts.db', hdrs=(tlink, dlink, picolink, MarkdownJS(), HighlightJS()), live=True, id=int, messages=list, feedback=bool, notes=str, pk='id', render=render)The app comes with a dummy data file dummy_data.jsonl containing sample text data. This file is loaded automatically when the app starts. If you want to load your own data, you'll need to replace this file with a new one in the same format.
The dummy data file contains JSON lines (JSONL) with the following structure on each line:
[{"role":"user","content":"User's message"},{"role":"assistant","content":"Assistant's response"}]To run the app, execute the following command:
python main.py
Open your web browser and navigate to http://localhost:5001 to access the app.
To use your own data instead of the dummy data:
- Create a JSONL file with your data, following the structure described above
- Replace the
dummy_data.jsonlfile in thedatadirectory with your file - Ensure your file is named
dummy_data.jsonlor update the file path inmain.py