abhilash-aot / forms-gpt-bcgov

Creates and edits form templates with the help of AI tools. Provide a text prompt and it creates a form template that can be imported into FormIO compatible services such as CHEFS or FormFlow.AI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FormsGPT (Conversational Form Design) Proof of Concept

This project was created in order to streamline the creation and editing of forms by new CHEFS users. Allowing the user to type, in natural language, a request for generating or altering an existing form. Features included in this proof of concept include:

  • Context: Adding documentation or source material for the forms product, in this case custom form components, and passing this information as reference to the Large Language Model. The large language model then can utilize this specialised information which may not have been in its training data.
  • Form Compression: This was implemented to reduce the number of tokens used in the LLM requests. A token is the name for the base unit of data for LLM processing. In a text context a token could be a word, a section of a word, or a single character. In sending an edit request the entire existing form which may consist of thousands of tokens is sent to the LLM. Shrinking these forms allows for a more efficient use of the LLM's processing.
  • Output Sanitizing: Reducing the response space into a form JSON aids in preventing unintended usage of the LLM.

Running the Project

Environment Variables

To run this project, you will need to alter the following environment variables in the sample.env file and rename to .env

Backend

backend/sample.env :

OPENAI_API_KEY=YOUR_OPENAI_API_KEY : See instructions below for generating an API Key

Frontend

For frontend/sample.env :

REACT_APP_BACKEND=http://{Your IP Address}:3081

Generating an OpenAI API Key

  1. Sign Up or Log In: Visit OpenAI Platform and sign in to your OpenAI account. If you don’t have an account, you’ll need to sign up first.

  2. Access the API Section: Once logged in, navigate to the API keys section. This is usually accessible through the main navigation menu as shown below.

How to navigate to API section

  1. Generate New API Key: Using the + Create new Secret key button we can create a new Token. This token can be shared across the team. Also we can create an organisation and invite members to the team so can create secret keys for users as well. You can control the Organisation and Team from the Settings menu.

Create an Organization

  1. Add credit card to Billing Section: Within the OpenAI account page, find and navigate to the Settings section. You can add the payment method in here.

Add billing information

  1. Model Selection and Pricing: You can find OpenAI API pricing here at Pricing. We have defaulted to the GPT 3.5 Turbo Model. Below you can see the pricing and rate limits for the selected model.

Pricing for GPT 3.5 Turbo Limits for GPT 3.5 Turbo

  1. Reviewing Usage: To review the usage on your OpenAI account, you can click here Platform Account Usage

Usage on your account

Building and Running

Running with Docker

Ensure you have the latest version of Docker Desktop installed with the command line interface.

Navigate to /docker/

Update the /docker/sample.env file and rename it to .env

Run docker-compose up --build -d

To test if the backend is up and running, you can navigate to http://localhost:3001/health.

To validate it running correctly, you can navigate to http://localhost to use your dockerized instance of the frontend.

Running from command line

Next, in a terminal, navigate to /backend/.

run npm install

and node server.js to run the backend.'

To test if the backend is up and running, you can navigate to http://localhost:3001/health.

in a new terminal window, navigate to /frontend/

run npm install

and npm start to run the frontend.

You can then navigate to http://localhost:3000 to use your local instance.

About

Creates and edits form templates with the help of AI tools. Provide a text prompt and it creates a form template that can be imported into FormIO compatible services such as CHEFS or FormFlow.AI

License:Apache License 2.0


Languages

Language:JavaScript 75.8%Language:CSS 15.5%Language:Dockerfile 5.3%Language:HTML 3.4%