Ask your llm from the command line
Project description
(Still under development)
lask
Ask LLMs right from the terminal.
Supports multiple providers like OpenAI, Anthropic, AWS Bedrock, and Azure OpenAI
Usage
Ensure you have OPENAI_API_KEY in your environment variables or configure it in ~/.lask-config, then you can use lask to send prompts to the LLM.
lask What movie is this quote from\? \"that still only counts as one\"
Features
- Simple command-line interface to send prompts to multiple LLM providers
- Support for OpenAI, Anthropic, AWS Bedrock, and more.
- Customizable models and parameters for each provider
- Minimal dependencies (only requires the
requestslibrary, andboto3for AWS) - Easy installation via pip
- Direct output to your terminal
- Streaming responses for real-time output
Installation
Using pip (recommended)
pip install lask
(For dev, do pip install .)
For a user-specific installation:
pip install --user lask
From source
-
Clone the repository:
git clone https://github.com/Open-Source-Lodge/lask.git
-
Navigate to the directory:
cd lask
-
Install the package:
pip install -e .
Setup
Before using lask, you need to set up API keys for your preferred provider:
-
Get an API key from your chosen provider:
-
Create a configuration file at
~/.lask-configin INI format:[default] provider = openai # Options: openai, anthropic, aws, azure system_prompt = Always answer questions concisely. # Default system prompt for all providers [openai] # OpenAI-specific settings api_key = your-api-key-here model = gpt-4.1 system_prompt = You are a helpful AI assistant. # Overrides default system prompt [anthropic] # Anthropic-specific settings api_key = your-api-key-here model = claude-3-opus-20240229 system_prompt = You are Claude, an AI assistant by Anthropic. [aws] # AWS Bedrock settings api_key = your-api-key-here model_id = anthropic.claude-3-sonnet-20240229-v1:0 region = us-east-1 system_prompt = Respond as a technical consultant. [azure] # Azure OpenAI settings api_key = your-azure-api-key resource_name = your-resource-name deployment_id = your-deployment-id system_prompt = You are an Azure OpenAI assistant.
This INI configuration file allows you to set your preferred provider, API keys, and customize the models and parameters for each provider.
An example configuration file with comments is available in the
examples/example.lask-configfile. -
Alternatively, set the appropriate environment variable:
For OpenAI (default provider):
export OPENAI_API_KEY='your-api-key-here'
For Anthropic:
export ANTHROPIC_API_KEY='your-api-key-here'
For AWS Bedrock: Ensure your AWS credentials are properly configured.
For Azure OpenAI:
export AZURE_OPENAI_API_KEY='your-api-key-here'
To make these permanent, add the export line to your
~/.bashrc,~/.zshrc, or equivalent shell configuration file.Windows users can use
set(CMD) or$env:(PowerShell) instead ofexport.
API Key Issues
If you see an error about the API key:
- Ensure you've configured the API key in the
~/.lask-configfile - Alternatively, double-check that you've correctly set the appropriate environment variable for your chosen provider:
- OpenAI:
OPENAI_API_KEY - Anthropic:
ANTHROPIC_API_KEY - AWS: Check your AWS credentials configuration
- OpenAI:
- Verify your API key is valid and has enough credits
Configuration
You can find a fully commented example configuration file in the examples/example.lask-config directory of this repository. Copy it to your home directory as ~/.lask-config and customize it to your needs.
Selecting a Provider
Set your preferred provider in the [default] section:
[default]
provider = openai # Options: openai, anthropic, aws
Streaming Configuration
By default, responses are streamed in real-time to your terminal. You can disable streaming in your configuration file:
[openai]
streaming = false # Disable streaming for OpenAI
[anthropic]
streaming = false # Disable streaming for Anthropic
When streaming is enabled, you'll see the response appearing in real-time as it's generated. When disabled, you'll get the complete response only after it's fully generated.
System Prompts
You can set system prompts at two levels:
-
Default system prompt for all providers:
[default] system_prompt = Always answer questions concisely.
-
Provider-specific system prompts that override the default:
[openai] system_prompt = You are a helpful AI assistant.
System prompts allow you to set consistent behavior across all your interactions with the LLM. For example, you can use them to:
- Specify a response style: "Always answer as short and concise as possible"
- Set a persona: "You are a helpful assistant specialized in Python programming"
- Request responses in a specific language: "Always respond in Spanish"
Provider-specific Configuration
Each provider has its own section where you can set provider-specific options:
OpenAI
[openai]
api_key = your-openai-api-key
model = gpt-4.1
temperature = 0.7
max_tokens = 2000
streaming = true # Enable streaming (this is the default)
system_prompt = You are a helpful AI assistant. # Provider-specific system prompt
Anthropic
[anthropic]
api_key = your-anthropic-api-key
model = claude-3-opus-20240229
temperature = 0.7
max_tokens = 4096
streaming = true # Enable streaming (this is the default)
system_prompt = You are Claude, an AI assistant by Anthropic. # Provider-specific system prompt
AWS Bedrock
[aws]
model_id = anthropic.claude-3-sonnet-20240229-v1:0
region = us-east-1
temperature = 0.7
max_tokens = 4096
system_prompt = Respond as a technical consultant. # Provider-specific system prompt
Azure OpenAI
[azure]
api_key = your-azure-api-key
resource_name = your-resource-name
deployment_id = your-deployment-id
api_version = 2023-05-15
temperature = 0.7
max_tokens = 2000
system_prompt = You are an Azure OpenAI assistant. # Provider-specific system prompt
Developing
Dependencies
This repo uses uv for running scripts and building the package. uv install instruction
To install the development dependencies, run:
uv sync
Build
To build the package, run:
uv build
Install for development
To install the package in development mode, run:
pip install dist/lask-0.1.0-py3-none-any.whl
or
pip install -e .
With the -e flag, you can edit the source code and see changes immediately without reinstalling.
If you want to use AWS Bedrock, also install boto3:
pip install boto3
(I have not tested aws yet, so please report any issues you find)
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.1.8.tar.gz.
File metadata
- Download URL: lask-0.1.8.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6654b18134093ea1019f43f9c9915cc99ac68d6273e2d87f09396767246ae73
|
|
| MD5 |
660c67dff10219e6be599bf29d6db9c9
|
|
| BLAKE2b-256 |
b805cb7f5a1710a066a0cbeb999eab3404f8f4cf5fa3d38f3fdd8e3ccbe3f560
|
Provenance
The following attestation bundles were made for lask-0.1.8.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.1.8.tar.gz -
Subject digest:
d6654b18134093ea1019f43f9c9915cc99ac68d6273e2d87f09396767246ae73 - Sigstore transparency entry: 253345657
- Sigstore integration time:
-
Permalink:
Open-Source-Lodge/lask@45255b416623fb27c6c0f35a42edc3ebd17bc9d2 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/Open-Source-Lodge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypipublish.yml@45255b416623fb27c6c0f35a42edc3ebd17bc9d2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file lask-0.1.8-py3-none-any.whl.
File metadata
- Download URL: lask-0.1.8-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
624c32939bea6cae1b211c59ce42fce942061296ed3f1b7158d89cf583b47774
|
|
| MD5 |
3fc5b306d4b4d23a0e159950e068e1ab
|
|
| BLAKE2b-256 |
3432d9187bc297a57da9c760f2c38e854da3ae967f7a87ff57f28d545e3947cf
|
Provenance
The following attestation bundles were made for lask-0.1.8-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.1.8-py3-none-any.whl -
Subject digest:
624c32939bea6cae1b211c59ce42fce942061296ed3f1b7158d89cf583b47774 - Sigstore transparency entry: 253345661
- Sigstore integration time:
-
Permalink:
Open-Source-Lodge/lask@45255b416623fb27c6c0f35a42edc3ebd17bc9d2 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/Open-Source-Lodge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypipublish.yml@45255b416623fb27c6c0f35a42edc3ebd17bc9d2 -
Trigger Event:
release
-
Statement type: