askllm-cli 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- askllm_cli-0.1.2/PKG-INFO +261 -0
- askllm_cli-0.1.2/README.md +234 -0
- {askllm_cli-0.1.0 → askllm_cli-0.1.2}/pyproject.toml +5 -2
- askllm_cli-0.1.2/src/askllm/__init__.py +12 -0
- askllm_cli-0.1.2/src/askllm/cli.py +1094 -0
- askllm_cli-0.1.2/src/askllm/executor.py +85 -0
- askllm_cli-0.1.2/src/askllm/web.py +256 -0
- askllm_cli-0.1.2/src/askllm_cli.egg-info/PKG-INFO +261 -0
- {askllm_cli-0.1.0 → askllm_cli-0.1.2}/src/askllm_cli.egg-info/SOURCES.txt +4 -1
- askllm_cli-0.1.2/src/askllm_cli.egg-info/requires.txt +4 -0
- askllm_cli-0.1.2/tests/test_askllm.py +902 -0
- askllm_cli-0.1.2/tests/test_web.py +82 -0
- askllm_cli-0.1.0/PKG-INFO +0 -210
- askllm_cli-0.1.0/README.md +0 -185
- askllm_cli-0.1.0/src/askllm/__init__.py +0 -10
- askllm_cli-0.1.0/src/askllm/cli.py +0 -431
- askllm_cli-0.1.0/src/askllm_cli.egg-info/PKG-INFO +0 -210
- askllm_cli-0.1.0/src/askllm_cli.egg-info/requires.txt +0 -3
- askllm_cli-0.1.0/tests/test_askllm.py +0 -99
- {askllm_cli-0.1.0 → askllm_cli-0.1.2}/setup.cfg +0 -0
- {askllm_cli-0.1.0 → askllm_cli-0.1.2}/src/askllm/__main__.py +0 -0
- {askllm_cli-0.1.0 → askllm_cli-0.1.2}/src/askllm_cli.egg-info/dependency_links.txt +0 -0
- {askllm_cli-0.1.0 → askllm_cli-0.1.2}/src/askllm_cli.egg-info/entry_points.txt +0 -0
- {askllm_cli-0.1.0 → askllm_cli-0.1.2}/src/askllm_cli.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: askllm-cli
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Lightweight OpenAI-compatible terminal REPL
|
|
5
|
+
Author: AskLLM
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: llm,repl,cli,openai,terminal,ai
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Communications :: Chat
|
|
21
|
+
Classifier: Topic :: Utilities
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
Requires-Dist: prompt_toolkit>=3.0.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
27
|
+
|
|
28
|
+
# AskLLM
|
|
29
|
+
|
|
30
|
+
A lightweight, cross-platform Python REPL for chatting with LLMs via any OpenAI-compatible API, powered by `prompt_toolkit`.
|
|
31
|
+
|
|
32
|
+
Designed to be installed via `pip install askllm-cli` (or `pipx install askllm-cli`), and developed using **Podman** with `python:3.12-slim` (or run directly with Python 3).
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- **Python Code Execution Tool:** Exposes a stateful Python execution tool to the LLM via OpenAI-compatible tool/function calling (`-x` / `--code-execution`), allowing models to execute Python code, verify calculations, inspect data, and iterate.
|
|
39
|
+
- **Modern, Cross-Platform REPL (`prompt_toolkit`):** Robust, native interactive terminal experience across Linux, macOS, and Windows.
|
|
40
|
+
- **Slash Command Auto-Completion:** Interactive auto-completion for slash commands (`/help`, `/model`, `/tools`, `/clear`, `/history`, etc.).
|
|
41
|
+
- **Minimal Dependencies:** Uses standard library for networking (`urllib.request`) and JSON, relying solely on `prompt_toolkit` for the terminal UI.
|
|
42
|
+
- **Standard Python Package:** Modern PEP 517/621 packaging (`pyproject.toml`) published as `askllm-cli` on PyPI.
|
|
43
|
+
- **Podman Development Ready:** Built-in development workflow using `python:3.12-slim` (`./dev.sh`).
|
|
44
|
+
- **Environment Variable Auto-Detection:** Automatically picks up standard OpenAI / Azure / local LLM variables.
|
|
45
|
+
- **Streaming Responses:** Real-time token streaming via Server-Sent Events (SSE).
|
|
46
|
+
- **Graceful Signal Handling:**
|
|
47
|
+
- `Ctrl+C` or `Ctrl+D` at the beginning of the line exits the REPL.
|
|
48
|
+
- `Ctrl+C` with text in the buffer cancels the line.
|
|
49
|
+
- `Ctrl+C` during response streaming halts generation cleanly without exiting.
|
|
50
|
+
- **Multi-Turn Chat History:** Maintains conversation context across turns within the session.
|
|
51
|
+
- **Automatic `/v1/responses` Detection & Fallback:** Automatically probes and switches to the newer `/v1/responses` API when supported, seamlessly falling back to `/v1/chat/completions` if the endpoint returns HTTP 404/405/501 (such as on Ollama, LM Studio, or vLLM). Can also be configured via `--api-mode` (`auto`, `chat`, `responses`).
|
|
52
|
+
- **Persistent Input History:** History saved across runs in `$HOME/.askllm_history` or custom file specified via `-H` / `--history-file` or `ASKLLM_HISTORY_FILE` (safely falling back to in-memory history if opening fails).
|
|
53
|
+
- **Multiline Input Support:**
|
|
54
|
+
- Triple quotes `"""` ... `"""`
|
|
55
|
+
- Trailing backslash `\`
|
|
56
|
+
- `/paste` command
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Development with Podman (`python:3.12-slim`)
|
|
61
|
+
|
|
62
|
+
No local Python installation or host dependencies are required. A complete development environment is provided via Podman:
|
|
63
|
+
|
|
64
|
+
### 1. Interactive Development Shell
|
|
65
|
+
Drop into an interactive bash shell running inside `python:3.12-slim` with AskLLM installed in editable mode (`pip install -e .`):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
./dev.sh
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Inside the shell:
|
|
72
|
+
```bash
|
|
73
|
+
# Run AskLLM directly
|
|
74
|
+
askllm --help
|
|
75
|
+
|
|
76
|
+
# Run tests
|
|
77
|
+
pytest
|
|
78
|
+
|
|
79
|
+
# Test interactive python
|
|
80
|
+
python3 -c "import askllm; print(askllm.__version__)"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Any changes made to files in `src/askllm` on your host are immediately reflected inside the container!
|
|
84
|
+
|
|
85
|
+
### 2. Run Tests in Podman
|
|
86
|
+
Run the test suite inside the `python:3.12-slim` container:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
./dev.sh test
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 3. Run AskLLM via Podman
|
|
93
|
+
Run AskLLM using Podman directly from the host:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
./askllm
|
|
97
|
+
```
|
|
98
|
+
or with arguments:
|
|
99
|
+
```bash
|
|
100
|
+
./askllm --model llama3.2 --endpoint http://localhost:11434/v1
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 4. Dev Container (VS Code / IDEs)
|
|
104
|
+
Open this repository in VS Code or any editor supporting Dev Containers to develop seamlessly inside the `python:3.12-slim` container.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Installation via `pip` / `pipx`
|
|
109
|
+
|
|
110
|
+
Install AskLLM from PyPI:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Recommended for CLI tools
|
|
114
|
+
pipx install askllm-cli
|
|
115
|
+
|
|
116
|
+
# Or via standard pip
|
|
117
|
+
pip install askllm-cli
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Or install locally in editable mode in any Python virtual environment:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Editable install
|
|
124
|
+
pip install -e .
|
|
125
|
+
|
|
126
|
+
# With dev dependencies (pytest)
|
|
127
|
+
pip install -e ".[dev]"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Once installed, the `askllm` command is directly available:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
askllm --help
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Or run as a module:
|
|
137
|
+
```bash
|
|
138
|
+
python3 -m askllm
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Production Container
|
|
144
|
+
|
|
145
|
+
Build and run the production image using Podman:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
podman build -t askllm .
|
|
149
|
+
podman run --rm -it --network=host -e OPENAI_API_KEY askllm
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Environment Variables
|
|
155
|
+
|
|
156
|
+
AskLLM automatically checks for standard OpenAI variables, all of which can be overridden by their `ASKLLM_` counterparts:
|
|
157
|
+
|
|
158
|
+
| Variable (AskLLM) | Fallback / Alias (OpenAI) | Description | Default |
|
|
159
|
+
| :--- | :--- | :--- | :--- |
|
|
160
|
+
| `ASKLLM_API_KEY` | `OPENAI_API_KEY` | Your API key | *(empty / none)* |
|
|
161
|
+
| `ASKLLM_BASE_URL` / `ASKLLM_ENDPOINT` / `ASKLLM_API_BASE` | `OPENAI_BASE_URL` / `OPENAI_ENDPOINT` / `OPENAI_API_BASE` | API base URL or chat completions endpoint | `https://api.openai.com/v1` |
|
|
162
|
+
| `ASKLLM_MODEL` / `ASKLLM_MODEL_NAME` | `OPENAI_MODEL` / `OPENAI_MODEL_NAME` / `MODEL` | Default model name | `gpt-4o-mini` |
|
|
163
|
+
| `ASKLLM_SYSTEM_PROMPT` | `OPENAI_SYSTEM_PROMPT` | Custom system prompt | `"You are a helpful assistant."` |
|
|
164
|
+
| `ASKLLM_CODE_EXECUTION` | `OPENAI_CODE_EXECUTION` | Enable Python code execution tool | `false` |
|
|
165
|
+
| `ASKLLM_HISTORY_FILE` | `OPENAI_HISTORY_FILE` | Path to persistent REPL history file | `~/.askllm_history` |
|
|
166
|
+
| `ASKLLM_API_MODE` | `OPENAI_API_MODE` | API mode (`auto`, `chat`, `responses`) | `auto` |
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Using with Local LLMs (Ollama, LM Studio, vLLM, etc.)
|
|
171
|
+
|
|
172
|
+
Because `./askllm` and `./dev.sh` use host networking (`--network=host`), you can connect directly to local servers:
|
|
173
|
+
|
|
174
|
+
#### Ollama:
|
|
175
|
+
```bash
|
|
176
|
+
ASKLLM_ENDPOINT="http://localhost:11434/v1" ASKLLM_MODEL="llama3.2" ./askllm
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### LM Studio / LocalAI / vLLM:
|
|
180
|
+
```bash
|
|
181
|
+
ASKLLM_ENDPOINT="http://localhost:1234/v1" ASKLLM_MODEL="local-model" ./askllm
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## REPL Slash Commands
|
|
187
|
+
|
|
188
|
+
Inside the REPL, type `/` to access built-in commands:
|
|
189
|
+
|
|
190
|
+
| Command | Action |
|
|
191
|
+
| :--- | :--- |
|
|
192
|
+
| `/help` | Display command help and tips |
|
|
193
|
+
| `/clear` or `/reset` | Clear session conversation history and code execution namespace |
|
|
194
|
+
| `/model [name]` | Show or dynamically switch model |
|
|
195
|
+
| `/endpoint` | Show currently configured endpoint URL and active API mode |
|
|
196
|
+
| `/system [prompt]` | Show or update the system prompt |
|
|
197
|
+
| `/tools [on\|off]` | Show or toggle Python code execution tool |
|
|
198
|
+
| `/history` | Show full message history for the session |
|
|
199
|
+
| `/paste` | Enter multiline paste mode |
|
|
200
|
+
| `/exit` or `/quit` | Exit the REPL |
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Declarative Web Request Tools
|
|
205
|
+
|
|
206
|
+
Each `-w`/`--web-request` value creates a separate model tool. A request has a
|
|
207
|
+
name, description, defaults, and `params`. Each parameter supplies the model
|
|
208
|
+
facing name and description, a JSON Schema snippet, and a dotted (or JSON
|
|
209
|
+
Pointer) path into `defaults` to replace:
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"name": "lookup",
|
|
214
|
+
"description": "Look up a value.",
|
|
215
|
+
"defaults": {
|
|
216
|
+
"uri": "https://example.test/lookup",
|
|
217
|
+
"query": {"page": 1},
|
|
218
|
+
"method": "GET"
|
|
219
|
+
},
|
|
220
|
+
"params": [
|
|
221
|
+
{
|
|
222
|
+
"name": "page",
|
|
223
|
+
"description": "Result page number.",
|
|
224
|
+
"schema": {"type": "integer", "minimum": 1},
|
|
225
|
+
"path": "query.page"
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
The tool exposed to the model contains only the declared parameters; request
|
|
232
|
+
fields not declared in `params` remain fixed at their defaults. `-w` may be
|
|
233
|
+
repeated, or its value may be a JSON array of request definitions.
|
|
234
|
+
|
|
235
|
+
## Command-Line Options
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
usage: askllm [-h] [-v] [-m MODEL] [-e ENDPOINT] [-x] [-k API_KEY] [-s SYSTEM]
|
|
239
|
+
[-H HISTORY_FILE] [-w JSON] [--api-mode {auto,chat,responses}]
|
|
240
|
+
|
|
241
|
+
options:
|
|
242
|
+
-h, --help show this help message and exit
|
|
243
|
+
-v, --version show program's version number and exit
|
|
244
|
+
-m MODEL, --model MODEL
|
|
245
|
+
LLM model name (env: ASKLLM_MODEL, OPENAI_MODEL, default: gpt-4o-mini)
|
|
246
|
+
-e ENDPOINT, --endpoint ENDPOINT
|
|
247
|
+
API Base URL / Endpoint (env: ASKLLM_BASE_URL, OPENAI_BASE_URL, OPENAI_ENDPOINT, OPENAI_API_BASE)
|
|
248
|
+
-x, --code-execution
|
|
249
|
+
Enable Python code execution tool for the LLM (env: ASKLLM_CODE_EXECUTION, OPENAI_CODE_EXECUTION)
|
|
250
|
+
-k API_KEY, --api-key API_KEY
|
|
251
|
+
API Key (env: ASKLLM_API_KEY, OPENAI_API_KEY)
|
|
252
|
+
-s SYSTEM, --system SYSTEM
|
|
253
|
+
System prompt (env: ASKLLM_SYSTEM_PROMPT, OPENAI_SYSTEM_PROMPT)
|
|
254
|
+
-H HISTORY_FILE, --history-file HISTORY_FILE
|
|
255
|
+
Path to history file (env: ASKLLM_HISTORY_FILE, OPENAI_HISTORY_FILE, default: ~/.askllm_history)
|
|
256
|
+
-w JSON, --web-request JSON
|
|
257
|
+
Expose a declarative web request tool; repeat the option or provide a JSON array
|
|
258
|
+
--api-mode {auto,chat,responses}
|
|
259
|
+
API mode: auto (probe /v1/responses then fallback to /v1/chat/completions),
|
|
260
|
+
chat, or responses (env: ASKLLM_API_MODE, OPENAI_API_MODE, default: auto)
|
|
261
|
+
```
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# AskLLM
|
|
2
|
+
|
|
3
|
+
A lightweight, cross-platform Python REPL for chatting with LLMs via any OpenAI-compatible API, powered by `prompt_toolkit`.
|
|
4
|
+
|
|
5
|
+
Designed to be installed via `pip install askllm-cli` (or `pipx install askllm-cli`), and developed using **Podman** with `python:3.12-slim` (or run directly with Python 3).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Python Code Execution Tool:** Exposes a stateful Python execution tool to the LLM via OpenAI-compatible tool/function calling (`-x` / `--code-execution`), allowing models to execute Python code, verify calculations, inspect data, and iterate.
|
|
12
|
+
- **Modern, Cross-Platform REPL (`prompt_toolkit`):** Robust, native interactive terminal experience across Linux, macOS, and Windows.
|
|
13
|
+
- **Slash Command Auto-Completion:** Interactive auto-completion for slash commands (`/help`, `/model`, `/tools`, `/clear`, `/history`, etc.).
|
|
14
|
+
- **Minimal Dependencies:** Uses standard library for networking (`urllib.request`) and JSON, relying solely on `prompt_toolkit` for the terminal UI.
|
|
15
|
+
- **Standard Python Package:** Modern PEP 517/621 packaging (`pyproject.toml`) published as `askllm-cli` on PyPI.
|
|
16
|
+
- **Podman Development Ready:** Built-in development workflow using `python:3.12-slim` (`./dev.sh`).
|
|
17
|
+
- **Environment Variable Auto-Detection:** Automatically picks up standard OpenAI / Azure / local LLM variables.
|
|
18
|
+
- **Streaming Responses:** Real-time token streaming via Server-Sent Events (SSE).
|
|
19
|
+
- **Graceful Signal Handling:**
|
|
20
|
+
- `Ctrl+C` or `Ctrl+D` at the beginning of the line exits the REPL.
|
|
21
|
+
- `Ctrl+C` with text in the buffer cancels the line.
|
|
22
|
+
- `Ctrl+C` during response streaming halts generation cleanly without exiting.
|
|
23
|
+
- **Multi-Turn Chat History:** Maintains conversation context across turns within the session.
|
|
24
|
+
- **Automatic `/v1/responses` Detection & Fallback:** Automatically probes and switches to the newer `/v1/responses` API when supported, seamlessly falling back to `/v1/chat/completions` if the endpoint returns HTTP 404/405/501 (such as on Ollama, LM Studio, or vLLM). Can also be configured via `--api-mode` (`auto`, `chat`, `responses`).
|
|
25
|
+
- **Persistent Input History:** History saved across runs in `$HOME/.askllm_history` or custom file specified via `-H` / `--history-file` or `ASKLLM_HISTORY_FILE` (safely falling back to in-memory history if opening fails).
|
|
26
|
+
- **Multiline Input Support:**
|
|
27
|
+
- Triple quotes `"""` ... `"""`
|
|
28
|
+
- Trailing backslash `\`
|
|
29
|
+
- `/paste` command
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Development with Podman (`python:3.12-slim`)
|
|
34
|
+
|
|
35
|
+
No local Python installation or host dependencies are required. A complete development environment is provided via Podman:
|
|
36
|
+
|
|
37
|
+
### 1. Interactive Development Shell
|
|
38
|
+
Drop into an interactive bash shell running inside `python:3.12-slim` with AskLLM installed in editable mode (`pip install -e .`):
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
./dev.sh
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Inside the shell:
|
|
45
|
+
```bash
|
|
46
|
+
# Run AskLLM directly
|
|
47
|
+
askllm --help
|
|
48
|
+
|
|
49
|
+
# Run tests
|
|
50
|
+
pytest
|
|
51
|
+
|
|
52
|
+
# Test interactive python
|
|
53
|
+
python3 -c "import askllm; print(askllm.__version__)"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Any changes made to files in `src/askllm` on your host are immediately reflected inside the container!
|
|
57
|
+
|
|
58
|
+
### 2. Run Tests in Podman
|
|
59
|
+
Run the test suite inside the `python:3.12-slim` container:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
./dev.sh test
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 3. Run AskLLM via Podman
|
|
66
|
+
Run AskLLM using Podman directly from the host:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
./askllm
|
|
70
|
+
```
|
|
71
|
+
or with arguments:
|
|
72
|
+
```bash
|
|
73
|
+
./askllm --model llama3.2 --endpoint http://localhost:11434/v1
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 4. Dev Container (VS Code / IDEs)
|
|
77
|
+
Open this repository in VS Code or any editor supporting Dev Containers to develop seamlessly inside the `python:3.12-slim` container.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Installation via `pip` / `pipx`
|
|
82
|
+
|
|
83
|
+
Install AskLLM from PyPI:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Recommended for CLI tools
|
|
87
|
+
pipx install askllm-cli
|
|
88
|
+
|
|
89
|
+
# Or via standard pip
|
|
90
|
+
pip install askllm-cli
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Or install locally in editable mode in any Python virtual environment:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Editable install
|
|
97
|
+
pip install -e .
|
|
98
|
+
|
|
99
|
+
# With dev dependencies (pytest)
|
|
100
|
+
pip install -e ".[dev]"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Once installed, the `askllm` command is directly available:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
askllm --help
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Or run as a module:
|
|
110
|
+
```bash
|
|
111
|
+
python3 -m askllm
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Production Container
|
|
117
|
+
|
|
118
|
+
Build and run the production image using Podman:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
podman build -t askllm .
|
|
122
|
+
podman run --rm -it --network=host -e OPENAI_API_KEY askllm
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Environment Variables
|
|
128
|
+
|
|
129
|
+
AskLLM automatically checks for standard OpenAI variables, all of which can be overridden by their `ASKLLM_` counterparts:
|
|
130
|
+
|
|
131
|
+
| Variable (AskLLM) | Fallback / Alias (OpenAI) | Description | Default |
|
|
132
|
+
| :--- | :--- | :--- | :--- |
|
|
133
|
+
| `ASKLLM_API_KEY` | `OPENAI_API_KEY` | Your API key | *(empty / none)* |
|
|
134
|
+
| `ASKLLM_BASE_URL` / `ASKLLM_ENDPOINT` / `ASKLLM_API_BASE` | `OPENAI_BASE_URL` / `OPENAI_ENDPOINT` / `OPENAI_API_BASE` | API base URL or chat completions endpoint | `https://api.openai.com/v1` |
|
|
135
|
+
| `ASKLLM_MODEL` / `ASKLLM_MODEL_NAME` | `OPENAI_MODEL` / `OPENAI_MODEL_NAME` / `MODEL` | Default model name | `gpt-4o-mini` |
|
|
136
|
+
| `ASKLLM_SYSTEM_PROMPT` | `OPENAI_SYSTEM_PROMPT` | Custom system prompt | `"You are a helpful assistant."` |
|
|
137
|
+
| `ASKLLM_CODE_EXECUTION` | `OPENAI_CODE_EXECUTION` | Enable Python code execution tool | `false` |
|
|
138
|
+
| `ASKLLM_HISTORY_FILE` | `OPENAI_HISTORY_FILE` | Path to persistent REPL history file | `~/.askllm_history` |
|
|
139
|
+
| `ASKLLM_API_MODE` | `OPENAI_API_MODE` | API mode (`auto`, `chat`, `responses`) | `auto` |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Using with Local LLMs (Ollama, LM Studio, vLLM, etc.)
|
|
144
|
+
|
|
145
|
+
Because `./askllm` and `./dev.sh` use host networking (`--network=host`), you can connect directly to local servers:
|
|
146
|
+
|
|
147
|
+
#### Ollama:
|
|
148
|
+
```bash
|
|
149
|
+
ASKLLM_ENDPOINT="http://localhost:11434/v1" ASKLLM_MODEL="llama3.2" ./askllm
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### LM Studio / LocalAI / vLLM:
|
|
153
|
+
```bash
|
|
154
|
+
ASKLLM_ENDPOINT="http://localhost:1234/v1" ASKLLM_MODEL="local-model" ./askllm
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## REPL Slash Commands
|
|
160
|
+
|
|
161
|
+
Inside the REPL, type `/` to access built-in commands:
|
|
162
|
+
|
|
163
|
+
| Command | Action |
|
|
164
|
+
| :--- | :--- |
|
|
165
|
+
| `/help` | Display command help and tips |
|
|
166
|
+
| `/clear` or `/reset` | Clear session conversation history and code execution namespace |
|
|
167
|
+
| `/model [name]` | Show or dynamically switch model |
|
|
168
|
+
| `/endpoint` | Show currently configured endpoint URL and active API mode |
|
|
169
|
+
| `/system [prompt]` | Show or update the system prompt |
|
|
170
|
+
| `/tools [on\|off]` | Show or toggle Python code execution tool |
|
|
171
|
+
| `/history` | Show full message history for the session |
|
|
172
|
+
| `/paste` | Enter multiline paste mode |
|
|
173
|
+
| `/exit` or `/quit` | Exit the REPL |
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Declarative Web Request Tools
|
|
178
|
+
|
|
179
|
+
Each `-w`/`--web-request` value creates a separate model tool. A request has a
|
|
180
|
+
name, description, defaults, and `params`. Each parameter supplies the model
|
|
181
|
+
facing name and description, a JSON Schema snippet, and a dotted (or JSON
|
|
182
|
+
Pointer) path into `defaults` to replace:
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"name": "lookup",
|
|
187
|
+
"description": "Look up a value.",
|
|
188
|
+
"defaults": {
|
|
189
|
+
"uri": "https://example.test/lookup",
|
|
190
|
+
"query": {"page": 1},
|
|
191
|
+
"method": "GET"
|
|
192
|
+
},
|
|
193
|
+
"params": [
|
|
194
|
+
{
|
|
195
|
+
"name": "page",
|
|
196
|
+
"description": "Result page number.",
|
|
197
|
+
"schema": {"type": "integer", "minimum": 1},
|
|
198
|
+
"path": "query.page"
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
The tool exposed to the model contains only the declared parameters; request
|
|
205
|
+
fields not declared in `params` remain fixed at their defaults. `-w` may be
|
|
206
|
+
repeated, or its value may be a JSON array of request definitions.
|
|
207
|
+
|
|
208
|
+
## Command-Line Options
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
usage: askllm [-h] [-v] [-m MODEL] [-e ENDPOINT] [-x] [-k API_KEY] [-s SYSTEM]
|
|
212
|
+
[-H HISTORY_FILE] [-w JSON] [--api-mode {auto,chat,responses}]
|
|
213
|
+
|
|
214
|
+
options:
|
|
215
|
+
-h, --help show this help message and exit
|
|
216
|
+
-v, --version show program's version number and exit
|
|
217
|
+
-m MODEL, --model MODEL
|
|
218
|
+
LLM model name (env: ASKLLM_MODEL, OPENAI_MODEL, default: gpt-4o-mini)
|
|
219
|
+
-e ENDPOINT, --endpoint ENDPOINT
|
|
220
|
+
API Base URL / Endpoint (env: ASKLLM_BASE_URL, OPENAI_BASE_URL, OPENAI_ENDPOINT, OPENAI_API_BASE)
|
|
221
|
+
-x, --code-execution
|
|
222
|
+
Enable Python code execution tool for the LLM (env: ASKLLM_CODE_EXECUTION, OPENAI_CODE_EXECUTION)
|
|
223
|
+
-k API_KEY, --api-key API_KEY
|
|
224
|
+
API Key (env: ASKLLM_API_KEY, OPENAI_API_KEY)
|
|
225
|
+
-s SYSTEM, --system SYSTEM
|
|
226
|
+
System prompt (env: ASKLLM_SYSTEM_PROMPT, OPENAI_SYSTEM_PROMPT)
|
|
227
|
+
-H HISTORY_FILE, --history-file HISTORY_FILE
|
|
228
|
+
Path to history file (env: ASKLLM_HISTORY_FILE, OPENAI_HISTORY_FILE, default: ~/.askllm_history)
|
|
229
|
+
-w JSON, --web-request JSON
|
|
230
|
+
Expose a declarative web request tool; repeat the option or provide a JSON array
|
|
231
|
+
--api-mode {auto,chat,responses}
|
|
232
|
+
API mode: auto (probe /v1/responses then fallback to /v1/chat/completions),
|
|
233
|
+
chat, or responses (env: ASKLLM_API_MODE, OPENAI_API_MODE, default: auto)
|
|
234
|
+
```
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "askllm-cli"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
description = "Lightweight OpenAI-compatible terminal REPL"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -18,6 +18,7 @@ classifiers = [
|
|
|
18
18
|
"Environment :: Console",
|
|
19
19
|
"Intended Audience :: Developers",
|
|
20
20
|
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
21
22
|
"Programming Language :: Python :: 3",
|
|
22
23
|
"Programming Language :: Python :: 3.8",
|
|
23
24
|
"Programming Language :: Python :: 3.9",
|
|
@@ -28,7 +29,9 @@ classifiers = [
|
|
|
28
29
|
"Topic :: Communications :: Chat",
|
|
29
30
|
"Topic :: Utilities",
|
|
30
31
|
]
|
|
31
|
-
dependencies = [
|
|
32
|
+
dependencies = [
|
|
33
|
+
"prompt_toolkit>=3.0.0",
|
|
34
|
+
]
|
|
32
35
|
|
|
33
36
|
[project.optional-dependencies]
|
|
34
37
|
dev = [
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AskLLM - A lightweight Python REPL for asking LLMs (OpenAI-compatible endpoints).
|
|
3
|
+
Powered by prompt_toolkit for a modern, cross-platform interactive terminal UX.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = "0.1.2"
|
|
7
|
+
|
|
8
|
+
from askllm.cli import LLMClient, REPL, main
|
|
9
|
+
from askllm.executor import PythonExecutor, PYTHON_TOOL
|
|
10
|
+
|
|
11
|
+
__all__ = ["LLMClient", "REPL", "main", "PythonExecutor", "PYTHON_TOOL", "__version__"]
|
|
12
|
+
|