gurtejx / LegallyWiseAI

COMP 2800 group project created by Team BBY-31.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

2800-202310-BBY31

LegallyWise created by ...

Team BBY-31

  • Abhishek (Ash) Chouhan
  • Gurtej Malik
  • Amrit Jhatu
  • Armaan Pruthi

Project Description

"Our team is developing an AI-powered online law app to help individuals, small businesses, and students navigate legal issues quickly and easily with personalized results and an ever-improving database of laws and policies."

Technologies

Frontend: HTML CSS Bootstrap v5.3.x/ v 5.1.3

Backend: JavaScript Node v19.3.0 Python llama_index v0.6.8 langchain v0.0.172

Database: Mongodb v6.0.5

Files

.
├── node_modules
│   ├── @hapi
│   │   ├── hoek
│   │   │   └── lib
│   │   └── topo
│   │       └── lib
│   ├── @mapbox
│   │   └── node-pre-gyp
│   │       ├── bin
│   │       ├── lib
│   │       │   └── util
│   │       │       └── nw-pre-gyp
│   │       └── node_modules
│   │           ├── node-fetch
│   │           │   └── lib
│   │           ├── tr46
│   │           │   └── lib
│   │           ├── webidl-conversions
│   │           │   └── lib
│   │           └── whatwg-url
│   │               └── lib
│   ├── @sideway
│   │   ├── address
│   │   │   └── lib
│   │   ├── formula
│   │   │   └── lib
│   │   └── pinpoint
│   │       └── lib
│   ├── @types
│   │   ├── node
│   │   │   ├── assert
│   │   │   ├── dns
│   │   │   ├── fs
│   │   │   ├── readline
│   │   │   ├── stream
│   │   │   ├── timers
│   │   │   └── ts4.8
│   │   │       ├── assert
│   │   │       ├── dns
│   │   │       ├── fs
│   │   │       ├── readline
│   │   │       ├── stream
│   │   │       └── timers
│   │   ├── webidl-conversions
│   │   └── whatwg-url
│   │       └── dist
│   ├── abbrev
│   ├── accepts
│   ├── agent-base
│   │   ├── dist
│   │   │   └── src
│   │   └── src
│   ├── ansi-colors
│   │   └── types
│   ├── ansi-regex
│   ├── ansi-styles
│   ├── anymatch
│   ├── aproba
│   ├── are-we-there-yet
│   │   └── lib
│   ├── array-flatten
│   ├── asn1.js
│   │   └── lib
│   │       └── asn1
│   │           ├── base
│   │           ├── constants
│   │           ├── decoders
│   │           └── encoders
│   ├── async
│   │   ├── dist
│   │   └── internal
│   ├── asynckit
│   │   └── lib
│   ├── axios
│   │   ├── dist
│   │   └── lib
│   │       ├── adapters
│   │       ├── cancel
│   │       ├── core
│   │       ├── defaults
│   │       ├── env
│   │       └── helpers
│   ├── balanced-match
│   ├── bcrypt
│   │   ├── examples
│   │   ├── lib
│   │   │   └── binding
│   │   │       └── napi-v3
│   │   ├── src
│   │   └── test
│   ├── binary-extensions
│   ├── biskviit
│   │   ├── lib
│   │   └── test
│   ├── bn.js
│   │   └── lib
│   ├── body-parser
│   │   ├── lib
│   │   │   └── types
│   │   └── node_modules
│   │       ├── debug
│   │       │   └── src
│   │       └── ms
│   ├── boolbase
│   ├── brace-expansion
│   ├── braces
│   │   └── lib
│   ├── bson
│   │   ├── etc
│   │   ├── lib
│   │   └── src
│   │       ├── parser
│   │       └── utils
│   ├── buffer-equal-constant-time
│   ├── bytes
│   ├── call-bind
│   │   └── test
│   ├── chalk
│   │   └── source
│   ├── cheerio
│   │   └── lib
│   │       ├── api
│   │       └── parsers
│   ├── cheerio-select
│   │   └── lib
│   ├── chokidar
│   │   ├── lib
│   │   └── types
│   ├── chownr
│   ├── color-convert
│   ├── color-name
│   ├── color-support
│   ├── combined-stream
│   │   └── lib
│   ├── commander
│   │   └── typings
│   ├── concat-map
│   │   ├── example
│   │   └── test
│   ├── connect-mongo
│   │   └── build
│   │       └── main
│   │           └── lib
│   ├── console-control-strings
│   ├── content-disposition
│   ├── content-type
│   ├── cookie
│   ├── cookie-signature
│   ├── css-select
│   │   └── lib
│   │       └── pseudo-selectors
│   ├── css-what
│   │   └── lib
│   │       ├── commonjs
│   │       └── es
│   ├── data-uri-to-buffer
│   │   ├── dist
│   │   └── src
│   ├── date-format
│   │   └── lib
│   ├── debug
│   │   └── src
│   ├── delayed-stream
│   │   └── lib
│   ├── delegates
│   │   └── test
│   ├── depd
│   │   └── lib
│   │       └── browser
│   ├── destroy
│   ├── detect-libc
│   │   └── lib
│   ├── dom-serializer
│   │   └── lib
│   │       └── esm
│   ├── domelementtype
│   │   └── lib
│   │       └── esm
│   ├── domhandler
│   │   └── lib
│   ├── domutils
│   │   └── lib
│   ├── dotenv
│   │   └── lib
│   ├── ecdsa-sig-formatter
│   │   └── src
│   ├── ee-first
│   ├── ejs
│   │   ├── bin
│   │   └── lib
│   ├── emoji-regex
│   │   └── es2015
│   ├── encodeurl
│   ├── encoding
│   │   ├── lib
│   │   └── test
│   ├── entities
│   │   └── lib
│   │       └── maps
│   ├── escape-goat
│   ├── escape-html
│   ├── etag
│   ├── express
│   │   ├── lib
│   │   │   ├── middleware
│   │   │   └── router
│   │   └── node_modules
│   │       ├── debug
│   │       │   └── src
│   │       └── ms
│   ├── express-session
│   │   ├── node_modules
│   │   │   ├── cookie
│   │   │   ├── debug
│   │   │   │   └── src
│   │   │   └── ms
│   │   └── session
│   ├── fetch
│   │   ├── example
│   │   ├── lib
│   │   └── test
│   ├── fetch-blob
│   ├── filelist
│   │   └── node_modules
│   │       ├── brace-expansion
│   │       └── minimatch
│   │           └── lib
│   ├── fill-range
│   ├── finalhandler
│   │   └── node_modules
│   │       ├── debug
│   │       │   └── src
│   │       └── ms
│   ├── flatted
│   │   ├── cjs
│   │   ├── esm
│   │   └── php
│   ├── follow-redirects
│   ├── form-data
│   │   └── lib
│   ├── formdata-polyfill
│   ├── forwarded
│   ├── fresh
│   ├── fs
│   ├── fs-extra
│   │   └── lib
│   │       ├── copy
│   │       ├── copy-sync
│   │       ├── empty
│   │       ├── ensure
│   │       ├── fs
│   │       ├── json
│   │       ├── mkdirs
│   │       ├── move
│   │       ├── move-sync
│   │       ├── output
│   │       ├── path-exists
│   │       ├── remove
│   │       └── util
│   ├── fs-minipass
│   │   └── node_modules
│   │       └── minipass
│   ├── fs.realpath
│   ├── fsevents
│   ├── function-bind
│   │   └── test
│   ├── gauge
│   ├── generic-pool
│   │   └── lib
│   ├── get-intrinsic
│   │   └── test
│   ├── glob
│   ├── glob-parent
│   ├── graceful-fs
│   ├── growly
│   │   ├── example
│   │   └── lib
│   ├── has
│   │   ├── src
│   │   └── test
│   ├── has-flag
│   ├── has-symbols
│   │   └── test
│   │       └── shams
│   ├── has-unicode
│   ├── he
│   │   ├── bin
│   │   └── man
│   ├── htmlparser2
│   │   └── lib
│   ├── http-errors
│   ├── https-proxy-agent
│   │   └── dist
│   ├── iconv-lite
│   │   ├── encodings
│   │   │   └── tables
│   │   └── lib
│   ├── ignore-by-default
│   ├── inflight
│   ├── inherits
│   ├── ip
│   │   └── lib
│   ├── ipaddr.js
│   │   └── lib
│   ├── is-binary-path
│   ├── is-docker
│   ├── is-extglob
│   ├── is-fullwidth-code-point
│   ├── is-glob
│   ├── is-number
│   ├── is-wsl
│   ├── isexe
│   │   └── test
│   ├── jake
│   │   ├── bin
│   │   ├── lib
│   │   │   ├── task
│   │   │   └── utils
│   │   └── test
│   │       ├── integration
│   │       │   └── jakelib
│   │       └── unit
│   ├── joi
│   │   ├── dist
│   │   └── lib
│   │       └── types
│   ├── jsonfile
│   ├── jsonwebtoken
│   │   └── lib
│   ├── juice
│   │   ├── bin
│   │   └── lib
│   ├── jwa
│   ├── jws
│   │   └── lib
│   ├── kruptein
│   │   └── lib
│   ├── lodash
│   │   └── fp
│   ├── log4js
│   │   ├── lib
│   │   │   └── appenders
│   │   └── types
│   ├── lru-cache
│   ├── mailgen
│   │   ├── examples
│   │   ├── screenshots
│   │   │   ├── cerberus
│   │   │   ├── default
│   │   │   ├── neopolitan
│   │   │   └── salted
│   │   └── themes
│   │       ├── cerberus
│   │       ├── default
│   │       ├── neopolitan
│   │       └── salted
│   ├── make-dir
│   │   └── node_modules
│   │       └── semver
│   │           └── bin
│   ├── media-typer
│   ├── memory-pager
│   ├── mensch
│   │   └── lib
│   ├── merge-descriptors
│   ├── methods
│   ├── mime
│   │   └── src
│   ├── mime-db
│   ├── mime-types
│   ├── minimalistic-assert
│   ├── minimatch
│   ├── minipass
│   ├── minizlib
│   │   └── node_modules
│   │       └── minipass
│   ├── mkdirp
│   │   ├── bin
│   │   └── lib
│   ├── mongo-connect
│   │   ├── lib
│   │   └── test
│   ├── mongodb
│   │   ├── etc
│   │   ├── lib
│   │   │   ├── bulk
│   │   │   ├── cmap
│   │   │   │   ├── auth
│   │   │   │   │   └── mongodb_oidc
│   │   │   │   ├── handshake
│   │   │   │   └── wire_protocol
│   │   │   ├── cursor
│   │   │   ├── gridfs
│   │   │   ├── operations
│   │   │   └── sdam
│   │   └── src
│   │       ├── bulk
│   │       ├── cmap
│   │       │   ├── auth
│   │       │   │   └── mongodb_oidc
│   │       │   ├── handshake
│   │       │   └── wire_protocol
│   │       ├── cursor
│   │       ├── gridfs
│   │       ├── operations
│   │       └── sdam
│   ├── mongodb-connection-string-url
│   │   └── lib
│   ├── ms
│   ├── negotiator
│   │   └── lib
│   ├── node-addon-api
│   │   └── tools
│   ├── node-domexception
│   ├── node-fetch
│   │   ├── @types
│   │   └── src
│   │       ├── errors
│   │       └── utils
│   ├── node-notifier
│   │   ├── lib
│   │   ├── notifiers
│   │   └── vendor
│   │       ├── mac.noindex
│   │       │   └── terminal-notifier.app
│   │       │       └── Contents
│   │       │           ├── MacOS
│   │       │           └── Resources
│   │       │               └── en.lproj
│   │       ├── notifu
│   │       └── snoreToast
│   ├── nodemailer
│   │   └── lib
│   │       ├── addressparser
│   │       ├── base64
│   │       ├── dkim
│   │       ├── fetch
│   │       ├── json-transport
│   │       ├── mail-composer
│   │       ├── mailer
│   │       ├── mime-funcs
│   │       ├── mime-node
│   │       ├── qp
│   │       ├── sendmail-transport
│   │       ├── ses-transport
│   │       ├── shared
│   │       ├── smtp-connection
│   │       ├── smtp-pool
│   │       ├── smtp-transport
│   │       ├── stream-transport
│   │       ├── well-known
│   │       └── xoauth2
│   ├── nodemon
│   │   ├── bin
│   │   ├── doc
│   │   │   └── cli
│   │   ├── lib
│   │   │   ├── cli
│   │   │   ├── config
│   │   │   ├── help
│   │   │   ├── monitor
│   │   │   ├── rules
│   │   │   └── utils
│   │   └── node_modules
│   │       ├── debug
│   │       │   └── src
│   │       ├── has-flag
│   │       ├── semver
│   │       │   └── bin
│   │       └── supports-color
│   ├── nopt
│   │   ├── bin
│   │   └── lib
│   ├── normalize-path
│   ├── npmlog
│   ├── nth-check
│   │   └── lib
│   │       └── esm
│   ├── object-assign
│   ├── object-inspect
│   │   ├── example
│   │   └── test
│   │       └── browser
│   ├── on-finished
│   ├── on-headers
│   ├── once
│   ├── openai
│   │   └── dist
│   ├── parse5
│   │   └── lib
│   │       ├── common
│   │       ├── extensions
│   │       │   ├── error-reporting
│   │       │   ├── location-info
│   │       │   └── position-tracking
│   │       ├── parser
│   │       ├── serializer
│   │       ├── tokenizer
│   │       ├── tree-adapters
│   │       └── utils
│   ├── parse5-htmlparser2-tree-adapter
│   │   └── lib
│   ├── parseurl
│   ├── path-is-absolute
│   ├── path-to-regexp
│   ├── picomatch
│   │   └── lib
│   ├── proxy-addr
│   ├── psl
│   │   ├── data
│   │   └── dist
│   ├── pstree.remy
│   │   ├── lib
│   │   └── tests
│   │       └── fixtures
│   ├── punycode
│   ├── qs
│   │   ├── dist
│   │   ├── lib
│   │   └── test
│   ├── random-bytes
│   ├── range-parser
│   ├── raw-body
│   ├── readable-stream
│   │   └── lib
│   │       └── internal
│   │           └── streams
│   ├── readdirp
│   ├── rfdc
│   │   └── test
│   ├── rimraf
│   ├── safe-buffer
│   ├── safer-buffer
│   ├── saslprep
│   │   ├── lib
│   │   └── test
│   ├── semver
│   │   ├── bin
│   │   ├── classes
│   │   ├── functions
│   │   ├── internal
│   │   └── ranges
│   ├── send
│   │   └── node_modules
│   │       ├── debug
│   │       │   ├── node_modules
│   │       │   │   └── ms
│   │       │   └── src
│   │       └── ms
│   ├── serve-static
│   ├── set-blocking
│   ├── setprototypeof
│   │   └── test
│   ├── shellwords
│   │   └── lib
│   ├── side-channel
│   │   └── test
│   ├── signal-exit
│   ├── simple-update-notifier
│   │   ├── build
│   │   ├── node_modules
│   │   │   └── semver
│   │   │       ├── bin
│   │   │       ├── classes
│   │   │       ├── functions
│   │   │       ├── internal
│   │   │       └── ranges
│   │   └── src
│   ├── slick
│   ├── smart-buffer
│   │   ├── build
│   │   ├── docs
│   │   └── typings
│   ├── socks
│   │   ├── build
│   │   │   ├── client
│   │   │   └── common
│   │   ├── docs
│   │   │   └── examples
│   │   │       ├── javascript
│   │   │       └── typescript
│   │   └── typings
│   │       ├── client
│   │       └── common
│   ├── sparse-bitfield
│   ├── statuses
│   ├── streamroller
│   │   └── lib
│   ├── string-width
│   ├── string_decoder
│   │   └── lib
│   ├── strip-ansi
│   ├── supports-color
│   ├── tar
│   │   └── lib
│   ├── to-regex-range
│   ├── toidentifier
│   ├── touch
│   │   ├── bin
│   │   └── node_modules
│   │       └── nopt
│   │           ├── bin
│   │           ├── examples
│   │           └── lib
│   ├── tr46
│   │   └── lib
│   ├── tslib
│   │   └── modules
│   ├── type-is
│   ├── uid-safe
│   ├── undefsafe
│   │   └── lib
│   ├── universalify
│   ├── unpipe
│   ├── util-deprecate
│   ├── utils-merge
│   ├── uuid
│   │   └── dist
│   │       ├── bin
│   │       ├── esm-browser
│   │       ├── esm-node
│   │       └── umd
│   ├── valid-data-url
│   ├── vary
│   ├── web-resource-inliner
│   │   ├── node_modules
│   │   │   ├── domhandler
│   │   │   │   └── lib
│   │   │   ├── htmlparser2
│   │   │   │   └── lib
│   │   │   ├── mime
│   │   │   │   └── types
│   │   │   ├── node-fetch
│   │   │   │   └── lib
│   │   │   ├── tr46
│   │   │   │   └── lib
│   │   │   ├── webidl-conversions
│   │   │   │   └── lib
│   │   │   └── whatwg-url
│   │   │       └── lib
│   │   └── src
│   ├── web-streams-polyfill
│   │   ├── dist
│   │   │   └── types
│   │   │       └── ts3.6
│   │   ├── es2018
│   │   ├── es6
│   │   └── ponyfill
│   │       ├── es2018
│   │       └── es6
│   ├── webidl-conversions
│   │   └── lib
│   ├── whatwg-url
│   │   └── lib
│   ├── which
│   │   └── bin
│   ├── wide-align
│   ├── wrappy
│   └── yallist
├── public
│   ├── css
│   └── img
└── views
    └── templates

Installation

Prerequisites Before you start, ensure you have these prerequisites installed:

Node.js & npm: You need Node.js installed to run this app. Check if you have it installed by running node -v. If not, you can download Node.js from their site.

MongoDB: This app uses MongoDB as a database. MongoDB can be found on their site.

IDE: Any text editor or IDE that supports JavaScript, HTML, and CSS will work, but we recommend Visual Studio Code. We will show instructions for VSCode now.

Install and run

Create a fork of our repo

Launch VS Code and navigate to pop it open in the project directory is located.

Install Project Dependencys: Pop open the terminal in VSCode and since it is already there it should be no issue on typing out the following command to get the dependencies implemented.

npm install

Prepare environment variables: Create an .env file in the project's root directory. Add any required variables to the .env file and keep it updated with the correct keys.

Set up MongoDB and use the values in our .env file to have everything configured.

Pop open the terminal and post the following before entering to run our project.

 node index.js

This will allow you to access our localhost link on any browser you have: http://localhost:3020.

Features

Consult LegallyWise AI: Click the Consult LegallyWise AI button at the homepage or the logo located on the navbar. This will take you to a room where you can ask a question and get a response that has come from the data the AI has been trained on. You may also choose a language before you click submit to get a response in a language you feel more comfortable in or have a better understanding.

Explain your Document: This feature can be accessed on the homepage by selecting the 'Explain your Document' button. It will take you to a page that will ask you to upload a pdf file, and you can ask questions specifically after you submit the file. This will also simplify and summarize the document if a user asks it to so they can demistify the legal jargon and know what the uploaded document is about before heading into their meeting with a lawyer.

Profile: This can be accessed by clicking 'Profile' on the navbar and will take a user to a profile page where they can see the fields they had registered with.

Contact: This can be accessed by clicking 'Contact' on the navbar and will take the user to a contact page that lists some important contacts they can either send an email to or call to get more legal information.

About: This can be accessed by clicking 'About' on the navbar and will take the user to a page where the app is explained a little and some information about the team that worked on the project.

Easter Egg: When the user clicks on the 'Ask a question' button 5 or more times continuously, a GIF appears that asks user not to spam. It's a cool feature that you should try.

Password reset: In case the user forgets their password, they can click on the 'Forgot username/password' link in the login form on login page, enter their username, then answer the security question they set at the time of signing up and they will be able to set a new password. In case the user forgets their username as well, they can click on the 'Forgot username' link on the forgot password page form. Then, a custom one-time usable password reset email is sent to the user. This email contains the user's username and a link to set the new password.

Credits

OpenAI. (n.d.). OpenAI. https://openai.com/

Welcome to PyPDF2 — PyPDF2 documentation. (n.d.). Welcome to PyPDF2 &Mdash; PyPDF2 Documentation. https://pypdf2.readthedocs.io/en/3.0.0/

C. (n.d.). API_documentation/EN.md at master · canlii/API_documentation. GitHub. https://github.com/canlii/API_documentation

Welcome to LangChain — 🦜🔗 LangChain 0.0.181. (2023, May 26). Welcome to LangChain — 🦜🔗 LangChain 0.0.181. https://python.langchain.com/en/latest/index.html

Licenses: OpenAI Key

AI

AI is increasingly becoming a sensation in the tech world, and more so are Natural language processing models like chatGPT by OpenAI. We realized the importance of staying up to date with the industry and decided to use a NLM model in our app. This project provided us with a deep understanding of AI technology, from staying updated with the latest models to integrating them into our application through API usage. Additionally, we explored the possibilities of training custom models to suit our specific requirements, further enhancing the capabilities of our application.

  1. Utilizing API Integration: We discovered how to integrate AI models into our application using APIs. Specifically, we learned how to incorporate OpenAI's GPT model by utilizing their API. This enabled us to access the model's capabilities and generate responses based on user input, enhancing the interactive experience within our application.

  2. Custom Model Training: One fascinating discovery was the ability to train our own custom model using our pre-processed dataset. We delved into the process of training the model on our specific data, which allowed us to create a model that was knowledgeable and tailored to our application's needs. By leveraging OpenAI's embedding feature, we could query the model effectively and retrieve relevant information from our dataset.

  3. Data Interaction Between Servers: During the development of our application and the creation of our custom language model, we encountered a significant challenge. Our application was built in a Node.js environment, but we faced the hurdle that Python was the only supported language by OpenAI to interact with their models. Unfortunately, there was no equivalent solution available for Node.js at that time. Although we explored workarounds to run Python scripts within a Node.js environment, we encountered issues with importing modules, limiting our options to simple script imports.

To overcome this obstacle, we conducted thorough research and adopted an innovative approach. We modified the Python code to function as a standalone server, capable of responding to incoming POST requests containing questions or prompts. The Python server then returned the response text encapsulated within a JSON object. By hosting the Python and Node.js servers separately and establishing communication between them, we resolved the compatibility issue and ensured each server operated within its own environment.

This clever solution enabled us to maintain the functionality of our application while effectively utilizing the components we had developed earlier.

  1. Utilizing Documentation: A significant portion of our app's features were the result of extensive research and leveraging information from various sources, including the internet and the respective companies involved. We dedicated considerable time to reading documentation, conducting tests, and troubleshooting to ensure that our efforts yielded positive results. There were moments when we felt overwhelmed and unsure if we could make progress, but it's important to acknowledge that such feelings are normal. Taking breaks and returning to the task with a fresh mindset proved to be highly beneficial.

It's essential to understand that processing a vast amount of information requires time and patience before effectively applying it. It's crucial not to lose hope when initially attempting to implement new ideas or features that don't work as expected. It's a common occurrence in the development process. Most of the time, you're only a step or two away from resolving the issue. It's important not to give up and persevere through the challenges encountered.

Contact Information

Gurtej Malik: gurtejmalik@gmail.com

Amrit Jhatu: ajhatu@my.bcit.ca

Abhishek Chouhan: achouhan4@my.bcit.ca

Armaan Pruthi: apruthi1@my.bcit.ca

About

COMP 2800 group project created by Team BBY-31.


Languages

Language:EJS 60.1%Language:JavaScript 31.0%Language:Python 6.8%Language:HTML 1.3%Language:CSS 0.7%Language:Procfile 0.1%