Evaluating LLM Code Generation: From Requirements to a Working Desktop Tool
This article presents a practical, reproducible method for testing whether a large language model can generate a runnable desktop application. Instead of relying on benchmark scores, we define a concrete task—a batch video-to-audio converter built with Python and tkinter—and walk through a structured prompt template, a requirement checklist, a concurrency pattern that keeps the UI responsive, and follow-up questions to verify contextual consistency. The focus is on real-world usability: feature coverage, direct runnability, and the model's ability to explain its own code. We also discuss edge cases, testing environment documentation, and how this approach can be integrated into a team's development workflow.
1. The Gap Between Benchmarks and Real Development
The coding ability of open-source large language models (LLMs) has improved significantly in recent years. Many teams evaluate models using public benchmarks, but those benchmarks usually consist of isolated functions or algorithmic problems. A desktop program with a graphical interface, file operations, and background tasks is very different. This article deliberately avoids citing unverified improvement percentages and instead focuses on a test method you can reproduce yourself.
To judge whether a model can produce working software, three questions need to be answered:
- Does the generated code cover every feature in the requirement?
- Can the generated code run directly, without missing dependencies or hidden errors?
- In follow-up questions, can the model correctly explain the code it generated?
2. The Test Task: A Batch Video-to-Audio Converter
The test task is a desktop tool that extracts audio from video files in batch and exports it as MP3 or WAV. This task was chosen for three reasons.
First, it involves multiple knowledge areas: file traversal, calling an external program, GUI layout, and event handling. A single error in any of these areas can break the entire program.
Second, it contains a typical pitfall. Conversion tasks take time. If the conversion runs directly on the main thread, the window becomes unresponsive during the process. Whether the model proactively uses a worker thread or an asynchronous solution reveals its understanding of concurrency.
Third, the result is objectively verifiable. The program either launches and completes conversions, or it does not.
The requirement list is as follows:
- Support common video formats (mp4, mkv, avi, mov) and export audio as MP3 or WAV.
- Implement using Python and tkinter.
- Provide a file list with options to add individual files or entire folders.
- Allow setting the output directory and output format.
- Provide “Start Conversion” and “Exit” functions.
- Display a progress bar and a status bar, with error popups when something fails.
- The UI must not freeze during conversion.
Requirement 7 does not specify the implementation method—only the expected outcome. This tests whether the model independently arrives at a suitable solution.
For testing, it is recommended to prepare sample files that include:
- At least one file for each supported video format.
- A large file (several hundred MB) to observe progress and responsiveness.
- A folder with multiple nested subdirectories.
- A video without an audio track.
- A corrupted file.
- A pair of files with the same name, to check whether output overwrites.
All tests should be performed on copies of the files, never on the original material.
3. A Structured Prompt Template
The prompt’s job is to state the requirements clearly. Here is a reusable template that can be adapted for any task:
[Role] You are an experienced Python desktop application developer.[Tech Stack] Python 3.x, standard library tkinter, call ffmpeg that is already installed on the system (via command line). Do not use any other third-party libraries.[Functional Requirements] (List each item; each should be independently verifiable)1. ...2. ...[Non-Functional Requirements]- Long-running operations must not block the UI thread.- Show clear error messages, including the name of the failed file.- When an output file already exists, do not overwrite it.[Output Requirements]1. Provide a complete, runnable single .py file.2. Provide the command to install dependencies.3. Provide a functional description and usage steps.4. List the edge cases you consider and how you handle them.[Self-Check] Before outputting, confirm: every functional requirement has corresponding code; no missing error message when ffmpeg is not installed.
Three points deserve special attention. The tech stack must be explicit; otherwise, the model may pick an incompatible library. Non-functional requirements should be listed separately, because “the interface must not freeze” is often overlooked. Ask the model to list edge cases—this makes later verification much easier.
4. Documenting the Test Environment
The same prompt can produce different results across model versions or environments. Therefore, a test report should record the following items, otherwise the conclusions cannot be reproduced:
- Model name, version, source, and calling parameters (e.g., temperature).
- Operating system and version.
- Python, tkinter, and ffmpeg versions.
- Test sample types, counts, and sizes.
- The exact prompt text and the text of every follow-up question.
5. Requirements Verification Checklist
After code generation, verify each requirement one by one. The following table lists the check method and pass criteria for each item. The test author simply fills in the results.
| # | Requirement | Check Method | Pass Criteria |
|---|---|---|---|
| 1 | Common video formats and audio export | Convert one file of each format | Output file is playable; duration matches the source |
| 2 | Python + tkinter | Inspect source code and run it | No non-standard library dependencies; ffmpeg is called externally |
| 3 | File list | Add a single file and a folder | List shows complete entries with no duplicates |
| 4 | Output settings | Change output directory and format | Files are written to the specified directory with the correct format |
| 5 | Start and exit | Click the buttons | Exit behavior is clear; closing during conversion asks for confirmation |
| 6 | Progress and error indication | Test with a corrupted file | Progress bar updates; error popup contains the file name |
| 7 | UI does not freeze | Drag window and click buttons during conversion of a large file | Window remains responsive throughout |
Also verify features the model added on its own:
- Recursive subdirectory scanning: triggered when a folder is added. Risk: scanning many files may take time and could include unwanted files.
- Automatic renaming for duplicate files: triggered when an output file exists. Risk: poorly designed numbering may produce hard-to-read filenames.
- Detecting whether ffmpeg is installed: triggered when the start button is clicked. Risk: an inaccurate detection method could produce false positives or negatives.
- Automatic extension expansion: risk: if the extension does not match the actual codec, conversion may fail.
6. Concurrency: A Minimal Pattern for a Non-Freezing UI
In tkinter, widgets can only be modified from the main thread. Therefore, the time-consuming conversion runs in a worker thread, which sends progress updates through a queue. The main thread uses after to periodically poll the queue and update the UI. The following code demonstrates this structure, omitting the full UI layout for brevity.
import osimport queueimport shutilimport subprocessimport threadingimport tkinter as tkfrom tkinter import messageboxdef unique_path(outdir, src, ext):"""Generate an output path that does not overwrite existing files."""base = os.path.splitext(os.path.basename(src))[0]dst = os.path.join(outdir, base + ext)n = 1while os.path.exists(dst):dst = os.path.join(outdir, f"{base}_{n}{ext}")n += 1return dstdef convert_one(src, dst):# Pass arguments as a list, not through the shell, so special characters in filenames are not executed as commandscmd = ["ffmpeg", "-y", "-i", src, "-vn", dst]subprocess.run(cmd, check=True, capture_output=True)def worker(files, outdir, q):total = len(files)for i, src in enumerate(files, start=1):try:dst = unique_path(outdir, src, ".mp3")convert_one(src, dst)q.put(("progress", i / total, f"Completed {i}/{total}"))except subprocess.CalledProcessError as e:err = e.stderr.decode(errors="ignore")[-300:]q.put(("error", src, err))q.put(("done", None, None))def poll(root, q, bar, status):try:while True:kind, a, b = q.get_nowait()if kind == "progress":bar["value"] = a * 100status.set(b)elif kind == "error":messagebox.showerror("Conversion failed", f"{a}\n{b}")elif kind == "done":status.set("All done")return # Stop pollingexcept queue.Empty:passroot.after(100, poll, root, q, bar, status)def start_conversion(root, files, outdir, bar, status):if shutil.which("ffmpeg") is None:messagebox.showerror("Missing dependency", "ffmpeg not detected. Please install it and add it to PATH.")returnq = queue.Queue()threading.Thread(target=worker, args=(files, outdir, q), daemon=True).start()poll(root, q, bar, status)
Here is how to verify this code. First, convert a file of several gigabytes. While the conversion is running, drag the window and click buttons—the window should remain responsive. Second, as a control, run the worker function directly in the button callback (without the worker thread) and perform the same actions—the window will become unresponsive. Third, check the output: files with the same name should be numbered _1, _2, and the original files must remain unchanged.
This code still has two limitations. The daemon=True thread ends when the window closes, but a running ffmpeg subprocess may remain and leave an incomplete output file. You should terminate the subprocess and remove the incomplete output before exiting. Also, unique_path checks for existence before creating, which introduces a race condition. With only one worker thread, that is not a problem. If you later switch to parallel conversions with multiple threads, you need a lock around the path-generation step.
7. Follow-Up Questions: Checking Contextual Consistency
After the initial generation, ask several follow-up questions and compare the answers with the code. Useful examples:
- If no output directory is set, where does the program write by default?
- Why must progress updates go through a queue instead of directly modifying the progress bar from the worker thread?
- If one file fails to convert, will subsequent files still be processed?
- If two files have the same name, what will the output filenames be?
- When the window is closed during an active conversion, what happens?
The evaluation criterion is that the answers must match the code. If the model says “conversion continues after a failure,” the code must contain an appropriate exception-handling structure that does not break the loop. If the answer contradicts the code, the model does not have a coherent understanding of what it generated.
8. Risks and Edge Cases
A batch conversion tool heavily involves file I/O. Keep the following points in mind during testing and use.
- Data safety: run tests on copies of your material. The program should only create new files; it must never delete or modify source files. If you need an overwrite feature, add an explicit confirmation step.
- Directory setting: do not set the output directory inside the input directory that is being scanned recursively—otherwise newly generated files may be picked up again for processing.
- Logs and privacy: ffmpeg error output can contain local paths and filenames. Remove sensitive information before sharing logs.
- Resource usage: converting large files consumes significant disk and CPU. Run batch tasks in an environment with enough free space.
- Execution of generated code: never run unvetted code directly on a machine holding important data. Use an isolated virtual environment or sandbox, and restrict the program’s file access scope.
- Call costs: multiple rounds of generation and follow-up questions consume tokens. Record the number of calls and token usage for each task to compare the cost-effectiveness of different models.
9. Considerations for Integrating into a Team Development Workflow
If a team wants to integrate code generation into its development process, the following building blocks are useful. A model-access layer standardizes API calling and authentication. A code-validation layer performs syntax checks and unit tests in a sandbox. A feedback layer sends runtime errors back to the model for correction. A logging and monitoring layer tracks generation quality, time, and cost.
An automated correction loop needs a maximum retry limit; otherwise, the model may keep rewriting the same error while continuously consuming tokens, without necessarily improving.
When selecting services and deployment options, first confirm the team’s compliance requirements: whether code and samples can be uploaded to external services, how sensitive fields in logs are handled, and the cost and data-location policies of different providers. The architecture above does not depend on a single vendor; teams can replace components with their existing infrastructure.
10. Conclusion
Benchmark scores reflect a model’s performance on standardized problems. To determine whether it is useful for real development, you need a concrete requirement, a reproducible prompt, a verification checklist with clear acceptance criteria, and follow-up questions.
Using the method in this article, you can reproduce the results in your own environment and evaluate a model’s coverage of requirements, concurrency handling, edge cases, and contextual consistency. The conclusion should be based on your test records.
