graph LR
MLXVisionChat["MLXVisionChat"]
Chat_UI["Chat UI"]
Chat_Loop["Chat Loop"]
Command_Handler["Command Handler"]
Response_Generator["Response Generator"]
History_Manager["History Manager"]
Image_Processor["Image Processor"]
Help_Displayer["Help Displayer"]
MLXVisionChat -- "initiates" --> Chat_Loop
Chat_Loop -- "relies on" --> Chat_UI
Chat_Loop -- "calls" --> Response_Generator
Chat_Loop -- "invokes" --> Command_Handler
Chat_Loop -- "uses" --> History_Manager
Command_Handler -- "calls" --> Image_Processor
Command_Handler -- "calls" --> Help_Displayer
The mlx-vlm chat application is structured around a central MLXVisionChat component that manages the entire chat session. This component integrates with a Chat UI for user interaction, providing a continuous Chat Loop that processes user input. Within this loop, a Command Handler dispatches specific commands, including those for an Image Processor to handle visual inputs and a Help Displayer for user guidance. Textual and multimodal responses are generated by a Response Generator which interfaces with the VLM, and all interactions are recorded by a History Manager to maintain conversation context. This design ensures a clear separation of concerns, with the MLXVisionChat class acting as the primary coordinator for the application's core functionalities.
Serves as the central orchestrator, encapsulating the entire chat application's state and high-level logic. It manages the VLM instance and overall chat session, acting as the main controller for the UI.
Related Classes/Methods:
Handles the presentation layer for the chat application, specifically managing the visual rendering of the chat interface and capturing user input from the command line. This is the direct interface with the user.
Related Classes/Methods:
Manages the continuous flow of the chat interaction. It handles user input, processes commands, generates responses, and updates the chat history in a continuous cycle, driving the interactive experience.
Related Classes/Methods:
Parses user input to identify and execute specific commands (e.g., /image, /help), acting as a dispatcher for special actions within the chat.
Related Classes/Methods:
Interfaces with the underlying VLM to produce textual or multimodal responses based on the current chat context, preparing data for display in the UI.
Related Classes/Methods:
Appends new messages and responses to the chat's conversation history, maintaining the chronological flow of the dialogue for display purposes.
Related Classes/Methods:
Manages the loading, preprocessing, and integration of image data into the chat context, enabling multimodal interactions with the VLM.
Related Classes/Methods:
Displays predefined help messages and usage instructions to the user, providing guidance on available commands and features directly within the UI.
Related Classes/Methods: