Skip to content

Commit 00db3b0

Browse files
committed
docs: Add documents for AI configs
1 parent 151d3dd commit 00db3b0

5 files changed

Lines changed: 150 additions & 1 deletion

File tree

django_email_learning/ai/language_models.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,36 @@
44

55

66
class LanguageModel(Enum):
7+
"""Supported AI text-editing models.
8+
9+
Each enum value maps to:
10+
11+
- ``model_name``: The provider model identifier sent to the AI API.
12+
- ``adapter_class``: The adapter that knows how to call that provider.
13+
14+
The project currently ships with OpenAI-backed models only.
15+
16+
.. note::
17+
These models are used when
18+
``DJANGO_EMAIL_LEARNING['AI']['TEXT_EDITING_MODEL']`` is configured.
19+
AI configuration is optional and only required when using AI editing
20+
features.
21+
"""
22+
723
GPT_4O_MINI = ("gpt-4o-mini", OpenAiAdapter)
24+
"""OpenAI GPT-4o mini model (balanced quality and speed)."""
25+
826
GPT_5_NANO = ("gpt-5-nano", OpenAiAdapter)
27+
"""OpenAI GPT-5 nano model (smallest and fastest GPT-5 variant)."""
28+
929
GPT_5_MINI = ("gpt-5-mini", OpenAiAdapter)
30+
"""OpenAI GPT-5 mini model (higher quality than nano, still efficient)."""
1031

1132
def __init__(self, model_name: str, adapter_class: type[AiServiceProtocol]) -> None:
33+
"""Attach provider metadata to each model enum value.
34+
35+
:param model_name: External model name used by the AI provider API.
36+
:param adapter_class: Adapter implementing :class:`AiServiceProtocol`.
37+
"""
1238
self.model_name = model_name
1339
self.adapter_class = adapter_class

docs/source/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
# -- General configuration ---------------------------------------------------
1414
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
1515

16-
extensions = ["sphinxcontrib.googleanalytics"]
16+
extensions = [
17+
"sphinx.ext.autodoc",
18+
"sphinxcontrib.googleanalytics",
19+
]
1720

1821
googleanalytics_id = "G-67JHEC135G"
1922
googleanalytics_enabled = True

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Django Email Learning documentation
2828
:maxdepth: 2
2929
:caption: Technical Reference
3030

31+
technical/ai-configuration
3132
technical/management-commands
3233

3334

docs/source/installation.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ Installation Steps
2626
2727
pip install django-email-learning
2828
29+
If you want to use AI editing tools, install with the AI optional extra:
30+
31+
.. code-block:: bash
32+
33+
pip install 'django-email-learning[ai]'
34+
2935
2. **Add to INSTALLED_APPS**
3036

3137
Add 'django_email_learning' to your INSTALLED_APPS in settings.py:
@@ -181,6 +187,50 @@ Optional configuration for branding assets in the platform header.
181187
},
182188
}
183189
190+
**AI**
191+
192+
Optional configuration for AI-powered text editing features.
193+
194+
- Configure this only if you have an OpenAI account and want to use AI edit tools.
195+
- If you do not use AI features, you can omit ``AI`` entirely.
196+
- Install AI dependencies with ``pip install 'django-email-learning[ai]'``.
197+
- Add ``'django_email_learning.ai'`` to ``INSTALLED_APPS`` when using AI tools.
198+
199+
.. code-block:: python
200+
201+
INSTALLED_APPS = [
202+
# ... your other apps
203+
'django_email_learning',
204+
'django_email_learning.ai',
205+
# ... more apps
206+
]
207+
208+
Available keys:
209+
210+
- ``OPENAI_API_KEY``: OpenAI API key used for AI requests.
211+
- ``TEXT_EDITING_MODEL``: OpenAI model name used by text editing.
212+
213+
Currently supported built-in models are:
214+
215+
- ``gpt-4o-mini``
216+
- ``gpt-5-nano``
217+
- ``gpt-5-mini``
218+
219+
.. code-block:: python
220+
221+
from django_email_learning.ai.language_models import LanguageModel
222+
223+
DJANGO_EMAIL_LEARNING = {
224+
'SITE_BASE_URL': 'https://yourdomain.com',
225+
'ENCRYPTION_SECRET_KEY': 'your-very-long-random-string',
226+
'AI': {
227+
'OPENAI_API_KEY': os.environ.get('OPENAI_API_KEY'),
228+
'TEXT_EDITING_MODEL': LanguageModel.GPT_4O_MINI.model_name,
229+
},
230+
}
231+
232+
See `AI Configuration <technical/ai-configuration.html>`_ for full details.
233+
184234
Email Backend Configuration
185235
---------------------------
186236

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
AI Configuration
2+
================
3+
4+
Django Email Learning supports optional AI-powered text editing features.
5+
6+
If you do not use AI editing tools, you can omit the ``AI`` section entirely.
7+
8+
Prerequisites
9+
-------------
10+
11+
Before configuring AI settings, install the AI optional dependencies:
12+
13+
.. code-block:: bash
14+
15+
pip install 'django-email-learning[ai]'
16+
17+
Then include the AI app in ``INSTALLED_APPS``:
18+
19+
.. code-block:: python
20+
21+
INSTALLED_APPS = [
22+
# ... your other apps
23+
'django_email_learning',
24+
'django_email_learning.ai',
25+
# ... more apps
26+
]
27+
28+
Settings
29+
--------
30+
31+
Configure AI under ``DJANGO_EMAIL_LEARNING['AI']`` in your Django ``settings.py``.
32+
33+
.. code-block:: python
34+
35+
from django_email_learning.ai.language_models import LanguageModel
36+
37+
DJANGO_EMAIL_LEARNING = {
38+
'SITE_BASE_URL': 'https://yourdomain.com',
39+
'ENCRYPTION_SECRET_KEY': 'your-very-long-random-string',
40+
'AI': {
41+
'OPENAI_API_KEY': os.environ.get('OPENAI_API_KEY'),
42+
'TEXT_EDITING_MODEL': LanguageModel.GPT_4O_MINI.model_name,
43+
},
44+
}
45+
46+
``OPENAI_API_KEY``
47+
~~~~~~~~~~~~~~~~~~
48+
49+
API key used for OpenAI requests.
50+
51+
- Required only when you want to use AI editing features.
52+
- Keep this value in environment variables or a secure secret manager.
53+
54+
``TEXT_EDITING_MODEL``
55+
~~~~~~~~~~~~~~~~~~~~~~
56+
57+
Model name used by AI text editing features.
58+
59+
- Value should match one of the names exposed by ``LanguageModel``.
60+
- Defaults can be set in your own project settings.
61+
62+
Available Models
63+
----------------
64+
65+
The package currently provides OpenAI-backed models:
66+
67+
- ``gpt-4o-mini``
68+
- ``gpt-5-nano``
69+
- ``gpt-5-mini``

0 commit comments

Comments
 (0)