You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/llm.md
+27-27Lines changed: 27 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
# Using the \llm Command (AI-assisted SQL)
1
+
# Using the /llm Command (AI-assisted SQL)
2
2
3
-
The `\llm` special command lets you ask natural-language questions and get SQL proposed for you. It uses the open‑source `llm` CLI under the hood and enriches your prompt with database context (schema and one sample row per table) so answers can include runnable SQL.
3
+
The `/llm` special command lets you ask natural-language questions and get SQL proposed for you. It uses the open‑source `llm` CLI under the hood and enriches your prompt with database context (schema and one sample row per table) so answers can include runnable SQL.
4
4
5
-
Alias: `\ai` works the same as `\llm`.
5
+
Alias: `/ai` works the same as `/llm`.
6
6
7
7
---
8
8
@@ -20,13 +20,13 @@ pip install llm
20
20
2) From the mycli prompt, configure your API key (only needed for remote providers like OpenAI):
21
21
22
22
```text
23
-
\llm keys set openai
23
+
/llm keys set openai
24
24
```
25
25
26
26
3) Ask a question. The response’s SQL (inside a ```sql fenced block) is extracted and pre-filled at the prompt:
27
27
28
28
```text
29
-
World> \llm "Capital of India?"
29
+
World> /llm "Capital of India?"
30
30
-- Answer text from the model...
31
31
-- ```sql
32
32
-- SELECT ...;
@@ -40,7 +40,7 @@ You can now hit Enter to run, or edit the query first.
40
40
41
41
## What Context Is Sent
42
42
43
-
When you ask a plain question via `\llm "..."`, mycli:
43
+
When you ask a plain question via `/llm "..."`, mycli:
44
44
- Sends your question.
45
45
- Adds your current database schema: table names with column types.
46
46
- Adds one sample row (if available) from each table.
@@ -53,27 +53,27 @@ Note: Context is gathered from the current connection. If you are not connected,
53
53
54
54
## Using `llm` Subcommands from mycli
55
55
56
-
You can run any `llm` CLI subcommand by prefixing it with `\llm` inside mycli. Examples:
56
+
You can run any `llm` CLI subcommand by prefixing it with `/llm` inside mycli. Examples:
57
57
58
58
- List models:
59
59
```text
60
-
\llm models
60
+
/llm models
61
61
```
62
62
- Set the default model:
63
63
```text
64
-
\llm models default gpt-5
64
+
/llm models default gpt-5
65
65
```
66
66
- Set provider API key:
67
67
```text
68
-
\llm keys set openai
68
+
/llm keys set openai
69
69
```
70
70
- Install a plugin (e.g., local models via Ollama):
71
71
```text
72
-
\llm install llm-ollama
72
+
/llm install llm-ollama
73
73
```
74
74
After installing or uninstalling plugins, mycli will restart to pick up new commands.
75
75
76
-
Tab completion works for `\llm` subcommands, and even for model IDs under `models default`.
76
+
Tab completion works for `/llm` subcommands, and even for model IDs under `models default`.
77
77
78
78
Aside: <https://ollama.com/> for using local models.
79
79
@@ -84,7 +84,7 @@ Aside: <https://ollama.com/> for using local models.
84
84
Ask your question in quotes. mycli sends database context and extracts a SQL block if present.
85
85
86
86
```text
87
-
World> \llm "Most visited urls?"
87
+
World> /llm "Most visited urls?"
88
88
```
89
89
90
90
Behavior:
@@ -98,9 +98,9 @@ Behavior:
98
98
Use `-c` to ask a follow‑up that continues the previous conversation with the model. This does not re-send the DB context; it relies on the ongoing thread.
99
99
100
100
```text
101
-
World> \llm "Top 10 customers by spend"
101
+
World> /llm "Top 10 customers by spend"
102
102
-- model returns analysis and a ```sql block; SQL is prefilled
103
-
World> \llm -c "Now include each customer's email and order count"
103
+
World> /llm -c "Now include each customer's email and order count"
104
104
```
105
105
106
106
Behavior:
@@ -115,29 +115,29 @@ Behavior:
115
115
116
116
- List available models:
117
117
```text
118
-
World> \llm models
118
+
World> /llm models
119
119
```
120
120
121
121
- Change default model:
122
122
```text
123
-
World> \llm models default llama3
123
+
World> /llm models default llama3
124
124
```
125
125
126
126
- Set API key (for providers that require it):
127
127
```text
128
-
World> \llm keys set openai
128
+
World> /llm keys set openai
129
129
```
130
130
131
131
- Ask a question with context:
132
132
```text
133
-
World> \llm "Capital of India?"
133
+
World> /llm "Capital of India?"
134
134
```
135
135
136
136
- Use a local model (after installing a plugin such as `llm-ollama`):
137
137
```text
138
-
World> \llm install llm-ollama
139
-
World> \llm models default llama3
140
-
World> \llm "Top 10 customers by spend"
138
+
World> /llm install llm-ollama
139
+
World> /llm models default llama3
140
+
World> /llm "Top 10 customers by spend"
141
141
```
142
142
143
143
See: <https://ollama.com/> for details.
@@ -149,13 +149,13 @@ See: <https://ollama.com/> for details.
149
149
mycli uses a saved `llm` template named `mycli-llm-template` for contextual questions. You can view or edit it:
150
150
151
151
```text
152
-
World> \llm templates edit mycli-llm-template
152
+
World> /llm templates edit mycli-llm-template
153
153
```
154
154
155
155
Tip: After first use, mycli ensures this template exists. To just view it without editing, use:
156
156
157
157
```text
158
-
World> \llm templates show mycli-llm-template
158
+
World> /llm templates show mycli-llm-template
159
159
```
160
160
161
161
---
@@ -164,15 +164,15 @@ World> \llm templates show mycli-llm-template
164
164
165
165
- No SQL pre-fill: Ensure the model’s response includes a ```sql fenced block. The built‑in prompt encourages this, but some models may omit it; try asking the model to include SQL in a ```sql block.
166
166
- Not connected to a database: Contextual questions require a live connection. Connect first. Follow‑ups with `-c` only help after a successful contextual call.
167
-
- Plugin changes not recognized: After `\llm install` or `\llm uninstall`, mycli restarts automatically to load new commands.
168
-
- Provider/API issues: Use `\llm keys list` and `\llm keys set <provider>` to check credentials. Use `\llm models` to confirm available models.
167
+
- Plugin changes not recognized: After `/llm install` or `/llm uninstall`, mycli restarts automatically to load new commands.
168
+
- Provider/API issues: Use `/llm keys list` and `/llm keys set <provider>` to check credentials. Use `/llm models` to confirm available models.
169
169
170
170
---
171
171
172
172
## Notes and Safety
173
173
174
174
- Data sent: Contextual questions send schema (table/column names and types) and a single sample row per table. Review your data sensitivity policies before using remote models; prefer local models (such as ollama) if needed.
175
-
- Help: Running `\llm` with no arguments shows a short usage message.
175
+
- Help: Running `/llm` with no arguments shows a short usage message.
0 commit comments