The purpose of this repository is to demonstrates how to quickly get up and running with machine learning in an Express application.
This application is a simple note taking application. It analyzes all the notes taken in a day and performs summarization and sentiment analysis on them.
All our ML occurs in the database where the notes are stored. This means just by connecting to the database we are able to train and deploy ML/AI models and have a production ready pipeline.
This example application requires a PostgreSQL database with the pgml and pgvector extension installed. The easiest way to do this is with a free database at postgresml.org.
Clone this repository. Once you have your PostgresML database, or local PostgreSQL with the extensions installed, create a .env file and add DATABASE_URL=<your_db_url>
replacing your_db_url.
Next install all required node packages with node install
.
Start the express server by running the following
npm run devStart
This will launch the application at localhost:3000
In a browser, navigate to localhost:3000. Recored a note in the text area on the left and click submit. Do this a couple times. On the right click Analyze Day, this will produce a sentiment analysis score and a summarization of your day.
![Screenshot 2024-03-18 at 3 20 33 PM](https://private-user-images.githubusercontent.com/39170265/313839428-8599e052-63b7-41f0-82de-7e743b48fa7c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUwNDI2MDQsIm5iZiI6MTcyNTA0MjMwNCwicGF0aCI6Ii8zOTE3MDI2NS8zMTM4Mzk0MjgtODU5OWUwNTItNjNiNy00MWYwLTgyZGUtN2U3NDNiNDhmYTdjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMwVDE4MjUwNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJkOWIwOWZhMTUwZDRiNTMzOTk1Mjc4M2ZhZmIzNzBjYzJlNjhlMmVkZTdjZTljMDhhZjNkMjZhMGVjYzZjOGMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.BYBcrjOhHrTExz3fLEoD-rXW73PMaMPOczc1VZ8BK0k)
We can augment this code to perform all types of ML. Checkout the postgresML docs for a full list.
If you are unhappy with the quality of the results, rest assured, higher quality models are available.
In this example we directly interacted with the extension using PostgreSQL. If you would prefer JS, see our JS SDK