An interactive command-line framework for LLM and Agent conversations, supporting streaming responses, tool-use, and configurable shortcut commands.
# 1. Install dependencies
pip install -r requirements.txt
# 2. Set your API key
export OPENAI_API_KEY="your-key-here"
# 3. Launch the CLI
python cli.py
# Or with agent mode enabled
python cli.py -aai_cli_framework/
├── cli.py # Entry point & interactive loop (click + rich)
├── main.py # Alternative entry point
├── config.yaml # Default configuration
├── core/
│ ├── config.py # YAML config loader with env var resolution
│ ├── llm_client.py # LLM abstraction (OpenAI-compatible API)
│ ├── agent.py # ReAct-pattern agent with tool registry
│ └── session.py # Conversation persistence & history
├── tools/
│ ├── file_ops.py # file_read, file_write, file_list, file_search
│ ├── shell.py # shell_exec (run terminal commands)
│ └── web_search.py # web_search (DuckDuckGo, no API key needed)
├── shortcuts/
│ ├── registry.py # Shortcut registration system
│ └── builtins.py # Built-in slash commands
└── utils/
└── display.py # Rich terminal formatting
| Shortcut | Aliases | Description |
|---|---|---|
/help |
/h, /? |
Show available commands |
/clear |
/cls |
Clear conversation history |
/model <name> |
Switch LLM model | |
/system <text> |
View/set system prompt | |
/agent [on/off] |
Toggle tool-use agent mode | |
/tools |
List available tools | |
/config |
/cfg |
Show current configuration |
/save <file> |
Save conversation to JSON | |
/load <file> |
Load conversation from JSON | |
/exit |
/quit, /q |
Exit the CLI |
When agent mode is enabled (/agent on), the LLM can use:
- file_read - Read files
- file_write - Write/create files
- file_list - List directory contents
- file_search - Search with glob patterns
- shell_exec - Run shell commands
- web_search - Search DuckDuckGo
Edit config.yaml or create your own:
llm:
provider: openai
api_key: ${OPENAI_API_KEY} # resolved from environment
model: gpt-4o
base_url: https://api.openai.com/v1
temperature: 0.7
max_tokens: 4096
stream: true
agent:
max_iterations: 10
system_prompt: "You are a helpful AI assistant..."Supports any OpenAI-compatible API (Ollama, LiteLLM, custom endpoints) by changing base_url.
python cli.py -c custom_config.yaml # Custom config file
python cli.py -m gpt-4o-mini # Override model
python cli.py -a # Start with agent mode on
python cli.py -p "Explain Python decorators" # Single prompt, no REPL
python cli.py --no-stream # Disable streaming- Streaming-first: Responses stream token-by-token for a responsive feel
- Tool sandboxing: Agent tools have defined schemas; shell_exec is the only tool with system access
- Pluggable shortcuts: Register new
/commandsvia the ShortcutRegistry - Persistent history: Conversations auto-save to
~/.ai_cli_history.json - Provider agnostic: Any OpenAI-compatible endpoint works (OpenAI, Ollama, vLLM, etc.)