Developing Software with AI and My Experience Working with AI Agent VVRI
Hello, this is Luke, a developer working on XRCLOUD. In a previous post, I mentioned that I am coding together with VVRI, who was created using ChatGPT-S. There has been a lot of talk about AI potentially replacing software developers, but from my experience using ChatGPT as a coding assistant, we’re far from that point. In fact, I believe the value of skilled software developers will only increase. I’d like to share one of my experiences working during the Chuseok holiday and discuss the competencies needed for AI-assisted software development.
1. Defining the Problem
Software development starts with defining the problem. Knowing what to develop and understanding the scope of the task is crucial before starting. The abstract scope of the task maps directly to the scope of the software code.
The issue I encountered over the weekend was as follows:
After modifying the deployment batch and redeploying, the database was lost. It turns out the storage of the container was not mapped to the host server’s storage. As a result, when redeploying, the container was fully reset, causing the existing database to be lost. Fortunately, since the service had no users yet, there wasn’t much user data. The issue was that the metaverse space (Spoke) attached to the server, including 3D models and images, might have also been lost. Luckily, when I checked, the storage was mapped correctly. However, upon opening the storage files, I couldn’t help but be shocked.
First, I checked the metadata and tried changing the file extensions, but the files were corrupted. Upon uploading them, I noticed that the content of the binary files had changed, which suggested that they were encrypted.
Now, the task was to define the problem’s scope. The first thing I did was determine how many files needed to be restored. I asked the following question:
Q. Luke’s Question
I want to check the number of blob files in all subfolders under the “dev” folder in the current directory on Ubuntu. I also have JSON files that contain a field called “content_type” in the following format:{"promotion_token": null, "content_type": "image/jpeg", "content_length": 322533}
Could you write a shell script to count files by content_type?
2. Confirming the Task and Suggesting a Work Methodology
Currently, most AI tools don’t directly execute the code they generate, and even if they could, I wouldn’t recommend it. AI can often produce risky code that can delete your work or unnecessarily complicate things. It’s essential to review the generated code, test it, and verify the results.
Here’s what I asked and the response I got from VVRI:
Q. Luke: Did you open the JSON file to check it?
A. VVRI: No, in the previous script, I didn’t directly open the JSON file. Instead, I used a tool called jq
to extract the content_type
field from the JSON file.
However, if the JSON file structure is different from what we expect, or if certain keys are missing or the file itself has issues, the script may not work correctly.
At this point, it would be a good idea to manually inspect a few JSON files and check if the content_type
field is correctly included.
The output still didn’t seem correct, so I copied the result and showed an example of a JSON file opened using the cat
command.
Q. Luke: It’s not working. Let me show you an example.
azureuser@room-duphonics-co:/app/haio/storage$ cat dev/expiring/30/32/303203f3-85f6-48f4-9d1b-83fbd69c0568.meta.json
{"promotion_token":null,"content_type":"image/jpeg","content_length":322533}
A. VVRI: Now it’s clearer. The content_type
field is included as "content_type": "image/jpeg"
in the JSON structure. However, there may be issues with extracting this field using grep
. I’ll adjust the script to use a more precise method to extract the content_type
field and count the files accordingly.
Then, after realizing it still wasn’t working as expected, I instructed VVRI to log the process for debugging.
Q. Luke: It’s still not working. I can’t even tell if it’s finding the JSON files. Print the process.
After reviewing the log results, VVRI and I discussed the issue further.
Q. Luke: The JSON files are being found, but it seems like the content_type
fields aren’t being recorded. I want to know how many files there are by content type.
A. VVRI: The JSON files are indeed being found, but it seems like we aren’t correctly retrieving the content_type
values. If it’s not critical that the blob files exist, we can simply extract the content_type
from the JSON files and count those instead.
Q. Luke: Yes, the blob files don’t matter. I just want to count the different content_type
entries from the JSON files.
A. VVRI: Now I fully understand. The blob files are irrelevant, and you simply want to count the different content_type
values found in the JSON files.
I’ll now revise the script to extract and count the content_type
values from the JSON files.
Finally, after verifying that the types were being output correctly, I asked VVRI to clean up the intermediate debug prints and finalize the script.
3. Archiving and Documentation
Below is the final script that VVRI created successfully. I also requested comments in both Korean and English and organized the work for future reference.
#!/bin/bash
# Define the directory to search
# 검색할 디렉토리를 정의합니다
base_dir="./dev"
output_file="content_types.txt"
# Clear the output file if it already exists
# 출력 파일이 이미 존재할 경우 내용을 초기화합니다
> "$output_file"
# Find all JSON files and process each one
# 모든 JSON 파일을 찾아서 각각 처리합니다
find "$base_dir" -type f -name "*.json" | while read -r json_file; do
# Extract the content_type from the JSON file using grep
# grep을 사용하여 JSON 파일에서 content_type을 추출합니다
content_type=$(grep -oP '"content_type"\s*:\s*"\K[^"]+' "$json_file")
# If the content_type was found, output it to the file
# content_type이 존재하면 파일에 저장합니다
if [[ -n "$content_type" ]]; then
echo "$content_type" >> "$output_file"
fi
done
# Count the number of lines (content_type entries) in the output file
# 출력 파일에서 content_type 항목의 라인 수를 셉니다
line_count=$(wc -l < "$output_file")
# Output the result
# 결과를 출력합니다
echo "Content type counts saved to $output_file" # content_type 개수가 $output_file에 저장되었습니다
echo "Total content types found: $line_count" # 총 $line_count개의 content_type을 찾았습니다
Script Explanation:
- Output File Variable Setting:
output_file="content_types.txt"
specifies the filename where thecontent_type
values will be saved.- File Initialization:
> "$output_file"
clears the file if it already exists.- Content Type Output:
echo "$content_type" >> "$output_file"
saves eachcontent_type
value to the file.- Line Count Calculation:
wc -l < "$output_file"
counts the lines in the file and stores it inline_count
.- Result Output:
- Outputs the total number of
content_type
entries found.
Execution Instructions:
- Save the script and grant execute permissions
chmod +x count_files.sh
2. Run the script:
sudo ./count_files.sh
4. Will AI Replace Software Developers?
For those unfamiliar with development, the above process might seem complicated. However, it’s roughly on par with questions on the Information Processing Engineer exam. Documenting the entire process took about an hour, but the actual shell coding, if I had complete command of the syntax, might have taken just 15 minutes. That said, shell coding isn’t my main focus. I used to work with C, C++, and Java, but it’s been a while, and these days I mostly work with JavaScript. Honestly, I’m not even sure what my main language is anymore. If I had to code without ChatGPT, it would take me a significant amount of time just to look up syntax.
This reminds me of the first time I failed my Information Processing Engineer exam in college. I had little information about the exam and walked in feeling relaxed. At the time, I was somewhat proficient in C, but I chose Visual Basic for the exam because I thought it would be safer and easier. I figured opening files, sorting them, and writing them back out would be straightforward. But when I got to the exam, I realized there was no MSDN installed. I didn’t know the Visual Basic equivalent of the fopen
function. I ended up writing C code in comments and walked out. Unsurprisingly, I failed. The second time around, I passed easily with test code included.
Coding has never been about choosing the right language like Java or C. AI can code, yes, but the problem is someone needs to instruct the AI. Or we need to help the AI understand our business and software. If you unknowingly execute a code that was misunderstood, you might end up planting a bug.
5. The Future of AI Coding
For AI coding to succeed, the AI must fully understand the project. For instance, one task I worked on recently involved analyzing how files are stored and determining how to replace those files with a CDN.
The problem is that the code is open-source, so if I modify it improperly, future changes to the open-source project could make it difficult to maintain. That’s why I’m considering creating an external layer or module to handle this task.
Without this background knowledge, if I asked the AI to modify the code all at once, it would likely rewrite all the storage and loading code. But if too many changes are made at once, it almost always leads to issues, and the project duration extends.
For those who can’t read code, approaching this could be impossible. Although AI helped a lot with understanding unfamiliar Elixir code, ultimately, the structure of code is generally the same regardless of the language. The language itself isn’t as important as understanding how to approach the problem and how to make the necessary changes with AI assistance.
This, I believe, is the future of AI coding, and it may become mainstream in the next 10 years.
#ChatGPT #SWDevelopment #AICoding