- Introduce SQLite database to store conversation history
- Implement functions to save and load conversations from the database
- Replace previous file-based history storage with database-backed solution
- Add new command to list and resume previous conversations
- Update chat logic to generate topics for saved conversations
- Add database initialization and management functions
- Modify command line interface to support resuming conversations
This commit introduces a significant refactor of the AI assistant's codebase, transitioning from a procedural approach to an object-oriented design. This change improves modularity, maintainability, and extensibility.
Key changes include:
- Introduction of classes: AIAssistant, CommandLineParser, InputHandler, and CommandParser.
- Encapsulation of core functionality within the AIAssistant class.
- Improved input handling with separation of interactive and piped input.
- Implementation of command parsing for actions like saving, clearing, and exiting.
- Refactored history management for persistent conversation storage.
The `guess_lexer` function was not correctly handling code snippets when no language was specified. It was only considering the second line of the code, which could lead to incorrect lexer selection. This commit joins the lines of code (excluding the first and last) back into a single string before passing it to `guess_lexer`, ensuring the entire code block is considered for lexer identification.
This commit introduces several improvements to the input handling process:
- Implemented `improved_input()` to handle multi-line input and prevent accidental sending of pasted content. The user signals completion by pressing Ctrl+D or entering two consecutive empty lines.
- Added a new command-line argument `--context` to allow users to specify the context length for the model.
- Updated the help message to reflect the new argument.