-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Comments
Some ideas:
I think I like 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... |
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 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"
)]) |
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 |
Best way to do this will be with Datasette or
sqlite-utils
but it would be neat to have a basic history command built intollm
itself.The text was updated successfully, but these errors were encountered: