Merging upstream version 1.14.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
b87d920aaa
commit
51881c9ebd
4 changed files with 27 additions and 8 deletions
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,3 +1,17 @@
|
|||
## 1.14.4 - 2025-01-31
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix the usage instructions in the `\llm` command.
|
||||
|
||||
## 1.14.3 - 2025-01-29
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix [misleading "0 rows affected" status for CTEs](https://github.com/dbcli/litecli/issues/203)
|
||||
by never displaying rows affected when the connector tells us -1
|
||||
* Show an error message when `\llm "question"` is invoked without a database connection.
|
||||
|
||||
## 1.14.2 - 2025-01-26
|
||||
|
||||
### Bug Fixes
|
||||
|
|
|
@ -444,7 +444,7 @@ class LiteCli(object):
|
|||
if special.is_llm_command(text):
|
||||
try:
|
||||
start = time()
|
||||
cur = self.sqlexecute.conn.cursor()
|
||||
cur = self.sqlexecute.conn and self.sqlexecute.conn.cursor()
|
||||
context, sql = special.handle_llm(text, cur)
|
||||
if context:
|
||||
click.echo(context)
|
||||
|
|
|
@ -138,14 +138,14 @@ qwq
|
|||
> \\llm models default llama3
|
||||
|
||||
# Set api key (not required for local models)
|
||||
> \\llm keys set openai sg-1234
|
||||
API key set for openai.
|
||||
> \\llm keys set openai
|
||||
|
||||
|
||||
# Install a model plugin
|
||||
> \\llm install llm-ollama
|
||||
llm-ollama installed.
|
||||
|
||||
# Models directory
|
||||
# Plugins directory
|
||||
# https://llm.datasette.io/en/stable/plugins/directory.html
|
||||
"""
|
||||
|
||||
|
@ -285,6 +285,8 @@ def is_llm_command(command) -> bool:
|
|||
|
||||
@export
|
||||
def sql_using_llm(cur, question=None, verbose=False) -> Tuple[str, Optional[str]]:
|
||||
if cur is None:
|
||||
raise RuntimeError("Connect to a datbase and try again.")
|
||||
schema_query = """
|
||||
SELECT sql FROM sqlite_master
|
||||
WHERE sql IS NOT NULL
|
||||
|
|
|
@ -138,16 +138,19 @@ class SQLExecute(object):
|
|||
# e.g. SELECT.
|
||||
if cursor.description is not None:
|
||||
headers = [x[0] for x in cursor.description]
|
||||
status = "{0} row{1} in set"
|
||||
status = "{count} row{s} in set"
|
||||
cursor = list(cursor)
|
||||
rowcount = len(cursor)
|
||||
else:
|
||||
_logger.debug("No rows in result.")
|
||||
status = "Query OK, {0} row{1} affected"
|
||||
rowcount = 0 if cursor.rowcount == -1 else cursor.rowcount
|
||||
if cursor.rowcount == -1:
|
||||
status = "Query OK"
|
||||
else:
|
||||
status = "Query OK, {count} row{s} affected"
|
||||
rowcount = cursor.rowcount
|
||||
cursor = None
|
||||
|
||||
status = status.format(rowcount, "" if rowcount == 1 else "s")
|
||||
status = status.format(count=rowcount, s="" if rowcount == 1 else "s")
|
||||
|
||||
return (title, cursor, headers, status)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue