# Programmable Prompt Engine (PPE) CLI Command `ai` is the shell CLI command to manage the brain(LLM) files and run a PPE agent script mainly. * Run script file command `ai run`, eg, `ai run -f calculator.ai.yaml "{content: '32+12*53'}"` * `-f` is used to specify the script file. * `{content: '32+12*53'}` is the optional json input to the script. * Scripts will display intermediate echo outputs during processing when streaming output. This can be controlled with `--streamEcho true|line|false`. To keep the displayed echo outputs, use `--no-consoleClear`. * Script can be single YAML file (`.ai.yaml`) or directory. * Directory must have an entry point script file with the same name as the directory. Other scripts in the directory can call each other. * Manage the brain files command `ai brain` include `ai brain download`, `ai brain list/search`. * Run `ai help` or `ai help [command]` to get more. ## Usage Install the CLI globally: ```sh $ npm install -g @offline-ai/cli $ ai COMMAND running command... $ ai (--version) @offline-ai/cli/0.3.8 linux-x64 node-v20.14.0 $ ai --help [COMMAND] USAGE $ ai COMMAND ... ``` Search and Download a brain(LLM) on huggingface. Choose one to download, or type more to reduce the brain(models) list Note: * All quantification (compression) brain 🧠 models are uploaded by the user by themselves, so it cannot guarantee that these user quantitative (compressed) brain 🧠 models can be used * At present, the GGUF quantitative brain 🧠 model has been tens of thousands, and many of them are repeated. * `AI Brain List` Display the brain list, which is part of the list filtered by the `featured`. If you want to display all the brain list, use `--no-onlyFeatured` option. ```sh #list the downloaded brain list #which means `ai brain list --downloaded` $ai brain #You can specify the keyword of the brain model to search $ai brain search llama3-8b #Download the brain, if there are multiple choices in the input keywords, you will be required to specify #LLAMA3-8B is the name of the brain model to be searched #`-q q4_0` is the quantification level of download. If it is not provided, it will be prompted to specify #`--hubUrl` is the mirror URL address of Huggingface $ai brain download llama3-8b -q Q4_0 --hubUrl=https://huggingface-mirror-url-address ``` After download, get the brain dir: ```bash ai config brainDir { "brainDir": "~/.local/share/ai/brain" } ``` You can create your config by `ai config save` Download and run the brain(LLM) Server: [llama.cpp](https://github.com/ggerganov/llama.cpp/releases/latest) ```bash mkdir llamacpp cd llamacpp wget https://github.com/ggerganov/llama.cpp/releases/download/b3631/llama-b3631-bin-ubuntu-x64.zip unzip llama-b3631-bin-ubuntu-x64.zip cd build/bin #run the server #`-ngl 33` means GPU layers to load, adjust it according to your GPU. #`-c 4096` means max context length #`-t 4` means thread count ./server -t 4 -c 4096 -ngl 33 -m ~/.local/share/ai/brain/your-brain-model.gguf ``` Now you can run your AI script: ```bash #you can config the search agent paths in `agentDirs` config or add `-s your_search_path` to argument . #`-f` means the agent file #`-i` means entering the interactive mode $ai run -if examples/char-dobby.ai.yaml ``` Note: * By default, the history after running is in the directory `~/.local/share/ai/logs/chats/[script_file_basename]/history`. You can check `seeds`, `temperature` and other information here. * In interactive mode, the history will be automatically loaded by default. If you don't need it, you can use `--new-chat` * In non-interactive mode, the history will not be automatically loaded. A new history will be generated for each run. * To completely disable the history saving, you can use `--no-chats` switch. ## Commands ### `ai run [FILE] [DATA]` 💻 Run PPE ai-agent script file. ``` USAGE $ ai run [FILE] [DATA] [--json] [-c ] [--banner] [-u ] [-s ...] [-l silence|fatal|error|warn|info|debug|trace] [-h ] [-n] [-k] [-t -i] [--no-chats] [--no-inputs ] [-m] [-f ] [-d ] [-D ...] [-a ] [-b ] [-p ...] [-L ] [-A ] [-e true|false|line] [--consoleClear] ARGUMENTS FILE the script file path, or the json data when `-f` switch is set DATA the json data which will be passed to the ai-agent script FLAGS -A, --aiPreferredLanguage= the ISO 639-1 code for the AI preferred language to translate the user input automatically, eg, en, etc. -D, --data=... the data which will be passed to the ai-agent script: key1=value1 key2=value2 -L, --userPreferredLanguage= the ISO 639-1 code for the user preferred language to translate the AI result automatically, eg, en, zh, ja, ko, etc. -a, --arguments= the json data which will be passed to the ai-agent script -b, --brainDir= the brains(LLM) directory -c, --config= the config file -d, --dataFile= the data file which will be passed to the ai-agent script -e, --streamEcho=