Restructuring the code #5

Closed
opened 2023-08-17 10:19:37 +02:00 by juk0de · 0 comments
Collaborator

If we'd restructure the code, it would make it easier to change and test it and also improve robustness:

  • Create modules for different parts (subcommands?) of the code, e. g.:
    • tags.py
    • message.py
    • chat.py
  • Create classes for the most important components that also implement the required operations:
    • Tag / TagLine
      • Tag is a single tag
      • TagLine is a line of tags with a defined prefix
      • Operations: get / add / delete / modify / match tags
    • Question / Answer
      • Question is a question string for the AI (with a defined header for the file section)
      • Answer is the response string from the AI (with a defined header for the file section)
      • Operations: extract sourcecode
    • Message
      • Message is composed of Question + Answer, optionally a set of Tags and a filename
      • Operations:
        • to_file() : write message to file (i. e. TagLine + Question.Prefix + Question + Answer.Prefix + Answer
        • from_file() : read message parts from file and create a Message instance
        • Others: get / modify the tags, question or answer
    • Chat
      • A structured chat history (list of Messages)
      • Operations:
        • Read Messages from DB folder (with filter for file names, tags and sort order)
        • Filter chat history based on message tags
        • Search Questions and Answers for a given string
        • Print chat history (optionally through a pager)
        • Prepare chat history to be used in an AI request
  • Split the tests into multiple modules
    • E. g. one test module per source module
If we'd restructure the code, it would make it easier to change and test it and also improve robustness: * Create modules for different parts (subcommands?) of the code, e. g.: * `tags.py` * `message.py` * `chat.py` * Create classes for the most important components that also implement the required operations: * `Tag` / `TagLine` * `Tag` is a single tag * `TagLine` is a line of tags with a defined prefix * Operations: get / add / delete / modify / match tags * `Question` / `Answer` * `Question` is a question string for the AI (with a defined header for the file section) * `Answer` is the response string from the AI (with a defined header for the file section) * Operations: extract sourcecode * `Message` * `Message` is composed of `Question` + `Answer`, optionally a set of `Tag`s and a filename * Operations: * `to_file()` : write message to file (i. e. `TagLine` + `Question.Prefix` + `Question` + `Answer.Prefix` + `Answer` * `from_file()` : read message parts from file and create a `Message` instance * Others: get / modify the tags, question or answer * `Chat` * A structured chat history (list of `Message`s) * Operations: * Read `Message`s from DB folder (with filter for file names, tags and sort order) * Filter chat history based on message tags * Search `Question`s and `Answer`s for a given string * Print chat history (optionally through a pager) * Prepare chat history to be used in an AI request * Split the tests into multiple modules * E. g. one test module per source module
juk0de self-assigned this 2023-08-17 10:19:46 +02:00
juk0de added reference restructurings 2023-08-17 10:23:32 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kaizenkodo/ChatMastermind#5
No description provided.