liveBook · Manning

Blackbox AI

As explained in Coding with AI

Blackbox AI is an AI-powered software development assistant that provides code generation, code assistance, and related programming support.

Blackbox AI is an AI-powered coding assistant for generating code, answering programming questions, and helping solve development tasks. It works in Visual Studio Code and Jupyter Notebook, with a web interface and IDE-based interaction; support spans more than 20 languages, including Python, JavaScript, TypeScript, Go, and Ruby. section 1.2.1

Use it as a fast drafting partner rather than an authority. It can produce scaffolding, boilerplate, database code, and tests, but the developer supplies requirements, reviews assumptions, refactors architecture, and rejects suggestions that do not fit the application. section 5.0 section 5.3.11

A practical Blackbox AI workflow is:

  • State the task precisely, including concrete constraints, file names, data shape, and expected behavior. section 5.3.2
  • Generate a small unit of code first, then inspect it against the surrounding application. section 5.3.6 section 8.4.5
  • Run the result, correct failures and assumptions, and refine the implementation instead of accepting it unchanged. section 5.1 section 8.4.5
  • Ask explicitly for edge cases, correct assertions, and reusable fixtures when generating tests. section 8.4.5

Turn a vague completion into a usable database draft

A comment such as “Connect to a database” gives too little direction and can yield an unhelpful suggestion. Specify the target instead: “connect to a SQLite database. The file name is data/questions.db.” That added context produces a more relevant connection attempt, which still needs review before it becomes application code. section 5.3.2

import unittest
import sqlite3
from questions import Questions  # Import the Questions class
class TestQuestions(unittest.TestCase):
    def setUp(self):
        # Create a test database
        self.conn = sqlite3.connect(':memory:')
        self.cursor = self.conn.cursor()
        # Create the necessary tables
        self.cursor.execute('''
            CREATE TABLE questions (
                id INTEGER PRIMARY KEY,
                correct INTEGER,
                question TEXT,
                a TEXT,
                b TEXT,
                c TEXT,
                d TEXT
            )
        ''')
        self.cursor.execute('''
            CREATE TABLE sessions (
                session_id INTEGER PRIMARY KEY,
                questions_correct INTEGER,
                questions_incorrect INTEGER
            )
        ''')
        self.cursor.execute('''
            CREATE TABLE question_sets (
                session_id INTEGER,
                question_id INTEGER
            )
        ''')
        # Insert some test data
        self.cursor.execute('''
            INSERT INTO questions (id, correct, question, a, b, c, d)
            VALUES (1, 1, 'What is the capital of France?', 
'Paris', 'London', 'Berlin', 'Rome')
        ''')
        self.cursor.execute('''
            INSERT INTO sessions (session_id, 
questions_correct, questions_incorrect)
            VALUES (1, 0, 0)
        ''')
        self.cursor.execute('''
            INSERT INTO question_sets (session_id, question_id)
            VALUES (1, 1)
        ''')
        self.conn.commit()
    def tearDown(self):
        # Close the database connection
        self.conn.close()
    def test_get_all_questions(self):
        questions = Questions(self.cursor)
        result = questions.get_all_questions()
        self.assertEqual(len(result), 1)
    def test_get_question(self):
        questions = Questions(self.cursor)
        result = questions.get_question(1)
        self.assertEqual(result['id'], 1)
        self.assertEqual(result['correct'], 1)
        self.assertEqual(result['question'], 
'What is the capital of France?')
        self.assertEqual(result['a'], 'Paris')
        self.assertEqual(result['b'], 'London')
        self.assertEqual(result['c'], 'Berlin')
        self.assertEqual(result['d'], 'Rome')
    def test_get_question_set(self):
        questions = Questions(self.cursor)
        result = questions.get_question_set(1)
        self.assertEqual(len(result), 1)
    def test_get_answered_questions(self):
        questions = Questions(self.cursor)
        result = questions.get_answered_questions(1)
        self.assertEqual(result, 0)
    def test_get_next_question(self):
        questions = Questions(self.cursor)
        result = questions.get_next_question(1)
        self.assertEqual(result, '1')
    def test_store_answer(self):
        questions = Questions(self.cursor)
        result = questions.store_answer(1, 1, 1)
        self.assertEqual(result, 'test')
    def test_mark_answer_wrong(self):
        questions = Questions(self.cursor)
        questions.mark_answer_wrong(1)
        self.cursor.execute('SELECT questions_incorrect 
FROM sessions WHERE session_id = ?', (1,))
        result = self.cursor.fetchone()
        self.assertEqual(result[0], 1)
    def test_tally_results(self):
        questions = Questions(self.cursor)
        result = questions.tally_results(1)
        self.assertEqual(result['questions_correct'], 0)
        self.assertEqual(result['questions_incorrect'], 0)
if __name__ == '__main__':
    unittest.main()

This generated unittest suite creates an in-memory SQLite database, defines tables, inserts test data, and exercises the Questions class. It demonstrates useful context-sensitive scaffolding, while retaining the need for local setup fixes and verification. section 8.4.4

For test generation, Blackbox AI can use application files as chat context and generate unittest or pytest-oriented starting points. Generated tests may be close to runnable, but check imports, fixtures, database setup, intended behavior, and missing boundary conditions before treating them as coverage. section 8.3.3 section 8.4.4 section 8.4.5

Blackbox AI is presented as a newer code-generation and problem-solving option with a free basic plan, code chat, multiple-IDE support, and specialized agents. Trade-offs include being less established, offering a single model, and providing limited public detail about training data and model specifics. section 8.3.3 section 8.4.5

How Coding with AI covers it

How deep it goes
Demonstrates prompting, generated database and selection code, refactoring, and unittest or pytest generation without detailing model internals.
Examples
Uses a HAM radio practice-exam app, SQLite Questions methods, random 35-question selection, and in-memory database tests.
What it assumes
Assumes enough Python and application knowledge to judge architecture, supply requirements, and review generated code.
What you can do after
Apply it via IDE chat to draft code and tests, then review, modify, run, and debug the generated results.
How it connects
Connects code generation with prompt engineering, Flask, SQLite, separation of concerns, unittest, pytest, and software testing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Coding with AI. The section links point to the parts of the book it draws on.