Skip to content

Commit 31fcee9

Browse files
committed
📨
0 parents  commit 31fcee9

6 files changed

Lines changed: 554 additions & 0 deletions

File tree

‎.env.local‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
OPENAI_API_KEY=<YOUR_API_KEY>

‎.gitignore‎

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# ---- Python ----
2+
# Byte-compiled / optimized / DLL files
3+
__pycache__/
4+
*.py[cod]
5+
*$py.class
6+
7+
# C extensions
8+
*.so
9+
10+
# Distribution / packaging
11+
.Python
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
cover/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
db.sqlite3
63+
db.sqlite3-journal
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
.pybuilder/
77+
target/
78+
79+
# Jupyter Notebook
80+
.ipynb_checkpoints
81+
82+
# IPython
83+
profile_default/
84+
ipython_config.py
85+
86+
# pyenv
87+
# For a library or package, you might want to ignore these files since the code is
88+
# intended to run in multiple environments; otherwise, check them in:
89+
# .python-version
90+
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
#Pipfile.lock
97+
98+
# poetry
99+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100+
# This is especially recommended for binary packages to ensure reproducibility, and is more
101+
# commonly ignored for libraries.
102+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103+
#poetry.lock
104+
105+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
106+
__pypackages__/
107+
108+
# Celery stuff
109+
celerybeat-schedule
110+
celerybeat.pid
111+
112+
# SageMath parsed files
113+
*.sage.py
114+
115+
# Environments
116+
.env
117+
.venv
118+
env/
119+
venv/
120+
ENV/
121+
env.bak/
122+
venv.bak/
123+
124+
# Spyder project settings
125+
.spyderproject
126+
.spyproject
127+
128+
# Rope project settings
129+
.ropeproject
130+
131+
# mkdocs documentation
132+
/site
133+
134+
# mypy
135+
.mypy_cache/
136+
.dmypy.json
137+
dmypy.json
138+
139+
# Pyre type checker
140+
.pyre/
141+
142+
# pytype static type analyzer
143+
.pytype/
144+
145+
# Cython debug symbols
146+
cython_debug/
147+
148+
# PyCharm
149+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
150+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
151+
# and can be added to the global gitignore or merged into this file. For a more nuclear
152+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
153+
#.idea/
154+
155+
credentials.json
156+
token.json

‎README.md‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Gmail LLM
2+
3+
Using GPT4 to extract interesting links from my daily newsletters
4+
5+
**Why?** I spend too much time opening and checking through all my newsletters subscriptions, would rather have all interesting links in one page.
6+
7+
Inspired by [isafulf/inbox_cleaner](https://github.com/isafulf/inbox_cleaner)
8+
9+
## Prerequisites
10+
11+
- Python 3.10 or higher
12+
- Gmail account
13+
- Google Cloud account with Gmail API enabled
14+
- OpenAI API key
15+
16+
## Setup
17+
18+
1. Clone repo:
19+
20+
```
21+
git clone https://github.com/benthecoder/gmail_llm.git
22+
cd gmail_llm
23+
```
24+
25+
2. Install packages:
26+
27+
```
28+
pip install -r requirements.txt
29+
```
30+
31+
3. Set up Google API credentials:
32+
33+
- create a new OAuth 2.0 Client ID ([instructions](https://developers.google.com/workspace/guides/create-credentials))
34+
- Download JSON file and rename it to `credentials.json`.
35+
- Put `credentials.json` in the `gmail_llm` directory.
36+
37+
4. Set OpenAI API key:
38+
39+
- Get an OpenAI API key [here](https://platform.openai.com/api-keys)
40+
- Rename` .env.local` to `.env` and set your key
41+
42+
```
43+
OPENAI_API_KEY=<YOUR_API_KEY>
44+
```
45+
46+
## Usage
47+
48+
Run the script:
49+
50+
```
51+
python main.py
52+
```
53+
54+
see an example in [summary](summary/2023-12-04.md) folder
55+
56+
## TODO
57+
58+
- [ ] improve prompt to extract as many links as possible and have better categorization
59+
- [ ] Experiment with different forms of output, maybe article form? Have it copy someone's writing style, publish it to substack, could be a newsletter automation with AI thing
60+
- [ ] Check if text extracted from emails can be cleaned up, any redundant info fed into prompt?
61+
62+
## Links
63+
64+
- Docs for listing emails [users.messages.list](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list)
65+
- Docs for querying [Searching for Messages](https://developers.google.com/gmail/api/guides/filtering)
66+
- [Counting tokens with tiktoken](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb)

0 commit comments

Comments
 (0)