AI is a powerful tool. It can help us in many ways.
In this article, I will compare Meta.AI, Claude 3 Opus and Chat GPT4 in the term of keeping context.
AI Comparison
First prompt - Bootstrap DB
I like to write the code. AI can do this too. The main difference is that AI can lose the context immediately.
Let’s take a simple prompt:
1
| prompt > create mysql database using docker with demo.sql file
|
I’ll remove all that AI explanation crap and here is the main results:
Claude:
Dockerfile:
1
2
3
4
5
6
7
8
| FROM mysql:latest
# Set environment variables
ENV MYSQL_ROOT_PASSWORD=root
ENV MYSQL_DATABASE=mydb
# Copy the SQL file to the container
COPY demo.sql /docker-entrypoint-initdb.d/
|
demo.sql:
1
2
3
4
5
6
7
8
9
10
11
| -- Create a table
CREATE TABLE users (
id INT PRIMARY KEY,
name VARCHAR(50),
email VARCHAR(50)
);
-- Insert sample data
INSERT INTO users (id, name, email) VALUES
(1, 'John Doe', 'john@example.com'),
(2, 'Jane Smith', 'jane@example.com');
|
And a bunch of instructions:
1
2
3
| docker build -t mysql-demo .
docker run --name mysql-container -d -p 3306:3306 mysql-demo
docker exec -it mysql-container mysql -uroot -proot
|
Emm, who will manually would like to run this?
1
2
3
| USE mydb;
SHOW TABLES;
SELECT * FROM users;
|
ChatGPT:
Pretty similar to Claude
1
2
3
| FROM mysql:5.7
ENV MYSQL_DATABASE demo
COPY ./demo.sql /docker-entrypoint-initdb.d/
|
version 5.7 - WAT?
And ChatGPT provided docker-compose file:
1
2
3
4
5
6
7
8
9
10
11
12
13
| version: '3'
services:
mysql:
build: .
environment:
MYSQL_ROOT_PASSWORD: rootpassword
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
volumes:
mysql_data:
|
And here is an instructions on how to run them:
1
2
| docker-compose build
docker-compose up
|
MetaAI:
MetaAI decided to go another way. It provides just a bunch of instructions.
1
2
3
4
| docker pull mysql/mysql-server:8.0
docker run --name mysql-demo -p 3306:3306 -e MYSQL_ROOT_PASSWORD=<your_password> -d mysql/mysql-server:8.0
docker cp demo.sql mysql-demo:/tmp/
docker exec -it mysql-demo mysql -uroot -p<your_password>
|
run pretty the same sql queries as Claude.
1
2
3
| mysql> CREATE DATABASE demo;
mysql> USE demo;
mysql> SOURCE /tmp/demo.sql;
|
Firs step overview
Every AI provided different approach with the same instruction.
I do not like Meta, because it provides just a bunch of instructions. Claude used mysql:latest
which is kind better than ChatGPT mysql:5.7
.
Second prompt - use docker compose
I like to use docker-compose. It is easier to maintain and run.
1
| prompt > use docker compose and store mysql data in ./data folder
|
Claude:
1
2
3
4
5
6
7
8
9
10
11
12
| version: '3'
services:
db:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: mydb
volumes:
- ./data:/var/lib/mysql
- ./demo.sql:/docker-entrypoint-initdb.d/demo.sql
ports:
- "3306:3306"
|
ChatGPT:
1
2
3
4
5
6
7
8
9
10
11
| version: '3.1' # Using version 3.1 for compatibility with volume mapping
services:
mysql:
build: .
environment:
MYSQL_ROOT_PASSWORD: rootpassword # Change the password as needed
ports:
- "3306:3306"
volumes:
- ./data:/var/lib/mysql # Maps the local 'data' directory to the container's MySQL storage
|
MetaAI:
1
2
3
4
5
6
7
8
9
10
11
12
| version: '3'
services:
mysql:
image: mysql/mysql-server:8.0
restart: always
environment:
MYSQL_ROOT_PASSWORD: <your_password>
MYSQL_DATABASE: demo
volumes:
- ./data:/var/lib/mysql
ports:
- 3306:3306
|
Conclusion
The best AI for this task is Claude. It provides the most accurate result understanding my end goal.