TODO (summary of project)
- This project requires using macOS. It reads messages from the built-in messages database on Mac. I welcome future support for other operating systems and/or just passing in messages as a CSV file.
- This project was written using Python 3.12.3. It may work with other Python versions. Download python: https://www.python.org/downloads/
- You need an OpenAI API key to use with this project.
- Clone the repository:
git clone https://github.com/tommypraeger/textsGPT.git
- Navigate to the repository directory:
cd textsGPT
- Create a virtual environment:
python3 -m venv venv
- Activate the virtual environment:
source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
-
Set environment variables (you can use a
.env
file to define them if you would like):OPENAI_API_KEY=<your OpenAI API key>
. https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key- (optional)
TOKENIZERS_PARALLELISM=false
. Could help prevent the messages described here from being printed.
-
Give the application you will use to run this script Full Disk Access (I know this seems sketchy but it needs to be able to access the messages database stored on your Mac, which is not available to applications by default):
- Open System Preferences
- Go to Security and Privacy
- Go to Privacy
- Go to Full Disk Access
- Give whatever application you're running this from Full Disk Access
Note: These instructions might be different on newer versions of macOS. These instructions work for macOS Monterrey (v12) (I need a new Mac to use a newer version)
First, edit the CHATS
dictionary in textsgpt/mac/my_chats.py
to include information about the chat(s) you want to use.
Run the script (replace <name of chat>
with the dictionary key you used for the chat in CHATS
):
python3 -m textsgpt "<name of chat>"
The first execution of the script can take several minutes for large chats as it builds an index for the entire content of the chat. Subsequent executions for the same chat should be faster as only new messages since the last script execution need to be indexed.
Once the indexing finishes, you can prompt the chatbot for information about your chat. Some example prompts:
- Suggest a new name for the group chat
- Please suggest date ideas that <name> would like in New York City. Be specific.
- What does <name> think about <topic>?
TODO (note about changing default values)
This project uses black
for formatting. Following the instructions for installation. Once installed, format by running the following from the root of this project:
black .
This project uses typing
. If you are using VS Code and have a Python language server configured, I recommend setting "python.analysis.typeCheckingMode": "strict"
in your settings.json to enforce type checking. Learn more here.
This project uses pytest. To run unit tests, run the following from the root of this project:
pytest
To generate a test coverage report, run:
pytest --cov-report=term-missing --cov=textsgpt
To change the contents of my_chats.py
without accidentally committing your chat info, you can run:
git update-index --assume-unchanged textsgpt/mac/my_chats.py
If you want git to track my_chats.py
again, run:
git update-index --no-assume-unchanged textsgpt/mac/my_chats.py
TODO
- This project is in collaboration with Gabe Schmittlein and draws significant inspiration from https://github.com/gschmittlein/imessageGPT
- This project borrows from https://github.com/tommypraeger/imessage_analysis, which drew inspiration from https://stmorse.github.io/journal/iMessage.html