Ask your llm from the command line
Project description
lask
Ask LLMs right from the terminal.
Features
- CLI for multiple LLM providers (OpenAI, Anthropic, AWS Bedrock, Azure)
- Customizable models and parameters
- Minimal dependencies (
requests,boto3for AWS) - Streaming responses
- Repl mode for interactive use, with temporary chat history
- Pipe input support
- Smart command mode: describe what you want in plain English and lask translates it into a shell command, with confirmation before execution
Installation
pip install lask
Usage
With OPENAI_API_KEY in your environment or in ~/.lask-config:
lask What movie is this quote from\? \"that still only counts as one\"
Or as a repl:
lask
==== Lask REPL Mode ====
Using provider: openai
Smart command: auto
> What movie is this quote from? "that still only counts as one"
LLM response here...
> When was that movie released?
Smart command mode also works in the REPL. When smart_command is auto or true, the REPL automatically detects command requests and handles them the same way — propose, confirm, execute:
> show disk usage for the current directory
du -sh .
Press Enter to run, or any other key to abort.
> explain what du does
The `du` command estimates file space usage...
REPL commands:
| Command | Description |
|---|---|
!help |
Show available REPL commands |
!clear |
Clear the screen |
!history |
Show prompt history |
!vi |
Switch to Vi editing mode |
!emacs |
Switch to Emacs editing mode |
exit / quit |
Exit the REPL |
Ctrl+C |
Interrupt a running command or response |
Ctrl+D |
Exit the REPL |
Or via pipe:
echo "What movie is this quote from? \"that still only counts as one\"" | lask
Smart Command Mode
By default, lask automatically detects if your prompt is asking for a shell command. When it is, it translates your natural language into a command, shows it to you, and waits for confirmation:
$ lask show diff between current branch and main
git diff HEAD..main
Press Enter to run, or any other key to abort.
Press Enter to execute, or any other key to abort. The executed command is added to your shell history, so you can press ↑ to recall and re-run or edit it.
The behaviour is controlled by the smart_command setting (default: auto):
| Value | Behaviour |
|---|---|
auto |
LLM decides if the prompt is a command request or a general question |
true |
Always treat the prompt as a command request |
false |
Never use smart command mode, always answer normally |
In REPL mode, smart command keeps a rolling history of your interactions so you
can reference them naturally ("do the same but with -v", "now compress that",
etc.). Two settings control what is included:
| Setting | Default | Description |
|---|---|---|
smart_context_commands |
true |
Include previous prompts and commands in context |
smart_context_output |
false |
Also capture and include command output |
Setup
-
Get API keys from your provider:
-
Create
~/.lask-config:[default] provider = openai # openai, anthropic, aws, azure system_prompt = Always answer questions concisely. [openai] api_key = your-api-key-here model = gpt-4.1 [anthropic] api_key = your-api-key-here model = claude-3-opus-20240229 [aws] model_id = anthropic.claude-3-sonnet-20240229-v1:0 region = us-east-1 [azure] api_key = your-azure-api-key resource_name = your-resource-name deployment_id = your-deployment-id
See
examples/example.lask-configfor a full example. -
Or use environment variables:
export OPENAI_API_KEY='your-api-key-here' export ANTHROPIC_API_KEY='your-api-key-here' # AWS uses standard AWS credentials export AZURE_OPENAI_API_KEY='your-api-key-here'
Configuration Options
Provider Selection
[default]
provider = openai # openai, anthropic, aws, azure
Streaming
[openai]
streaming = false # Disable streaming (true by default)
System Prompts
[default]
system_prompt = Always answer questions concisely.
[openai]
system_prompt = You are a helpful AI assistant. # Provider-specific
Smart Command
[default]
smart_command = auto # auto, true, or false
smart_context_commands = true # include command history in context
smart_context_output = false # include command output in context
Provider-Specific Settings
Each provider supports model, temperature, max_tokens, and other parameters.
See examples/example.lask-config for all options.
Development
This repo uses uv:
# Install dependencies
uv sync
# Build
uv build
# Install for development
pip install -e .
# For AWS Bedrock
pip install boto3
License
GNU General Public License v3.0 (GPL-3.0)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lask-0.3.0.tar.gz.
File metadata
- Download URL: lask-0.3.0.tar.gz
- Upload date:
- Size: 35.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef7f80a5af0e16bbedf089f7e8a1e7d3a51746c808e45193e338b76111fbeb51
|
|
| MD5 |
95af9bd73fdd7112dfee8754e3f0c9fe
|
|
| BLAKE2b-256 |
28d622c40705c11f88499543643f70618664e12b2841ee146870c4a14c357465
|
Provenance
The following attestation bundles were made for lask-0.3.0.tar.gz:
Publisher:
pypipublish.yml on Open-Source-Lodge/lask
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lask-0.3.0.tar.gz -
Subject digest:
ef7f80a5af0e16bbedf089f7e8a1e7d3a51746c808e45193e338b76111fbeb51 - Sigstore transparency entry: 1056985264
- Sigstore integration time:
-
Permalink:
Open-Source-Lodge/lask@205a8d717db4c5f2bbdd716cb13681509e14250a -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Open-Source-Lodge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypipublish.yml@205a8d717db4c5f2bbdd716cb13681509e14250a -
Trigger Event:
release
-
Statement type:
File details
Details for the file lask-0.3.0-py3-none-any.whl.
File metadata
- Download URL: lask-0.3.0-py3-none-any.whl
- Upload date:
- Size: 37.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4afe968a9681702255434eb1fb19431dc9c0e553eb4a3ec74489aab8b8057805
|
|
| MD5 |
7003fc6a94b342ae644166a5c518b000
|
|
| BLAKE2b-256 |
836a8dd467b2ab448b800114a4027e1008e63a798548d7618f3029533fe1174e
|
Provenance
The following attestation bundles were made for lask-0.3.0-py3-none-any.whl:
Publisher:
pypipublish.yml on Open-Source-Lodge/lask
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lask-0.3.0-py3-none-any.whl -
Subject digest:
4afe968a9681702255434eb1fb19431dc9c0e553eb4a3ec74489aab8b8057805 - Sigstore transparency entry: 1056985279
- Sigstore integration time:
-
Permalink:
Open-Source-Lodge/lask@205a8d717db4c5f2bbdd716cb13681509e14250a -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Open-Source-Lodge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypipublish.yml@205a8d717db4c5f2bbdd716cb13681509e14250a -
Trigger Event:
release
-
Statement type: