liveBook · Manning

ChatGPT

As explained in Build Financial Software with Generative AI (From Scratch)

A conversational generative-AI system that responds to natural-language prompts and can generate text or code.

ChatGPT is a generative-AI assistant used through natural-language prompts for coding help and exploratory questions. It can help turn an unclear task into a starting point: summarize a regulation for a bank customer, produce a small Python program, explain a failure, or reshape generated code. Its output is an aid to development work rather than an automatically correct solution. section 1.4.1 section 1.5.2

Prompt refinement controls the level and purpose of a response. A request to summarize Check 21 can be narrowed from regulatory detail to customer benefits, a few sentences, or even one word. The same approach applies to code: ask for a balance-printing statement, then request input handling, a function, type hints, or a returned formatted string. Responses can vary even for the same prompt because ChatGPT is nondeterministic. section 1.5.2

Use ChatGPT as part of a deliberate development workflow:

  • Request a small implementation or a focused revision instead of assuming a first response is production-ready. section 1.5.2 section 2.3.1
  • Give faulty code and tests when debugging; inspect whether the explanation identifies the actual logic problem. section 1.5.3
  • Check generated code against domain requirements, such as required ACH record types and correct record labels. section 2.3.1
  • Verify library versions, security implications, and current guidance when a response may rely on outdated model knowledge. section 1.5.7

From a balance formatter to testable payment parsing

A prompt can first generate Python that formats a user-entered current balance. Asking for a function, annotations, and a returned string makes the result easier to reuse. For a larger task, an ACH parser generated from the same broad request may omit record types or mislabel them. A useful follow-up asks for separate parser functions per record type, allowing valid and invalid records to be tested independently. section 1.5.2 section 2.3.1

Listing 2.3 Parsing with separate functions
def parse_ach(filename):
    records = []

    parser_functions = {          #1
        '1': parse_file_header,    #1
        '5': parse_batch_header,   #1
        '6': parse_entry_detail,   #1
        '7': parse_addenda,        #1
        '8': parse_batch_control,  #1
        '9': parse_file_control    #1
    }                              #1
 #1
    with open(filename, 'r') as file: #1
        lines = file.readlines()

        for line in lines:
            record_type = line[0]
            parser = parser_functions.get(record_type) #2

            if parser:                       #3
                records.append(parser(line)) 
            else:                            
                print(f"Unknown record type: 
   ➥{record_type} in line: {line}") #4
                continue

    return records
…                               #5
def parse_file_control(line):    #5
    return {                     #5
        'record_type': 'File Control',  #5
        # ... additional fields    #5
    }  #5
…                                #5

Inspect a generated ACH parser structure that dispatches each record type to a dedicated parsing function, including handling for unknown records. section 2.3.1

Treat answers as a starting point to review, run, and improve. ChatGPT may identify a transaction-list bug, such as removing an item too early because of an incorrect comparison, but tests establish the expected behavior. It may also give a plausible PostgreSQL example using psycopg2 while failing to recognize psycopg3; a revised prompt can adapt the example, but cannot replace validation against the intended version and environment. section 1.5.3 section 1.5.7

How Build Financial Software with Generative AI (From Scratch) covers it

How deep it goes
Demonstrates iterative prompting, generated-code inspection, debugging, and version verification without comprehensively teaching generative AI.
Examples
Uses Check 21 summaries, a current-balance formatter, a transaction-list defect, and ACH parser outputs from ChatGPT 3.5 and 4.
What it assumes
Assumes general software-development familiarity while using simple Python requests to help newcomers get started.
What you can do after
Evaluate/understand generated responses by refining prompts, testing code, checking domain rules, and validating version-sensitive advice.
How it connects
Connects generative AI with prompt engineering, Python, unit testing, ACH parsing, PostgreSQL, and psycopg.

Also explained in

Compare how 20 books explain ChatGPT →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Financial Software with Generative AI (From Scratch). The section links point to the parts of the book it draws on.