advanced software engineering course project - FA2023
We aim to build a ChatGPT based content recommendation API service to suggest interesting, educational, and curated contents to clients. Our service would intake textual requests (e.g. I want to learn more about long COVID symptoms ) given by clients (e.g. content seeking APPs or services) and output recommended contents in a summarized fashion back to the clients. We envision five key functionalities and logistics inside our API service:
This module interacts with clients and databases to manage client’s content preferences. It receives initial preferences given by the client and stores it in the database with the client ID. It also retrieves client preferences from the database upon request by other APIs. It also updates client preferences based on the prompts the client provided overtime. Overall, it serves as the core management system of preferences for each client.
This module mainly integrates different source content APIs, such as OpenAI API, WikiMedia API, and PubMed API, etc. to retrieve a plethora of contents based on information about the client, such as the keywords extracted from client’s prompt. Overall this API serves as an integrated platform to retrieve raw contents from different sources.
This module converts the raw contents into semi-bespoke and summarized contents based on user preferences. Different raw contents retrieved from source content directly can have vastly different characteristics to work with. Therefore, this module makes sure that these contents are sanitized and prepared so that they can be compared during the ranking process. Overall, it serves as an intermediate API between Content Integration and Content Ranking that summarizes, standarizes, and optimizes the content before they are to be ranked.
This module intakes different contents and client information to rank the contents and return the most tailored content to the client/API.
- Ensure you have Node.js installed on your machine (https://nodejs.org/en/download). This project uses v18.18.2.
- Navigate to the project directory and install the required dependencies for this project by using
npm install
orsudo npm install
with root privileges
Jest is a popular JavaScript testing framework developed by Facebook. It is widely used and we use Jest for testing in this project
We usesqlite3 for non-vector storage, like user ID, preference and prompt.
OpenAI API is a powerful artificial intelligence service provided by OpenAI that allows developers to integrate natural language processing capabilities into their applications. We use OpenAI API for various kinds of sub-tasks in this project.
LangChain is a framework designed to simplify the creation of applications using large language models. We use Langchain for text generation in this project.
- type
npm test
in the project root directory to run test code.
- Github action is used to to implement continuous integration tests for the project. Each time there is a push or merge to the main, CI tests are run.
- The workflow files are located at:
https://github.com/Martin-lc/2023_COMS4156/tree/main/.github/workflows
- The workflow files are located at:
- CI tests include a test for unit tests and integration tests as well as tests for
style checking
andstatic analysis
usingESLint
- We will jest for code coverage analysis -- simply type
npx jest --coverage
to check for branch coverage for the repository
to run the demo, simply type npm run demo
in the project root directory. To make it work properly:
- change the
user_path
to your pwd at project root directory - demo.js take 3 parameters:
query
,userPreference
(user preference), andrecord_num
(record number)query
: the query you want to inputuserPreference
:u se comma to separate different input strings with no space in betweenrecord_num
: limit to 2 or 3 for best demonstration effect and wait time
- example run:
npm run demo -- --userPreference wellness,elder,covid,nutrition --record_num 2
, enter query when prompted:what should I do if I have covid?
- Set your OpenAI API key:
export OPENAI_API_KEY=your_openai_api_key
- Start the server with:
node server.js
- Open Postman and create a new POST request to
http://localhost:3000/demo
- Set the body to
raw
andJSON (application/json)
, and input:{ "query": "I want to learn about long COVID symptoms", "userPreference": "wellness,elder,covid,nutrition", "record_num": 2 }
- Hit Send. Make sure your server is running when testing with Postman.
- Set your OpenAI API key:
export OPENAI_API_KEY=your_openai_api_key
- Start the server with:
node server.js
- To start the application, navigate to the directory containing your client files and run
npm run server
- This will start a local web server on port 8080. You can access the application by going to http://localhost:8080 in your web browser.
The application includes end-to-end tests written with Puppeteer and Jest. These tests simulate user interactions with the web application in a headless Chrome browser. To run only the end-to-end tests, use the following Jest command:
npx jest --testRegex '.e2e.test.js$'
This command will execute tests in files that match the .e2e.test.js pattern. Make sure the application is running via http-server before executing the tests.