Skip to content

Commit c3a508e

Browse files
committed
Make llm library a dependency.
1 parent 21957bc commit c3a508e

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

litecli/packages/special/llm.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,26 @@
22
import io
33
import logging
44
import os
5+
import pprint
56
import re
67
import shlex
78
import sys
89
from runpy import run_module
9-
from typing import Optional, Tuple
1010
from time import time
11+
from typing import Optional, Tuple
1112

1213
import click
13-
import pprint
14-
15-
try:
16-
import llm
17-
from llm.cli import cli
18-
19-
LLM_CLI_COMMANDS = list(cli.commands.keys())
20-
MODELS = {x.model_id: None for x in llm.get_models()}
21-
except ImportError:
22-
llm = None
23-
cli = None
24-
LLM_CLI_COMMANDS = []
25-
MODELS = {}
14+
import llm
15+
from llm.cli import cli
2616

2717
from . import export
28-
from .main import parse_special_command, Verbosity
18+
from .main import Verbosity, parse_special_command
2919

3020
log = logging.getLogger(__name__)
3121

3222
LLM_TEMPLATE_NAME = "litecli-llm-template"
23+
LLM_CLI_COMMANDS = list(cli.commands.keys())
24+
MODELS = {x.model_id: None for x in llm.get_models()}
3325

3426

3527
def run_external_cmd(cmd, *args, capture_output=False, restart_cli=False, raise_exception=True) -> Tuple[int, str]:
@@ -187,13 +179,6 @@ def __init__(self, results=None):
187179
"""
188180

189181

190-
def initialize_llm():
191-
# Initialize the LLM library.
192-
if click.confirm("This feature requires additional libraries. Install LLM library?", default=True):
193-
click.echo("Installing LLM library. Please wait...")
194-
run_external_cmd("pip", "install", "--quiet", "llm", restart_cli=True)
195-
196-
197182
def ensure_litecli_template(replace=False):
198183
"""
199184
Create a template called litecli with the default prompt.
@@ -223,11 +208,6 @@ def handle_llm(text, cur) -> Tuple[str, Optional[str], float]:
223208
is_verbose = mode is Verbosity.VERBOSE
224209
is_succinct = mode is Verbosity.SUCCINCT
225210

226-
# LLM is not installed.
227-
if llm is None:
228-
initialize_llm()
229-
raise FinishIteration(None)
230-
231211
if not arg.strip(): # No question provided. Print usage and bail.
232212
output = [(None, None, None, USAGE)]
233213
raise FinishIteration(output)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies = [
1616
"sqlparse>=0.4.4",
1717
"setuptools", # Required by llm commands to install models
1818
"pip",
19+
"llm>=0.25.0",
1920
]
2021

2122
[build-system]

0 commit comments

Comments
 (0)