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
Magic command defaults upgrade + delete messages #566
base: main
Are you sure you want to change the base?
Conversation
Took a look, no reason for builds to fail. None of my code touches the interpreter logic - purely magic commands. I've also tested it, and all works fine. Having looked through some other PRs (open and closed) seems to be a recurring issue. |
- Add your `OPENAI_API_KEY` environment variable to the repository secrets to make sure your tests can pass. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be removed as it's a bit confusing, and will likely lead to folks opening Issues or reaching out in the Discrd because they are trying to add their own OpenAI keys to a repo that they don't have access to the Environment Variables for - and I don't think anyone is running the actions on their own forks of the repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair, I thought it was the reason for the failing tests initially but I realised it wasn't. Will delete.
Would be good to get to the bottom of it more generally since it's a recurring issue..
"%save_message [path]": "Saves messages to a specified JSON path. If no path is provided, it defaults to '[date]_messages_[counter].json'.", | ||
"%load_message [path]": "Loads messages from a specified JSON path. If no path is provided, it loads the latest default message '[date]_messages_[counter].json'.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot - will update!
"%load_message [path]": "Loads messages from a specified JSON path. If no path is provided, it defaults to 'messages.json'.", | ||
"%save_message [path]": "Saves messages to a specified JSON path. If no path is provided, it defaults to '[date]_messages_[counter].json'.", | ||
"%load_message [path]": "Loads messages from a specified JSON path. If no path is provided, it loads the latest default message '[date]_messages_[counter].json'.", | ||
"%delete_message [number]": "Deletes saved messages, preserving the most recent 'number' files. If no number is provided, it deletes all but the most recent file.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%delete_message
didn't seem to work. Maybe because it's defined as delete_messages
on line 148 in the handle_magic_command()
method?
Also, it seems like %delete_message
should require a path rather than potentially deleting multiple files when called without an argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it should be %delete_messages, and will make it so that you can supply a folder or file.
Overall, I really like this change. It's a solid improvement on storing and retrieving conversation threads. Nice work! I wonder if we should use the same path that the user's I believe getting the correct directory for the user's |
Yeah, I'm happy to extract this out if we're re-using the logic across multiple places. |
@richawo I think just making the update so that Thanks for taking this one on! |
@ericrallen, hey, I'll sort it out shortly! Sorry, I've been distracted by too many projects lately 😅 |
No worries, @richawo. I just wanted to revisit this one because I think it's a nice quality-of-life improvement. Happy to help with the resolution of Merge Conflicts, too. I know sometimes they can get a bit tricky after so many changes have been made since a PR started. |
Hi @richawo |
Haha I really should, still not fixed right? |
@richawo Let me know if you have any questions or any other ideas for how to improve magic commands! |
The problem:
Magic commands previously saved to and overwrote message.json by default. The problem is:
Relevant issue
Fixes #564
The Fix:
[date]_messages_[counter].json
when no path is provided.[date]_messages_[counter].json
when no path is provided.handle_help
function to reflect the changes.With this approach, you can still save the messages quickly without overwriting. The names also include the date so you're able to get more information about the file (albeit nothing too in-depth). If you wish to clear out previous messages, you can also do that now too.
Testing
I have tested the code on the following OS:
AI Language Model (if applicable)
N/A