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

Log chats to database for enhanced interaction #1859

Open
lockmeister opened this issue Oct 1, 2024 · 2 comments
Open

Log chats to database for enhanced interaction #1859

lockmeister opened this issue Oct 1, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@lockmeister
Copy link

lockmeister commented Oct 1, 2024

Issue

It would be handy to log chats to a database rather than just save a large .md file.
I was inspired by this tool, which logs all LLM chats to sqlite and then allows you to explore the logs in your browser.

this can add a lot of really nice features "for free", through the use of SQL queries in datasette.

  • easily track costs e.g. across a day, a repo.
  • full text search of chat history, could add vector search too. Minimises costs; search history instead of asking again.
  • datasette plugins allow many additional features, e.g AI generated SQL queries to enable natural language queries to generate SQL to search your chat

Using datasette is a good solution, or perhaps a future version of aider might implement some of those features internally.

@lockmeister
Copy link
Author

added PR #1860

@fry69
Copy link
Contributor

fry69 commented Oct 1, 2024

This would be a perfect first plugin if aider ever gets a plugin system, otherwise I think the current markdown file log works super fine.

The only downside is that the markdown log is for all aider sessions combined, but that can be worked around with a Bash/shell alias. See this post I copied from the Discord ->


Here is a cute Bash alias for aider: It will create separate chat/input history files for each aider session in a .aider.history folder with a timestamp and the current branch name of the git repository, to make it much easier to look things up later. If no git repository is present, default gets used as the branch name.

Example when run:

aider --input-history-file .aider.history/feature-20240910_1213.input.md --chat-history-file .aider.history/feature-20240910_1213.chat.md

Bash alias:

alias aider='mkdir -p .aider.history ; branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "default"); timestamp=$(date "+%Y%m%d_%H%M"); aider --input-history-file ".aider.history/$branch-$timestamp.input.md" --chat-history-file ".aider.history/$branch-$timestamp.chat.md"'

This makes it also possible to automatically clean out old sessions, preventing endless growing history files (which are also a pain to search/lookup).
Downside: No more global input history, every session starts fresh with an empty one (no going back). This could be changed though, just remove the --input-history-file part from the alias.

@fry69 fry69 added the enhancement New feature or request label Oct 1, 2024
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

2 participants