mchat is an entirely text-based LLM chat application with support for different LLMs and pre-establshed customizable prompt 'personas' that support mult-shot prompts. mchat uses the excellent Textual framework for a GUI-like experience complete with mouse support and should run anywhere a decent terminal is available, including over SSH.
All that is needed is an OpenAI API key. Azure OpenAI will also work, but you will need to disable the Dall-E support if you don't also have an OpenAI API key.
New - Dall-E support added using the dall-e
keyword, and an 'image composer' persona to help create prompts.
- Copy text to past buffer when clicking on the response
- Persona support
- Support Multi-line prompts
- History and reloadable sessions with local database storage
- Support for image creation (currently just dall-e)
- Support for selecting the use of mutiple models simultaneously
- Support for functions
-
Make sure you have Python and Poetry installed on your system. If not, you can download and install them from their official websites:
- Python: https://www.python.org
- Poetry: https://python-poetry.org/docs/#installation
-
Clone this repository to your local machine or download and extract the source code.
-
Open a terminal or command prompt and navigate to the project directory.
-
Run the following command to install the project dependencies:
poetry install
This will create a virtual environment and install all the required dependencies specified in the
pyproject.toml
file.
Configuration is done within three files: settings.toml
, .secrets.toml
(optional, but recommended) and personas.json
Open the settings.toml file in a text editor to configure your application. Here's an explanation of the provided configuration options:
- model_families: A list of model families available, the default shows "oai_models" (OpenAI Models) and "ms_models" (Microsoft Models). A Model family is a group of models that use the same API access token.
For each model family, list names of the models supported in that family, precede each model with the same prefix used in for the model family. The names you use do not have to match the actual ones used by the underlying API.
- oai_models: A list of OpenAI models, including "oai_gpt-3.5-turbo" and "oai_gpt-4".
- ms_models: A list of Microsoft models, including "ms_openai_gpt_35".
For each model, you can configure the following properties:
- <model_name>.deployment: Specifies the deployment of the model, for OpenAI models, this is the actual OpenAI model name, for Microsoft models, this is the deployment name.
- <model_name>.max_tokens: Specifies the maximum number of tokens for the model.
- default_model: Specifies the default model to use.
- default_temperature: Specifies the default temperature for generating text.
- default_persona: Specifies the default persona for generating text.
mchat maintains memory of the current chat in order to retain context in long conversations. When the retained memory exceeds the size the model supports, it will summarize the convseration to reduce size. Since this can be called often for longer chats, it is recommended to use an inexpensive model.
You can configure the following properties:
- memory_model: Specifies the specific model to use for memory, use one of the models you sepcified in your model lists
- memory_model_temperature: Specifies the temperature for the memory model.
- memory_model_max_tokens: Specifies the maximum tokens for the memory model.
Note that some configuration options, such as API keys, are meant to be kept in a separate .secrets.toml file. You can include the following configuration in that file:
# In .secrets.toml
# dynaconf_merge = true
# Replace the following with your actual API keys
# openai_models_api_key = "oai_ai_api_key_goes_here"
# ms_models_api_key = "ms_openai_api_key_goes_here"
mchat comes with a default persona and two example personas linux computer and financial manager. Additional personas can be added in a extra_personas.json
file at the top level (same level as this README) using a similar pattern to mchat/default_personas.json
in the code. When configuring personas, the extra_context
list can allow you to respresent a multi-shot prompt, see the linux computer
persona in mchat/default_personas.json
as an example.
-
Run the application in poetry using the following command
poetry run mchat
-
Activate the virtual environment created by Poetry using the following command:
poetry shell
-
Run the application using the following command:
mchat
Thank you for considering contributing to the project! To contribute, please follow these guidelines:
-
Fork the repository and clone it to your local machine.
-
Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name
Replace
your-feature-name
with a descriptive name for your contribution. -
Make the necessary changes and ensure that your code follows the project's coding conventions and style guidelines - which currently are using PEP 8 for style and black for formatting
-
Commit your changes with a clear and descriptive commit message:
git commit -m "Add your commit message here"
-
Push your branch to your forked repository:
git push origin feature/your-feature-name
-
Open a pull request from your forked repository to the main repository's
main
branch. -
Provide a clear and detailed description of your changes in the pull request. Include any relevant information that would help reviewers understand your contribution.
This project is licensed under the MIT License.
Feel free to reach out to me at @jspv on GitHub