askllm-cli 0.1.0__tar.gz → 0.1.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: askllm-cli
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Lightweight OpenAI-compatible terminal REPL
5
5
  Author: AskLLM
6
6
  License: MIT
@@ -9,6 +9,7 @@ Classifier: Development Status :: 4 - Beta
9
9
  Classifier: Environment :: Console
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
12
13
  Classifier: Programming Language :: Python :: 3
13
14
  Classifier: Programming Language :: Python :: 3.8
14
15
  Classifier: Programming Language :: Python :: 3.9
@@ -20,12 +21,13 @@ Classifier: Topic :: Communications :: Chat
20
21
  Classifier: Topic :: Utilities
21
22
  Requires-Python: >=3.8
22
23
  Description-Content-Type: text/markdown
24
+ Requires-Dist: prompt_toolkit>=3.0.0
23
25
  Provides-Extra: dev
24
26
  Requires-Dist: pytest>=7.0; extra == "dev"
25
27
 
26
28
  # AskLLM
27
29
 
28
- A lightweight, zero-dependency Python REPL for chatting with LLMs via any OpenAI-compatible API.
30
+ A lightweight, cross-platform Python REPL for chatting with LLMs via any OpenAI-compatible API, powered by `prompt_toolkit`.
29
31
 
30
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).
31
33
 
@@ -33,7 +35,10 @@ Designed to be installed via `pip install askllm-cli` (or `pipx install askllm-c
33
35
 
34
36
  ## Features
35
37
 
36
- - **Zero Third-Party Runtime Dependencies:** Uses standard library only (`urllib.request`, `json`, `readline`).
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.
37
42
  - **Standard Python Package:** Modern PEP 517/621 packaging (`pyproject.toml`) published as `askllm-cli` on PyPI.
38
43
  - **Podman Development Ready:** Built-in development workflow using `python:3.12-slim` (`./dev.sh`).
39
44
  - **Environment Variable Auto-Detection:** Automatically picks up standard OpenAI / Azure / local LLM variables.
@@ -43,7 +48,8 @@ Designed to be installed via `pip install askllm-cli` (or `pipx install askllm-c
43
48
  - `Ctrl+C` with text in the buffer cancels the line.
44
49
  - `Ctrl+C` during response streaming halts generation cleanly without exiting.
45
50
  - **Multi-Turn Chat History:** Maintains conversation context across turns within the session.
46
- - **Persistent Input History:** Readline history saved across runs in `~/.askllm_history`.
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).
47
53
  - **Multiline Input Support:**
48
54
  - Triple quotes `"""` ... `"""`
49
55
  - Trailing backslash `\`
@@ -147,14 +153,17 @@ podman run --rm -it --network=host -e OPENAI_API_KEY askllm
147
153
 
148
154
  ## Environment Variables
149
155
 
150
- AskLLM automatically checks for these environment variables:
156
+ AskLLM automatically checks for standard OpenAI variables, all of which can be overridden by their `ASKLLM_` counterparts:
151
157
 
152
- | Variable | Description | Default |
153
- | :--- | :--- | :--- |
154
- | `OPENAI_API_KEY` | Your API key | *(empty / none)* |
155
- | `OPENAI_ENDPOINT` or `OPENAI_BASE_URL` or `OPENAI_API_BASE` | API base URL or chat endpoint | `https://api.openai.com/v1` |
156
- | `OPENAI_MODEL` | Default model name | `gpt-4o-mini` |
157
- | `OPENAI_SYSTEM_PROMPT` | Custom system prompt | `"You are a helpful assistant."` |
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` |
158
167
 
159
168
  ---
160
169
 
@@ -164,12 +173,12 @@ Because `./askllm` and `./dev.sh` use host networking (`--network=host`), you ca
164
173
 
165
174
  #### Ollama:
166
175
  ```bash
167
- OPENAI_ENDPOINT="http://localhost:11434/v1" OPENAI_MODEL="llama3.2" ./askllm
176
+ ASKLLM_ENDPOINT="http://localhost:11434/v1" ASKLLM_MODEL="llama3.2" ./askllm
168
177
  ```
169
178
 
170
179
  #### LM Studio / LocalAI / vLLM:
171
180
  ```bash
172
- OPENAI_ENDPOINT="http://localhost:1234/v1" OPENAI_MODEL="local-model" ./askllm
181
+ ASKLLM_ENDPOINT="http://localhost:1234/v1" ASKLLM_MODEL="local-model" ./askllm
173
182
  ```
174
183
 
175
184
  ---
@@ -181,10 +190,11 @@ Inside the REPL, type `/` to access built-in commands:
181
190
  | Command | Action |
182
191
  | :--- | :--- |
183
192
  | `/help` | Display command help and tips |
184
- | `/clear` or `/reset` | Clear session conversation history |
193
+ | `/clear` or `/reset` | Clear session conversation history and code execution namespace |
185
194
  | `/model [name]` | Show or dynamically switch model |
186
- | `/endpoint` | Show currently configured endpoint URL |
195
+ | `/endpoint` | Show currently configured endpoint URL and active API mode |
187
196
  | `/system [prompt]` | Show or update the system prompt |
197
+ | `/tools [on\|off]` | Show or toggle Python code execution tool |
188
198
  | `/history` | Show full message history for the session |
189
199
  | `/paste` | Enter multiline paste mode |
190
200
  | `/exit` or `/quit` | Exit the REPL |
@@ -194,17 +204,25 @@ Inside the REPL, type `/` to access built-in commands:
194
204
  ## Command-Line Options
195
205
 
196
206
  ```
197
- usage: askllm [-h] [-v] [-m MODEL] [-e ENDPOINT] [-k API_KEY] [-s SYSTEM]
207
+ usage: askllm [-h] [-v] [-m MODEL] [-e ENDPOINT] [-x] [-k API_KEY] [-s SYSTEM]
208
+ [-H HISTORY_FILE] [--api-mode {auto,chat,responses}]
198
209
 
199
210
  options:
200
211
  -h, --help show this help message and exit
201
212
  -v, --version show program's version number and exit
202
213
  -m MODEL, --model MODEL
203
- LLM model name (env: OPENAI_MODEL, default: gpt-4o-mini)
214
+ LLM model name (env: ASKLLM_MODEL, OPENAI_MODEL, default: gpt-4o-mini)
204
215
  -e ENDPOINT, --endpoint ENDPOINT
205
- API Base URL / Endpoint (env: OPENAI_BASE_URL, OPENAI_ENDPOINT, OPENAI_API_BASE)
216
+ API Base URL / Endpoint (env: ASKLLM_BASE_URL, OPENAI_BASE_URL, OPENAI_ENDPOINT, OPENAI_API_BASE)
217
+ -x, --code-execution
218
+ Enable Python code execution tool for the LLM (env: ASKLLM_CODE_EXECUTION, OPENAI_CODE_EXECUTION)
206
219
  -k API_KEY, --api-key API_KEY
207
- API Key (env: OPENAI_API_KEY)
220
+ API Key (env: ASKLLM_API_KEY, OPENAI_API_KEY)
208
221
  -s SYSTEM, --system SYSTEM
209
- System prompt (env: OPENAI_SYSTEM_PROMPT)
222
+ System prompt (env: ASKLLM_SYSTEM_PROMPT, OPENAI_SYSTEM_PROMPT)
223
+ -H HISTORY_FILE, --history-file HISTORY_FILE
224
+ Path to history file (env: ASKLLM_HISTORY_FILE, OPENAI_HISTORY_FILE, default: ~/.askllm_history)
225
+ --api-mode {auto,chat,responses}
226
+ API mode: auto (probe /v1/responses then fallback to /v1/chat/completions),
227
+ chat, or responses (env: ASKLLM_API_MODE, OPENAI_API_MODE, default: auto)
210
228
  ```
@@ -1,6 +1,6 @@
1
1
  # AskLLM
2
2
 
3
- A lightweight, zero-dependency Python REPL for chatting with LLMs via any OpenAI-compatible API.
3
+ A lightweight, cross-platform Python REPL for chatting with LLMs via any OpenAI-compatible API, powered by `prompt_toolkit`.
4
4
 
5
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
6
 
@@ -8,7 +8,10 @@ Designed to be installed via `pip install askllm-cli` (or `pipx install askllm-c
8
8
 
9
9
  ## Features
10
10
 
11
- - **Zero Third-Party Runtime Dependencies:** Uses standard library only (`urllib.request`, `json`, `readline`).
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.
12
15
  - **Standard Python Package:** Modern PEP 517/621 packaging (`pyproject.toml`) published as `askllm-cli` on PyPI.
13
16
  - **Podman Development Ready:** Built-in development workflow using `python:3.12-slim` (`./dev.sh`).
14
17
  - **Environment Variable Auto-Detection:** Automatically picks up standard OpenAI / Azure / local LLM variables.
@@ -18,7 +21,8 @@ Designed to be installed via `pip install askllm-cli` (or `pipx install askllm-c
18
21
  - `Ctrl+C` with text in the buffer cancels the line.
19
22
  - `Ctrl+C` during response streaming halts generation cleanly without exiting.
20
23
  - **Multi-Turn Chat History:** Maintains conversation context across turns within the session.
21
- - **Persistent Input History:** Readline history saved across runs in `~/.askllm_history`.
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).
22
26
  - **Multiline Input Support:**
23
27
  - Triple quotes `"""` ... `"""`
24
28
  - Trailing backslash `\`
@@ -122,14 +126,17 @@ podman run --rm -it --network=host -e OPENAI_API_KEY askllm
122
126
 
123
127
  ## Environment Variables
124
128
 
125
- AskLLM automatically checks for these environment variables:
129
+ AskLLM automatically checks for standard OpenAI variables, all of which can be overridden by their `ASKLLM_` counterparts:
126
130
 
127
- | Variable | Description | Default |
128
- | :--- | :--- | :--- |
129
- | `OPENAI_API_KEY` | Your API key | *(empty / none)* |
130
- | `OPENAI_ENDPOINT` or `OPENAI_BASE_URL` or `OPENAI_API_BASE` | API base URL or chat endpoint | `https://api.openai.com/v1` |
131
- | `OPENAI_MODEL` | Default model name | `gpt-4o-mini` |
132
- | `OPENAI_SYSTEM_PROMPT` | Custom system prompt | `"You are a helpful assistant."` |
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` |
133
140
 
134
141
  ---
135
142
 
@@ -139,12 +146,12 @@ Because `./askllm` and `./dev.sh` use host networking (`--network=host`), you ca
139
146
 
140
147
  #### Ollama:
141
148
  ```bash
142
- OPENAI_ENDPOINT="http://localhost:11434/v1" OPENAI_MODEL="llama3.2" ./askllm
149
+ ASKLLM_ENDPOINT="http://localhost:11434/v1" ASKLLM_MODEL="llama3.2" ./askllm
143
150
  ```
144
151
 
145
152
  #### LM Studio / LocalAI / vLLM:
146
153
  ```bash
147
- OPENAI_ENDPOINT="http://localhost:1234/v1" OPENAI_MODEL="local-model" ./askllm
154
+ ASKLLM_ENDPOINT="http://localhost:1234/v1" ASKLLM_MODEL="local-model" ./askllm
148
155
  ```
149
156
 
150
157
  ---
@@ -156,10 +163,11 @@ Inside the REPL, type `/` to access built-in commands:
156
163
  | Command | Action |
157
164
  | :--- | :--- |
158
165
  | `/help` | Display command help and tips |
159
- | `/clear` or `/reset` | Clear session conversation history |
166
+ | `/clear` or `/reset` | Clear session conversation history and code execution namespace |
160
167
  | `/model [name]` | Show or dynamically switch model |
161
- | `/endpoint` | Show currently configured endpoint URL |
168
+ | `/endpoint` | Show currently configured endpoint URL and active API mode |
162
169
  | `/system [prompt]` | Show or update the system prompt |
170
+ | `/tools [on\|off]` | Show or toggle Python code execution tool |
163
171
  | `/history` | Show full message history for the session |
164
172
  | `/paste` | Enter multiline paste mode |
165
173
  | `/exit` or `/quit` | Exit the REPL |
@@ -169,17 +177,25 @@ Inside the REPL, type `/` to access built-in commands:
169
177
  ## Command-Line Options
170
178
 
171
179
  ```
172
- usage: askllm [-h] [-v] [-m MODEL] [-e ENDPOINT] [-k API_KEY] [-s SYSTEM]
180
+ usage: askllm [-h] [-v] [-m MODEL] [-e ENDPOINT] [-x] [-k API_KEY] [-s SYSTEM]
181
+ [-H HISTORY_FILE] [--api-mode {auto,chat,responses}]
173
182
 
174
183
  options:
175
184
  -h, --help show this help message and exit
176
185
  -v, --version show program's version number and exit
177
186
  -m MODEL, --model MODEL
178
- LLM model name (env: OPENAI_MODEL, default: gpt-4o-mini)
187
+ LLM model name (env: ASKLLM_MODEL, OPENAI_MODEL, default: gpt-4o-mini)
179
188
  -e ENDPOINT, --endpoint ENDPOINT
180
- API Base URL / Endpoint (env: OPENAI_BASE_URL, OPENAI_ENDPOINT, OPENAI_API_BASE)
189
+ API Base URL / Endpoint (env: ASKLLM_BASE_URL, OPENAI_BASE_URL, OPENAI_ENDPOINT, OPENAI_API_BASE)
190
+ -x, --code-execution
191
+ Enable Python code execution tool for the LLM (env: ASKLLM_CODE_EXECUTION, OPENAI_CODE_EXECUTION)
181
192
  -k API_KEY, --api-key API_KEY
182
- API Key (env: OPENAI_API_KEY)
193
+ API Key (env: ASKLLM_API_KEY, OPENAI_API_KEY)
183
194
  -s SYSTEM, --system SYSTEM
184
- System prompt (env: OPENAI_SYSTEM_PROMPT)
195
+ System prompt (env: ASKLLM_SYSTEM_PROMPT, OPENAI_SYSTEM_PROMPT)
196
+ -H HISTORY_FILE, --history-file HISTORY_FILE
197
+ Path to history file (env: ASKLLM_HISTORY_FILE, OPENAI_HISTORY_FILE, default: ~/.askllm_history)
198
+ --api-mode {auto,chat,responses}
199
+ API mode: auto (probe /v1/responses then fallback to /v1/chat/completions),
200
+ chat, or responses (env: ASKLLM_API_MODE, OPENAI_API_MODE, default: auto)
185
201
  ```
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "askllm-cli"
7
- version = "0.1.0"
7
+ version = "0.1.1"
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.1"
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
+