# ai-cli **Repository Path**: chambersxdu/ai-cli ## Basic Information - **Project Name**: ai-cli - **Description**: 一个简单的命令行LLM工具 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-03 - **Last Updated**: 2025-05-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Simple AI CLI Assistant A simple command-line interface (CLI) tool to interact with Large Language Models (LLMs) using an OpenAI-compatible API directly from your terminal. Designed for personal use and quick setup across machines. ## Installation **⚠️ Security Warning:** The following command downloads and executes a script directly from the internet. This method is convenient but bypasses standard security checks. **Only run this command if you trust the source URL (i.e., you control the script being downloaded).** **Run the Installer:** Open your terminal and execute: ```bash curl -fsSL https://gitee.com/chambersxdu/ai-cli/raw/master/install_ai.sh | bash ``` If you want to install it on Windows, please open the Powershell and execute: ```bash irm https://gitee.com/chambersxdu/ai-cli/raw/master/install.ps1 | iex ``` **What the installer does:** * Checks for prerequisites. * Installs the `requests` Python library using `pip3 install --user`. * Downloads the `ai.py` script. * Installs it to `~/bin/ai`. * Makes it executable (`chmod +x`). * Checks if `~/bin` is in your system's `PATH` and provides instructions if it's not. If you see a warning about PATH, you'll need to add `export PATH="$HOME/bin:$PATH"` to your shell configuration file (e.g., `~/.bashrc` or `~/.zshrc`) and restart your shell or source the file. ## Configuration 1. **First Run:** Run the `ai` command once without arguments: ```bash ai ``` This will create the default configuration file at `~/.ai_cli_config` if it doesn't exist. 2. **Edit Configuration:** Open the configuration file with your preferred text editor: ```bash nano ~/.ai_cli_config # or vim, code, etc. ``` 3. **Set Required Values:** * `api_key`: **REQUIRED.** Replace `YOUR_API_KEY_HERE` with your actual LLM API key. 4. **Customize Optional Values:** * `base_url`: Change if you are not using the official OpenAI API (e.g., for a local model server like Ollama: `http://localhost:11434/v1`). * `default_model`: Set your preferred default model name. * `models`: Edit the comma-separated list of models available through your `base_url`. * `system_prompt`: Customize the instructions given to the AI. * `request_timeout`: Adjust the API request timeout in seconds if needed. ## Usage * **Basic Query (uses default model):** ```bash ai "How to find files modified yesterday?" ``` * **Specify a Model:** ```bash ai -m gpt-4o "Translate 'hello world' to French" ``` * **List Configured Models & System Prompt:** ```bash ai -l ``` * **Verbose Output (for debugging):** ```bash ai -v "Why is the sky blue?" ``` ## ⚠️ Important Safety Warning * This tool sends your query to an external LLM API. * The AI model can generate **incorrect, inefficient, or dangerously destructive commands** (e.g., involving `rm -rf`, `sudo`, `chmod`, `dd`). * The system prompt asks the AI to be alert to dangerous commands, but based on testing, this is **NOT RELIABLE**. The AI may fail to identify risks or may not provide adequate warnings. * **YOU ARE RESPONSIBLE** for understanding and verifying any command suggested by this tool **BEFORE** executing it in your terminal. * **NEVER blindly execute commands generated by the AI, especially those involving `sudo` or potentially destructive operations.**