I've been looking for a Linux command line tool that leverages AI to streamline my terminal experience. There are so many instances where I forget a command or what to do some convoluted sequence of shell commands where it takes me a whole lot of time to figure it out. This is way easier now with LLMs but moving back and forth between the terminal and browser isn't the smoothest and the browser doesn't have access to my local device. Although letting an AI system run this on your local device is pretty scary when you think about it, I mean imagine if you give it a prompt and it incorrectly interprets the meaning and ends up deleting important files and the backup you may have for those files. For this reason, make sure you have cloud or isolated/disconnected backups.
curl -sS https://raw.githubusercontent.com/ekkinox/yai/main/install.sh | bash
user@system:~$ yai
user@system:~$ emacs .config/yai.json
It would be nice if yai used vector stores and other tools (e.g. similar to Langchain) to enable questions and answering of your documents and code. I would take a stab at it but the problem is yai is written in the Go programming language which I have absolutely no experience with. The tool is still very useful though as I'll show below.
A somewhat complicated example
yai -e " I want you to create a folder in my home directory called simple_job; if the folder exist just delete it. In the folder please create a LAMMPS molecular dynamics script using the lennard-jones potential for Argon gas in a box with lengths 20 angstroms (ex. region 1 block 0 20 0 20 0 20), be sure to create 100 randomly placed Argon atoms in the box and set mass. You can use a NVT ensemble and set the temperature to 300 Kelvin and run the simulation for 1000 timesteps. Make sure you validate all the LAMMPS commands you use. After creating the LAMMPS script, I want you to use the task-spooler, command 'tsp', to run the command to run is 'mpirun -np 1 /opt/lammps/23Jun2022/build/lmp -sf omp -in {NAME_OF_SCRIPT}' where {NAME_OF_SCRIPT} is the name you used for the LAMMPS simulation script you created in the folder simple_job."
So what did this give in terms of the commands? At first it looks a bit
difficult to go through and what you see is that it strings all the commands
together and for the script it uses echo. Here is the output:
`mkdir -p ~/simple_job && rm -rf ~/simple_job && mkdir -p ~/simple_job && cd ~/simple_job && echo -e 'units lj
atom_style atomic
lattice fcc 0.8442 region simbox block 0 20 0 20 0 20 create_box 1 simbox create_atoms 1 random 100 12345 simbox
mass 1 39.948 pair_style lj/cut 2.5 pair_coeff 1 1 1.0 1.0 2.5 velocity all create 300.0 12345 fix 1 all nvt temp
300.0 300.0 0.1 thermo 100 thermo_style custom step pe temp press run 1000' > simulation.lammps && tsp mpirun -np 1
/opt/lammps/23Jun2022/build/lmp -sf omp -in simulation.lammps`
Create the folder simple_job, delete it if exists, and create the LAMMPS script with the desired parameters. Then use
confirm execution? [y/N]
Is this correct, does it work? The LAMMPS commands don't look like they are on
newlines but indeed they are when you look at the final file produced. Did it
run, it did! It submitted the task to tsp and the LAMMPS script
actually ran. This is pretty cool if you ask me, especially if you want to
create a draft template simulation folder/file setup. Below is the
simulation result visualized which seems to run without any wonky behavior
even though the pair potential coefficients are not correct. I had to manually
add the dump command but I could have specified this in the prompt.
![]() |
Simulation result from a prompt given to Yai. |
Caveats
Where to go from here
No comments:
Post a Comment
Please refrain from using ad hominem attacks, profanity, slander, or any similar sentiment in your comments. Let's keep the discussion respectful and constructive.