GPTBundle, a React application toolkit, harnesses AI to convert textual content into structured forms and delivers advanced autofill suggestions.
Leveraging GPT-4 from OpenAI's API simplifies form development, accelerating the process and enhancing intuitiveness.
Main Features
GPTBundle facilitates adding AI capabilities to forms in React applications. Some of the main GPTBundle features include:
You can find a list of all examples here. Feel free to explore all the features and download the source code to examine how it functions deeply.
AI Form Creators - From existing content: checklists, surveys, exams, data collection, you name it!
AI Form Assistant - Your product forms with AI-powered autofill capabilities.
UI Libraries Integration - Effortlessly integrate with MUI, Ant.Design, and more through react-jsonschema-form, ensuring smooth, and consistent UI across your projects.
Community
Contributing - GPTBundle is open source because we believe that streamlining AI is based on transparency. If you are interested contributing to GPTBundle, check out our GitHub page.
Support - This project is primarily maintained by Vinta Software. If you require assistance, our team is ready and willing to help. Please feel free to reach out to us via email at gptbundle@vintasoftware.com.
Getting Started
Installation
Configuration
Set your OPENAI_API_KEY in the environment variables (.env.localfor Next.js).
If you don't have a key, get one from your OpenAI account:
Use the GptBundleConfig to provide the action functions from server package to the client-side.
In Next.js, do that in your root layout:
It can generate forms from any kind of text content: an article, a task description, a legal contract, a list of topics, etc.
Even if the text is code, like Mermaid diagrams.
As long as it's text, and the AI can understand it, GPTBundle can generate a form for it.
Generating a form
The best way to understand the form generation is to see it in action, the code and the generated forms:
The code above renders an input form that looks like this:
After the user clicks the the Generate Form button, the AI generates this form based on the input form:
The AI generated form is built by react-jsonschema-form library
from the schemas below. In other words, the AI generated the following schemas to build the form above based on user's input:
{
"title": "Personal Information Form",
"description": "Form to collect name and age",
"type": "object",
"required": [
"name",
"age"
],
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"age": {
"type": "integer",
"title": "Age"
}
}
}
Note the AI produces a schema for the form logic, and another schema for the form UI, compatible with each other.
Usage
GPTBundle provides a React hook, useGeneratedFormSchema, which takes no arguments.
The hook returns a function generateFormSchema and references to the formSchema and uiSchema:
formSchema and uiSchema are generated when the generateFormSchema is called.
Those schemas must passed to a Form from react-jsonschema-form for the form generation:
You must call generateFormSchema with the text content and prompt you want to generate the form from.
In our example, we use the content and prompt from the user input:
Ai Form Assistant
GPTBundle has tools to enhance your application's forms with an AI assistant that autofills form fields.
Autofill a single field
Suppose you have a form like this:
You can create a button to autofill the recipe field with the useFormAssistant hook:
Note the current value of the field is passed to the AI assistant, so it can enhance it.
After autofilling, the form will look like this:
Fill multiple fields
You can also fill multiple fields based on the field names and values,
and context about the form like page title and form title.
By default, the AI will fill the form's empty fields when the fillFields function is called:
After autofilling, the form will look like this:
Force filling non-empty fields
In the example above, the AI didn't autofill the recipe field because it already had a value,
despite the fact it was a "template" for humans to write the recipe. To force the AI to enhance
fields that have any value in them, use the fieldsToFill option:
fieldsToFill == null, the default, means only fill empty fields.
fieldsToFill === '__all__' means fill all fields, even if they have a value.
fieldsToFill === ['duration', 'cost'] means fill only those specified fields.
Pass field labels to the AI assistant
The more context about the form the AI can get, the better the autofilling will be.
You can pass the field labels to the AI assistant with the fieldLabels option: