Skip to content

Commit

Permalink
Merge pull request #201 from dbcli/redirect-stderr
Browse files Browse the repository at this point in the history
Redirect both stdout and stderr while capturing output.
  • Loading branch information
amjith authored Jan 26, 2025
2 parents d06888a + b3b6139 commit d0ad299
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.14.1 - 2025-01-25

### Bug Fixes

* Capture stderr in addition to stdout when capturing output from `llm` cli.

## 1.14.0 - 2025-01-22

### Features
Expand Down
6 changes: 3 additions & 3 deletions litecli/packages/special/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ def run_external_cmd(cmd, *args, capture_output=False, restart_cli=False, raise_

if capture_output:
buffer = io.StringIO()
redirect = contextlib.redirect_stdout(buffer)
redirect = contextlib.ExitStack()
redirect.enter_context(contextlib.redirect_stdout(buffer))
redirect.enter_context(contextlib.redirect_stderr(buffer))
else:
# Use nullcontext to do nothing when not capturing output
redirect = contextlib.nullcontext()

with redirect:
Expand Down Expand Up @@ -172,7 +173,6 @@ def initialize_llm():
if click.confirm("This feature requires additional libraries. Install LLM library?", default=True):
click.echo("Installing LLM library. Please wait...")
run_external_cmd("pip", "install", "--quiet", "llm", restart_cli=True)
ensure_litecli_template()


def ensure_litecli_template(replace=False):
Expand Down

0 comments on commit d0ad299

Please sign in to comment.