Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duartemartins/readwise-gpt-tagger
A python script that tags all Readwise highlights using ChatGPT
https://github.com/duartemartins/readwise-gpt-tagger
Last synced: 3 days ago
JSON representation
A python script that tags all Readwise highlights using ChatGPT
- Host: GitHub
- URL: https://github.com/duartemartins/readwise-gpt-tagger
- Owner: Duartemartins
- Created: 2024-09-09T18:41:10.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2024-09-09T20:40:52.000Z (4 months ago)
- Last Synced: 2024-09-18T17:11:14.374Z (4 months ago)
- Language: Python
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-readwise - readwise-gpt-tagger - Export all highlights to CSV, tag them using GPT, and update them on Readwise. (Tools / Other)
README
# Readwise GPT Tagger Project
This project retrieves, processes, and enriches highlights from your Readwise account, generating both CSV and DOCX files that include the highlights and associated tags. If the highlights have fewer than 3 tags, the script uses OpenAI to generate additional relevant tags.
## Features
- Fetches all highlights from a user's Readwise account, iterating through multiple pages of data if necessary.
- Automatically enriches highlights with additional tags generated by OpenAI if fewer than three are present.
- Saves highlights with their tags to both a CSV and DOCX file.
- Logs updated highlights and handles potential errors, such as API rate-limiting.
- Supports pagination to retrieve large datasets beyond a single API request limit.## Project Structure
- `.gitignore`: Specifies files and directories to be ignored by Git.
- `Highlights_with_Tags.csv`: CSV file containing highlights with tags.
- `Highlights_with_Tags.docx`: DOCX file containing highlights with tags.
- `Highlights.docx`: DOCX file containing highlights without additional tags.
- `README.md`: This file, explaining project details.
- `readwise.py`: Python script responsible for fetching, processing, and saving highlights.
- `requirements.txt`: List of dependencies required for the project.
- `updated_highlights_log.txt`: Log file recording the highlights that were successfully updated in Readwise with new tags.## Setup
1. **Clone the repository:**
```sh
git clone https://github.com/your-username/highlights-project.git
cd highlights-project
```2. **Install the required dependencies:**
```sh
pip install -r requirements.txt
```3. **Set Environment Variables:**
You will need two environment variables:
- `READWISE`: Your Readwise API token.
- `OPENAI_API_KEY`: Your OpenAI API key.You can set them like this in your terminal:
```sh
export READWISE=your_readwise_token
export OPENAI_API_KEY=your_openai_api_key
```## Usage
1. **Run the `readwise.py` script to process highlights:**
```sh
python readwise.py
```2. **Output Files:**
- `Highlights_with_Tags.csv`: CSV file with highlights and their tags.
- `Highlights_with_Tags.docx`: DOCX file with highlights and their tags.
- `updated_highlights_log.txt`: Log of successfully updated highlights in Readwise.## Error Handling
- **API Rate-Limiting:** The script detects API throttling errors and logs when requests are delayed due to rate limits. You may need to rerun the script after waiting for the cooldown period.
- **Incomplete Tag Generation:** If the OpenAI tag generation fails, it logs the error and continues processing other highlights.## Dependencies
This project uses the following Python packages:
```txt
stack-data==0.6.3
tornado==6.4
tqdm==4.66.4
traitlets==5.14.2
typing_extensions==4.12.2
tzdata==2024.1
urllib3==2.2.2
wcwidth==0.2.13
requests==2.28.1
python-docx==0.8.11
openai==1.7.0
```You can install them by running:
```sh
pip install -r requirements.txt
```## License
This project is licensed under the MIT License. You are free to use, modify, and distribute this project under the terms of the license.