|
2 | 2 | import io |
3 | 3 | import logging |
4 | 4 | import os |
| 5 | +import pprint |
5 | 6 | import re |
6 | 7 | import shlex |
7 | 8 | import sys |
8 | 9 | from runpy import run_module |
9 | | -from typing import Optional, Tuple |
10 | 10 | from time import time |
| 11 | +from typing import Optional, Tuple |
11 | 12 |
|
12 | 13 | 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 |
26 | 16 |
|
27 | 17 | from . import export |
28 | | -from .main import parse_special_command, Verbosity |
| 18 | +from .main import Verbosity, parse_special_command |
29 | 19 |
|
30 | 20 | log = logging.getLogger(__name__) |
31 | 21 |
|
32 | 22 | 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()} |
33 | 25 |
|
34 | 26 |
|
35 | 27 | 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): |
187 | 179 | """ |
188 | 180 |
|
189 | 181 |
|
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 | | - |
197 | 182 | def ensure_litecli_template(replace=False): |
198 | 183 | """ |
199 | 184 | Create a template called litecli with the default prompt. |
@@ -223,11 +208,6 @@ def handle_llm(text, cur) -> Tuple[str, Optional[str], float]: |
223 | 208 | is_verbose = mode is Verbosity.VERBOSE |
224 | 209 | is_succinct = mode is Verbosity.SUCCINCT |
225 | 210 |
|
226 | | - # LLM is not installed. |
227 | | - if llm is None: |
228 | | - initialize_llm() |
229 | | - raise FinishIteration(None) |
230 | | - |
231 | 211 | if not arg.strip(): # No question provided. Print usage and bail. |
232 | 212 | output = [(None, None, None, USAGE)] |
233 | 213 | raise FinishIteration(output) |
|
0 commit comments