Issue with Generating Contracts from User Input

When a user inputs data into the app, I want to generate a contract with placeholders replaced by the user’s input.

I am attaching all the screenshots of my workflow,Data type, Api Call, Contract template(Generated from Chatgpt).

I’m currently working on resume generation using GPT-4 for a client which involves using structured data and outputs to fill resume templates. I’m using the JSON Resume structure https://jsonresume.org/ and instructing GPT to output the revised resume as JSON which I then parse and save to Bubble. I’d recommend going down this route as it seems to give the best response.

I can’t really see the specifics of your use case but you might include in the prompt:

'Format your response as a series of JSON objects with ‘heading’ and ‘content’ keys.

This will then return:

[
    {
        "heading": "Clause 1",
        "content": "Clause 1 is about"
    },
    {
        "heading": "Clause 2",
        "content": "Clause 2 is about..."
    },
    {
        "heading": "Clause 3",
        "content": "Clause 3 is about..."
    },
    {
        "heading": "Clause 4",
        "content": "Clause 4 is about..."
    }
]

This will allow you to save individual clauses (as presumably each Contact contains a series of Clauses / Sections). That means instead of saving the entire contract as one block of text, your contract is a list of sections and other data types which you can then edit more dynamically.

EDIT: As an aside, I’m not convinced you need to be creating dozens of assistant messages… You should probably be creating one System message with all of the relevant user inputs.

{
“model”: “gpt-3.5-turbo”,
“messages”: [
{
“role”: “system”,
“content”: “You are a paralegal associate in a legal company. Draft a legal contract with minimum 15 clauses.”
},
{
“role”: “user”,
“content”: “Please draft a legal contract between <party_a> and <party_b>. The contract should include terms related to [<agreement_type>].”
},
{
“role”: “assistant”,
“content”: “Party A: <party_a>”
},
{
“role”: “assistant”,
“content”: “Party B: <party_b>”
},
{
“role”: “assistant”,
“content”: “Company Address: <company_address>”
},
{
“role”: “assistant”,
“content”: “Individual Address: <individual_address>”
},
{
“role”: “assistant”,
“content”: "CIN: "
},
{
“role”: “assistant”,
“content”: “Company Name: <company_name>”
},
{
“role”: “assistant”,
“content”: “First Name (Parent): <parent_first_name>”
},
{
“role”: “assistant”,
“content”: “First Name (User Name): <user_first_name>”
},
{
“role”: “assistant”,
“content”: "GSTIN: "
},
{
“role”: “assistant”,
“content”: “Contract Terms: <contract_terms>”
},
{
“role”: “assistant”,
“content”: “Last Name (User): <user_last_name>”
},
{
“role”: “assistant”,
“content”: “Last Name (Parent): <parent_last_name>”
},
{
“role”: “assistant”,
“content”: “Pincode (Company): <company_pincode>”
},
{
“role”: “assistant”,
“content”: “Pincode (Individual): <individual_pincode>”
},
{
“role”: “assistant”,
“content”: “Type of Agreement: <agreement_type>”
},
{
“role”: “assistant”,
“content”: “Type of Party: <party_type>”
},
{
“role”: “assistant”,
“content”: “Now, please draft the contract text.”
}
]
}
is this fine, please check. also i am a non tech person, taking help of gpt for codes.
Gpt is creating a necessary clauses require, but not taking a user input from database. Also how system message can have all relevent input