Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command for browsing captured logs #3

Closed
simonw opened this issue Apr 2, 2023 · 3 comments
Closed

Command for browsing captured logs #3

simonw opened this issue Apr 2, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Apr 2, 2023

Best way to do this will be with Datasette or sqlite-utils but it would be neat to have a basic history command built into llm itself.

@simonw simonw added the enhancement New feature or request label Apr 2, 2023
@simonw
Copy link
Owner Author

simonw commented Apr 2, 2023

Some ideas:

  • llm log
  • llm logs
  • llm history

I think I like llm log better.

What should it do? The problem is that the outputs can be pretty long, but those are often what you want to see.

I mean the coolest thing here would be if it was an interactive interface using Textual...

@simonw
Copy link
Owner Author

simonw commented Apr 2, 2023

I did a very rough prototype in Textual, but it's going to need a lot more work to be useful:

+from .ui import LogApp
+@cli.command()
+def logs():
+    path = get_log_db_path()
+    if not os.path.exists(path):
+        raise click.ClickException("No log database found at %s" % path)
+    app = LogApp(path)
+    app.run()

And in ui.py:

import sqlite_utils
from textual.app import App, ComposeResult
from textual.widgets import DataTable


class LogApp(App):
    def __init__(self, path):
        self.db = sqlite_utils.Database(path)
        super().__init__()

    def compose(self) -> ComposeResult:
        yield DataTable()

    def on_mount(self) -> None:
        table = self.query_one(DataTable)
        table.add_columns("provider", "prompt", "system", "response", "model", "timestamp")
        table.add_rows([r.values() for r in self.db.query(
            "select provider, prompt, system, response, model, timestamp from log order by timestamp desc"
        )])

image

@simonw
Copy link
Owner Author

simonw commented Apr 2, 2023

I'm going to have it output your history as a pretty-printed JSON array. That will do for the moment.

It will output most recent first (like git log does).

@simonw simonw closed this as completed in d8c4c08 Apr 2, 2023
simonw added a commit that referenced this issue Apr 2, 2023
simonw added a commit that referenced this issue May 17, 2023
simonw added a commit that referenced this issue Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant