LLM CLI: Running Language Models from the Command Line

Tags llm llm-cli

Issue

  • What is LLM in the CLI?

Environment

  • Windows
  • Mac
  • Linux

Resolution for Tier 2

LLM CLI means using an AI language model directly from the computer’s command line or terminal. 

Instead of opening a website like ChatGPT, you type commands in the terminal and the LLM responds there. It can help with coding, file analysis, troubleshooting, summarizing text, writing commands, and automating tasks adjusting the computer’s settings. If it can be done in PowerShell, CMD, or a Terminal window, AI can do it for you.

 

Installation

Windows Installation

Run these in order: 

  1. Set-ExecutionPolicy -Scope CurrentUser RemoteSigned 
  2. winget install OpenJS.NodeJS.LTS 
    • reboot the terminal window then run this: 
  3. npm install -g opencode-ai@latest

Mac Instillation

Run one long command: 

curl -fsSL https://opencode.ai/install | bash 
if [ -d "$HOME/.opencode/bin" ]; then 
grep -qxF 'export PATH="$HOME/.opencode/bin:$PATH"' "$HOME/.zshrc" || echo 'export PATH="$HOME/.opencode/bin:$PATH"' >> "$HOME/.zshrc" 
fi 
source "$HOME/.zshrc" 

OR

echo 'export PATH="$HOME/.opencode/bin:$PATH"' >> ~/.bash_profile && echo "alias bigpickle='opencode -m opencode/big-pickle'" >> ~/.bash_profile && exec bash

Linux Installation

Run:

curl -fsSL https://opencode.ai/install | bash 

 

Verification

Type this: opencode 

Within this you can maximize the window to see your context length (The AI’s short term memory of what you’re doing) Define context length. Or Context length is how much information the LLM can “keep in mind” at one time. 

Emphasize this: 

It now has access to see into your os and software. Be careful and smart. 

On first use: 

/init.     (This will initialize the AI with your computer and create a file that will be read every time it opens) 

Then tell the AI to do this: 

Add this to the initialization file: 

I’m low on tokens, 

Keep responses simple, 

Don’t over-explain, 

Don’t act if I didn’t ask you to, 

Only give me what I ask for, I’ll tell you if I need more information or if I want you to act.

 

How to talk to AI

Give it context. Let it know what is happening and tell it to look at your computer. Then ask it to provide a list of solutions or ideas without acting, in a numbered list.  

Tell it to create a file for a project called the ticket number. Then tell it to put all of the details of what it has done into that project file. Then after it shows you a list, you can say, work on number 3 and then document your efforts and results in the project file. Finally tell me in short simple terms how it went. 

You can reference the project via the ticket number after any given amount of time. “Look at the project (ticket number) and tell me where we are in the project in a numbered list.”