pretty-please-llm 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. pretty_please_llm-0.1.0/.github/workflows/ci.yml +46 -0
  2. pretty_please_llm-0.1.0/.github/workflows/pypi-publish.yml +43 -0
  3. pretty_please_llm-0.1.0/.gitignore +207 -0
  4. pretty_please_llm-0.1.0/.pre-commit-config.yaml +7 -0
  5. pretty_please_llm-0.1.0/LICENSE +21 -0
  6. pretty_please_llm-0.1.0/PKG-INFO +202 -0
  7. pretty_please_llm-0.1.0/README.md +171 -0
  8. pretty_please_llm-0.1.0/examples/anthropic_example.py +20 -0
  9. pretty_please_llm-0.1.0/examples/litellm_example.py +15 -0
  10. pretty_please_llm-0.1.0/examples/openai_example.py +17 -0
  11. pretty_please_llm-0.1.0/pretty_please/__init__.py +4 -0
  12. pretty_please_llm-0.1.0/pretty_please/adapters/__init__.py +1 -0
  13. pretty_please_llm-0.1.0/pretty_please/adapters/anthropic.py +68 -0
  14. pretty_please_llm-0.1.0/pretty_please/adapters/claude_code/__init__.py +1 -0
  15. pretty_please_llm-0.1.0/pretty_please/adapters/claude_code/hook.py +61 -0
  16. pretty_please_llm-0.1.0/pretty_please/adapters/claude_code/install.py +100 -0
  17. pretty_please_llm-0.1.0/pretty_please/adapters/codex/__init__.py +1 -0
  18. pretty_please_llm-0.1.0/pretty_please/adapters/codex/hook.py +77 -0
  19. pretty_please_llm-0.1.0/pretty_please/adapters/codex/install.py +84 -0
  20. pretty_please_llm-0.1.0/pretty_please/adapters/litellm.py +50 -0
  21. pretty_please_llm-0.1.0/pretty_please/adapters/openai.py +67 -0
  22. pretty_please_llm-0.1.0/pretty_please/cli.py +48 -0
  23. pretty_please_llm-0.1.0/pretty_please/core.py +93 -0
  24. pretty_please_llm-0.1.0/pretty_please/py.typed +0 -0
  25. pretty_please_llm-0.1.0/pretty_please/stats.py +103 -0
  26. pretty_please_llm-0.1.0/pyproject.toml +52 -0
  27. pretty_please_llm-0.1.0/tests/test_adapters.py +259 -0
  28. pretty_please_llm-0.1.0/tests/test_cli.py +76 -0
  29. pretty_please_llm-0.1.0/tests/test_core.py +103 -0
  30. pretty_please_llm-0.1.0/tests/test_e2e_sdk.py +212 -0
  31. pretty_please_llm-0.1.0/tests/test_install.py +98 -0
  32. pretty_please_llm-0.1.0/tests/test_stats.py +91 -0
@@ -0,0 +1,46 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Set up Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.12"
18
+
19
+ - name: Install dev deps
20
+ run: pip install -e ".[dev]"
21
+
22
+ - name: ruff check
23
+ run: ruff check .
24
+
25
+ - name: ruff format check
26
+ run: ruff format --check .
27
+
28
+ test:
29
+ runs-on: ubuntu-latest
30
+ strategy:
31
+ matrix:
32
+ python-version: ["3.9", "3.10", "3.11", "3.12"]
33
+
34
+ steps:
35
+ - uses: actions/checkout@v4
36
+
37
+ - name: Set up Python ${{ matrix.python-version }}
38
+ uses: actions/setup-python@v5
39
+ with:
40
+ python-version: ${{ matrix.python-version }}
41
+
42
+ - name: Install package
43
+ run: pip install -e ".[dev]"
44
+
45
+ - name: Run tests with coverage
46
+ run: pytest --cov=pretty_please --cov-report=term-missing
@@ -0,0 +1,43 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Set up Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.12"
18
+
19
+ - name: Build package
20
+ run: pip install build && python -m build
21
+
22
+ - name: Upload dist artifacts
23
+ uses: actions/upload-artifact@v4
24
+ with:
25
+ name: dist
26
+ path: dist/
27
+
28
+ publish:
29
+ needs: build
30
+ runs-on: ubuntu-latest
31
+ environment: pypi
32
+ permissions:
33
+ id-token: write # required for OIDC trusted publisher
34
+
35
+ steps:
36
+ - name: Download dist artifacts
37
+ uses: actions/download-artifact@v4
38
+ with:
39
+ name: dist
40
+ path: dist/
41
+
42
+ - name: Publish to PyPI
43
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1,7 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.4.0
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix]
7
+ - id: ruff-format
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mladen Srdic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,202 @@
1
+ Metadata-Version: 2.4
2
+ Name: pretty-please-llm
3
+ Version: 0.1.0
4
+ Summary: 🙏🏼 Politely injects PLEASE into your LLM prompts. Because manners matter (kind of).
5
+ Project-URL: Homepage, https://github.com/msrdic/pretty-please
6
+ Project-URL: Issues, https://github.com/msrdic/pretty-please/issues
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Keywords: anthropic,llm,openai,politeness,prompt
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Requires-Python: >=3.9
20
+ Provides-Extra: anthropic
21
+ Requires-Dist: anthropic>=0.25; extra == 'anthropic'
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest-cov; extra == 'dev'
24
+ Requires-Dist: pytest>=8.0; extra == 'dev'
25
+ Requires-Dist: ruff>=0.4; extra == 'dev'
26
+ Provides-Extra: litellm
27
+ Requires-Dist: litellm>=1.0; extra == 'litellm'
28
+ Provides-Extra: openai
29
+ Requires-Dist: openai>=1.0; extra == 'openai'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # pretty-please 🙏🏼
33
+
34
+ > Politely injects **PLEASE** into your LLM prompts. Because manners matter (kind of).
35
+
36
+ `pretty-please` is a tiny, zero-dependency Python library that intercepts your prompts before they reach an LLM and gives them a light politeness pass. It works as a drop-in wrapper around the Anthropic and OpenAI SDKs, as a LiteLLM callback, and as a Claude Code `UserPromptSubmit` hook.
37
+
38
+ ```python
39
+ from pretty_please.core import transform
40
+
41
+ transform("List the planets.")
42
+ # → "Please, list the planets."
43
+
44
+ transform("I need help improving this function.")
45
+ # → "I need help improving this function, please."
46
+
47
+ transform("Please could you explain this?")
48
+ # → "Please could you explain this?" (already polite, untouched)
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Does this actually work?
54
+
55
+ **Probably not in the way you'd hope.**
56
+
57
+ Yin et al. (2024) — ["Should We Respect LLMs?"](https://arxiv.org/abs/2402.14531) (arXiv:2402.14531) — found that *rudeness* reliably hurts LLM performance. But the flip side isn't symmetrical: adding *please* showed no consistent improvement on frontier models like GPT-4. The paper's main takeaway is really "avoid being rude," not "be polite and get better answers."
58
+
59
+ `pretty-please` is defensive prompt hygiene, not a performance booster. It won't make Claude smarter. It just stops you from accidentally being rude to a language model, which, per the research, is a real and avoidable own-goal.
60
+
61
+ ---
62
+
63
+ ## Installation
64
+
65
+ ```bash
66
+ pip install pretty-please-llm
67
+ ```
68
+
69
+ With SDK extras:
70
+
71
+ ```bash
72
+ pip install "pretty-please-llm[anthropic]"
73
+ pip install "pretty-please-llm[openai]"
74
+ pip install "pretty-please-llm[litellm]"
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Usage
80
+
81
+ ### Core (no dependencies)
82
+
83
+ ```python
84
+ from pretty_please.core import detect_tone, transform
85
+
86
+ detect_tone("Fix this bug.") # → "curt"
87
+ detect_tone("Could you help me?") # → "polite"
88
+ detect_tone("I need a summary.") # → "neutral"
89
+
90
+ transform("Fix this bug.") # → "Please, fix this bug."
91
+ transform("I need a summary.") # → "I need a summary, please."
92
+ transform("Please help me.") # → "Please help me." (unchanged)
93
+ ```
94
+
95
+ ### Anthropic SDK
96
+
97
+ ```python
98
+ from pretty_please.adapters.anthropic import PrettyAnthropicClient
99
+
100
+ client = PrettyAnthropicClient() # same args as anthropic.Anthropic()
101
+
102
+ response = client.messages.create(
103
+ model="claude-opus-4-6",
104
+ max_tokens=1024,
105
+ messages=[{"role": "user", "content": "Summarize this article."}],
106
+ # ↑ becomes "Please, summarize this article." under the hood
107
+ )
108
+ ```
109
+
110
+ ### OpenAI SDK
111
+
112
+ ```python
113
+ from pretty_please.adapters.openai import PrettyOpenAIClient
114
+
115
+ client = PrettyOpenAIClient() # same args as openai.OpenAI()
116
+
117
+ response = client.chat.completions.create(
118
+ model="gpt-4o",
119
+ messages=[{"role": "user", "content": "Write a haiku about deadlines."}],
120
+ )
121
+ ```
122
+
123
+ ### LiteLLM
124
+
125
+ ```python
126
+ from pretty_please.adapters.litellm import install
127
+ install() # register the callback once at startup
128
+
129
+ import litellm
130
+ response = litellm.completion(
131
+ model="gpt-4o",
132
+ messages=[{"role": "user", "content": "Explain gradient descent."}],
133
+ )
134
+ ```
135
+
136
+ ### Claude Code hook
137
+
138
+ ```bash
139
+ pretty-please install-hook
140
+ ```
141
+
142
+ Writes the hook into `~/.claude/settings.json`. Every prompt you type in Claude Code will be politely transformed before it's sent.
143
+
144
+ > **Note:** the installer records the Python interpreter that ran it (`sys.executable`). If you installed pretty-please into a virtualenv, make sure that virtualenv is active when you run `install-hook`, or the hook will fail when the venv isn't active.
145
+
146
+ Use `--path` to install into a non-default profile directory:
147
+
148
+ ```bash
149
+ pretty-please install-hook --path ~/work/.claude/settings.json
150
+ ```
151
+
152
+ ### Codex CLI hook
153
+
154
+ ```bash
155
+ pretty-please install-hook --codex
156
+ ```
157
+
158
+ Writes the hook into `~/.codex/hooks.json`. Note: Codex hooks can't replace the prompt text directly, so the polite rephrasing is injected as `additionalContext` alongside your original prompt rather than replacing it.
159
+
160
+ ```bash
161
+ pretty-please install-hook --codex --path ~/work/.codex/hooks.json
162
+ ```
163
+
164
+ ### Stats
165
+
166
+ ```bash
167
+ pretty-please stats
168
+ ```
169
+
170
+ ```
171
+ pretty-please stats
172
+ ──────────────────────────────
173
+ Total seen: 142
174
+ Transformed: 89 (63%)
175
+ curt: 41
176
+ neutral: 48
177
+ Passed through: 53 (37%)
178
+ ```
179
+
180
+ ---
181
+
182
+ ## How it works
183
+
184
+ Tone is detected by a small set of rules (no ML, no external deps):
185
+
186
+ | Tone | Signal | Transform |
187
+ |------|--------|-----------|
188
+ | **polite** | contains *please / could / would / kindly / can you* | pass through unchanged |
189
+ | **curt** | short imperative verb, no modal, or profanity/ALL CAPS | prepend `"Please, "` |
190
+ | **neutral** | everything else | append `", please"` |
191
+
192
+ ---
193
+
194
+ ## Contributing
195
+
196
+ This project is a work in progress and contributions are very welcome! Open an issue or PR at [github.com/msrdic/pretty-please](https://github.com/msrdic/pretty-please).
197
+
198
+ ---
199
+
200
+ ## License
201
+
202
+ MIT
@@ -0,0 +1,171 @@
1
+ # pretty-please 🙏🏼
2
+
3
+ > Politely injects **PLEASE** into your LLM prompts. Because manners matter (kind of).
4
+
5
+ `pretty-please` is a tiny, zero-dependency Python library that intercepts your prompts before they reach an LLM and gives them a light politeness pass. It works as a drop-in wrapper around the Anthropic and OpenAI SDKs, as a LiteLLM callback, and as a Claude Code `UserPromptSubmit` hook.
6
+
7
+ ```python
8
+ from pretty_please.core import transform
9
+
10
+ transform("List the planets.")
11
+ # → "Please, list the planets."
12
+
13
+ transform("I need help improving this function.")
14
+ # → "I need help improving this function, please."
15
+
16
+ transform("Please could you explain this?")
17
+ # → "Please could you explain this?" (already polite, untouched)
18
+ ```
19
+
20
+ ---
21
+
22
+ ## Does this actually work?
23
+
24
+ **Probably not in the way you'd hope.**
25
+
26
+ Yin et al. (2024) — ["Should We Respect LLMs?"](https://arxiv.org/abs/2402.14531) (arXiv:2402.14531) — found that *rudeness* reliably hurts LLM performance. But the flip side isn't symmetrical: adding *please* showed no consistent improvement on frontier models like GPT-4. The paper's main takeaway is really "avoid being rude," not "be polite and get better answers."
27
+
28
+ `pretty-please` is defensive prompt hygiene, not a performance booster. It won't make Claude smarter. It just stops you from accidentally being rude to a language model, which, per the research, is a real and avoidable own-goal.
29
+
30
+ ---
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install pretty-please-llm
36
+ ```
37
+
38
+ With SDK extras:
39
+
40
+ ```bash
41
+ pip install "pretty-please-llm[anthropic]"
42
+ pip install "pretty-please-llm[openai]"
43
+ pip install "pretty-please-llm[litellm]"
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Usage
49
+
50
+ ### Core (no dependencies)
51
+
52
+ ```python
53
+ from pretty_please.core import detect_tone, transform
54
+
55
+ detect_tone("Fix this bug.") # → "curt"
56
+ detect_tone("Could you help me?") # → "polite"
57
+ detect_tone("I need a summary.") # → "neutral"
58
+
59
+ transform("Fix this bug.") # → "Please, fix this bug."
60
+ transform("I need a summary.") # → "I need a summary, please."
61
+ transform("Please help me.") # → "Please help me." (unchanged)
62
+ ```
63
+
64
+ ### Anthropic SDK
65
+
66
+ ```python
67
+ from pretty_please.adapters.anthropic import PrettyAnthropicClient
68
+
69
+ client = PrettyAnthropicClient() # same args as anthropic.Anthropic()
70
+
71
+ response = client.messages.create(
72
+ model="claude-opus-4-6",
73
+ max_tokens=1024,
74
+ messages=[{"role": "user", "content": "Summarize this article."}],
75
+ # ↑ becomes "Please, summarize this article." under the hood
76
+ )
77
+ ```
78
+
79
+ ### OpenAI SDK
80
+
81
+ ```python
82
+ from pretty_please.adapters.openai import PrettyOpenAIClient
83
+
84
+ client = PrettyOpenAIClient() # same args as openai.OpenAI()
85
+
86
+ response = client.chat.completions.create(
87
+ model="gpt-4o",
88
+ messages=[{"role": "user", "content": "Write a haiku about deadlines."}],
89
+ )
90
+ ```
91
+
92
+ ### LiteLLM
93
+
94
+ ```python
95
+ from pretty_please.adapters.litellm import install
96
+ install() # register the callback once at startup
97
+
98
+ import litellm
99
+ response = litellm.completion(
100
+ model="gpt-4o",
101
+ messages=[{"role": "user", "content": "Explain gradient descent."}],
102
+ )
103
+ ```
104
+
105
+ ### Claude Code hook
106
+
107
+ ```bash
108
+ pretty-please install-hook
109
+ ```
110
+
111
+ Writes the hook into `~/.claude/settings.json`. Every prompt you type in Claude Code will be politely transformed before it's sent.
112
+
113
+ > **Note:** the installer records the Python interpreter that ran it (`sys.executable`). If you installed pretty-please into a virtualenv, make sure that virtualenv is active when you run `install-hook`, or the hook will fail when the venv isn't active.
114
+
115
+ Use `--path` to install into a non-default profile directory:
116
+
117
+ ```bash
118
+ pretty-please install-hook --path ~/work/.claude/settings.json
119
+ ```
120
+
121
+ ### Codex CLI hook
122
+
123
+ ```bash
124
+ pretty-please install-hook --codex
125
+ ```
126
+
127
+ Writes the hook into `~/.codex/hooks.json`. Note: Codex hooks can't replace the prompt text directly, so the polite rephrasing is injected as `additionalContext` alongside your original prompt rather than replacing it.
128
+
129
+ ```bash
130
+ pretty-please install-hook --codex --path ~/work/.codex/hooks.json
131
+ ```
132
+
133
+ ### Stats
134
+
135
+ ```bash
136
+ pretty-please stats
137
+ ```
138
+
139
+ ```
140
+ pretty-please stats
141
+ ──────────────────────────────
142
+ Total seen: 142
143
+ Transformed: 89 (63%)
144
+ curt: 41
145
+ neutral: 48
146
+ Passed through: 53 (37%)
147
+ ```
148
+
149
+ ---
150
+
151
+ ## How it works
152
+
153
+ Tone is detected by a small set of rules (no ML, no external deps):
154
+
155
+ | Tone | Signal | Transform |
156
+ |------|--------|-----------|
157
+ | **polite** | contains *please / could / would / kindly / can you* | pass through unchanged |
158
+ | **curt** | short imperative verb, no modal, or profanity/ALL CAPS | prepend `"Please, "` |
159
+ | **neutral** | everything else | append `", please"` |
160
+
161
+ ---
162
+
163
+ ## Contributing
164
+
165
+ This project is a work in progress and contributions are very welcome! Open an issue or PR at [github.com/msrdic/pretty-please](https://github.com/msrdic/pretty-please).
166
+
167
+ ---
168
+
169
+ ## License
170
+
171
+ MIT