sqlsaber 0.18.0__py3-none-any.whl → 0.19.0__py3-none-any.whl
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.
Potentially problematic release.
This version of sqlsaber might be problematic. Click here for more details.
- sqlsaber/cli/interactive.py +45 -9
- {sqlsaber-0.18.0.dist-info → sqlsaber-0.19.0.dist-info}/METADATA +2 -1
- {sqlsaber-0.18.0.dist-info → sqlsaber-0.19.0.dist-info}/RECORD +6 -6
- {sqlsaber-0.18.0.dist-info → sqlsaber-0.19.0.dist-info}/WHEEL +0 -0
- {sqlsaber-0.18.0.dist-info → sqlsaber-0.19.0.dist-info}/entry_points.txt +0 -0
- {sqlsaber-0.18.0.dist-info → sqlsaber-0.19.0.dist-info}/licenses/LICENSE +0 -0
sqlsaber/cli/interactive.py
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"""Interactive mode handling for the CLI."""
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
|
+
from pathlib import Path
|
|
4
5
|
|
|
5
|
-
import
|
|
6
|
+
import platformdirs
|
|
7
|
+
from prompt_toolkit import PromptSession
|
|
8
|
+
from prompt_toolkit.history import FileHistory
|
|
9
|
+
from prompt_toolkit.styles import Style
|
|
6
10
|
from pydantic_ai import Agent
|
|
7
11
|
from rich.console import Console
|
|
8
12
|
from rich.panel import Panel
|
|
@@ -24,6 +28,23 @@ from sqlsaber.database.schema import SchemaManager
|
|
|
24
28
|
from sqlsaber.threads import ThreadStorage
|
|
25
29
|
|
|
26
30
|
|
|
31
|
+
def bottom_toolbar():
|
|
32
|
+
return [
|
|
33
|
+
(
|
|
34
|
+
"class:bottom-toolbar",
|
|
35
|
+
" Use 'Esc-Enter' or 'Meta-Enter' to submit.",
|
|
36
|
+
)
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
style = Style.from_dict(
|
|
41
|
+
{
|
|
42
|
+
"frame.border": "#ebbcba",
|
|
43
|
+
"bottom-toolbar": "#ebbcba bg:#21202e",
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
27
48
|
class InteractiveSession:
|
|
28
49
|
"""Manages interactive CLI sessions."""
|
|
29
50
|
|
|
@@ -82,7 +103,7 @@ class InteractiveSession:
|
|
|
82
103
|
self.console.print(
|
|
83
104
|
"\n",
|
|
84
105
|
"[dim] > Use '/clear' to reset conversation",
|
|
85
|
-
"[dim] > Use '/exit' or '/quit' to leave[/dim]",
|
|
106
|
+
"[dim] > Use 'Ctrl+D', '/exit' or '/quit' to leave[/dim]",
|
|
86
107
|
"[dim] > Use 'Ctrl+C' to interrupt and return to prompt\n\n",
|
|
87
108
|
"[dim] > Start message with '#' to add something to agent's memory for this database",
|
|
88
109
|
"[dim] > Type '@' to get table name completions",
|
|
@@ -137,7 +158,10 @@ class InteractiveSession:
|
|
|
137
158
|
# Create the query task
|
|
138
159
|
query_task = asyncio.create_task(
|
|
139
160
|
self.streaming_handler.execute_streaming_query(
|
|
140
|
-
user_query,
|
|
161
|
+
user_query,
|
|
162
|
+
self.agent,
|
|
163
|
+
self.cancellation_token,
|
|
164
|
+
self.message_history,
|
|
141
165
|
)
|
|
142
166
|
)
|
|
143
167
|
self.current_task = query_task
|
|
@@ -183,17 +207,26 @@ class InteractiveSession:
|
|
|
183
207
|
# Initialize table cache
|
|
184
208
|
await self._update_table_cache()
|
|
185
209
|
|
|
210
|
+
session = PromptSession(
|
|
211
|
+
history=FileHistory(
|
|
212
|
+
Path(platformdirs.user_config_dir("sqlsaber")) / "history"
|
|
213
|
+
)
|
|
214
|
+
)
|
|
215
|
+
|
|
186
216
|
while True:
|
|
187
217
|
try:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
218
|
+
# with patch_stdout():
|
|
219
|
+
user_query = await session.prompt_async(
|
|
220
|
+
"",
|
|
191
221
|
multiline=True,
|
|
192
|
-
|
|
222
|
+
mouse_support=True,
|
|
193
223
|
completer=CompositeCompleter(
|
|
194
224
|
SlashCommandCompleter(), self.table_completer
|
|
195
225
|
),
|
|
196
|
-
|
|
226
|
+
show_frame=True,
|
|
227
|
+
bottom_toolbar=bottom_toolbar,
|
|
228
|
+
style=style,
|
|
229
|
+
)
|
|
197
230
|
|
|
198
231
|
if not user_query:
|
|
199
232
|
continue
|
|
@@ -276,7 +309,10 @@ class InteractiveSession:
|
|
|
276
309
|
self.console.print("\n[yellow]Query interrupted[/yellow]")
|
|
277
310
|
else:
|
|
278
311
|
self.console.print(
|
|
279
|
-
"\n[yellow]
|
|
312
|
+
"\n[yellow]Press Ctrl+D to exit. Or use '/exit' or '/quit' slash command.[/yellow]"
|
|
280
313
|
)
|
|
314
|
+
except EOFError:
|
|
315
|
+
# Exit when Ctrl+D is pressed
|
|
316
|
+
break
|
|
281
317
|
except Exception as e:
|
|
282
318
|
self.console.print(f"[bold red]Error:[/bold red] {str(e)}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlsaber
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.19.0
|
|
4
4
|
Summary: SQLsaber - Open-source agentic SQL assistant
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Requires-Python: >=3.12
|
|
@@ -13,6 +13,7 @@ Requires-Dist: httpx>=0.28.1
|
|
|
13
13
|
Requires-Dist: keyring>=25.6.0
|
|
14
14
|
Requires-Dist: pandas>=2.0.0
|
|
15
15
|
Requires-Dist: platformdirs>=4.0.0
|
|
16
|
+
Requires-Dist: prompt-toolkit>3.0.51
|
|
16
17
|
Requires-Dist: pydantic-ai
|
|
17
18
|
Requires-Dist: questionary>=2.1.0
|
|
18
19
|
Requires-Dist: rich>=13.7.0
|
|
@@ -10,7 +10,7 @@ sqlsaber/cli/commands.py,sha256=CmCqDC6KiE8JD6Vkpsry4lBQInCiS8TBeKKx3gdxZcM,8689
|
|
|
10
10
|
sqlsaber/cli/completers.py,sha256=HsUPjaZweLSeYCWkAcgMl8FylQ1xjWBWYTEL_9F6xfU,6430
|
|
11
11
|
sqlsaber/cli/database.py,sha256=atwg3l8acQ3YTDuhq7vNrBN6tpOv0syz6V62KTF-Bh8,12910
|
|
12
12
|
sqlsaber/cli/display.py,sha256=wa7BjTBwXwqLT145Q1AEL0C28pQJTrvDN10mnFMjqsg,8554
|
|
13
|
-
sqlsaber/cli/interactive.py,sha256=
|
|
13
|
+
sqlsaber/cli/interactive.py,sha256=uoJdLWPoaDBkfdFN-59u6zduU8XGY98L16zpNsGu7nE,12964
|
|
14
14
|
sqlsaber/cli/memory.py,sha256=OufHFJFwV0_GGn7LvKRTJikkWhV1IwNIUDOxFPHXOaQ,7794
|
|
15
15
|
sqlsaber/cli/models.py,sha256=ZewtwGQwhd9b-yxBAPKePolvI1qQG-EkmeWAGMqtWNQ,8986
|
|
16
16
|
sqlsaber/cli/streaming.py,sha256=WNqBYYbWtL5CNQkRg5YWhYpWKI8qz7JmqneB2DXTOHY,5259
|
|
@@ -40,8 +40,8 @@ sqlsaber/tools/enums.py,sha256=CH32mL-0k9ZA18911xLpNtsgpV6tB85TktMj6uqGz54,411
|
|
|
40
40
|
sqlsaber/tools/instructions.py,sha256=X-x8maVkkyi16b6Tl0hcAFgjiYceZaSwyWTfmrvx8U8,9024
|
|
41
41
|
sqlsaber/tools/registry.py,sha256=HWOQMsNIdL4XZS6TeNUyrL-5KoSDH6PHsWd3X66o-18,3211
|
|
42
42
|
sqlsaber/tools/sql_tools.py,sha256=hM6tKqW5MDhFUt6MesoqhTUqIpq_5baIIDoN1MjDCXY,9647
|
|
43
|
-
sqlsaber-0.
|
|
44
|
-
sqlsaber-0.
|
|
45
|
-
sqlsaber-0.
|
|
46
|
-
sqlsaber-0.
|
|
47
|
-
sqlsaber-0.
|
|
43
|
+
sqlsaber-0.19.0.dist-info/METADATA,sha256=oH4qQnKuu5n7ucEEtSccDyvI1obYPPeZV3xNAn-8Mzc,6178
|
|
44
|
+
sqlsaber-0.19.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
45
|
+
sqlsaber-0.19.0.dist-info/entry_points.txt,sha256=qEbOB7OffXPFgyJc7qEIJlMEX5RN9xdzLmWZa91zCQQ,162
|
|
46
|
+
sqlsaber-0.19.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
47
|
+
sqlsaber-0.19.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|