Skip to content

Commit 55338be

Browse files
committed
docs: Add documents for AI configs
1 parent 151d3dd commit 55338be

5 files changed

Lines changed: 123 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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,39 @@ Optional configuration for branding assets in the platform header.
181181
},
182182
}
183183
184+
**AI**
185+
186+
Optional configuration for AI-powered text editing features.
187+
188+
- Configure this only if you have an OpenAI account and want to use AI edit tools.
189+
- If you do not use AI features, you can omit ``AI`` entirely.
190+
191+
Available keys:
192+
193+
- ``OPENAI_API_KEY``: OpenAI API key used for AI requests.
194+
- ``TEXT_EDITING_MODEL``: OpenAI model name used by text editing.
195+
196+
Currently supported built-in models are:
197+
198+
- ``gpt-4o-mini``
199+
- ``gpt-5-nano``
200+
- ``gpt-5-mini``
201+
202+
.. code-block:: python
203+
204+
from django_email_learning.ai.language_models import LanguageModel
205+
206+
DJANGO_EMAIL_LEARNING = {
207+
'SITE_BASE_URL': 'https://yourdomain.com',
208+
'ENCRYPTION_SECRET_KEY': 'your-very-long-random-string',
209+
'AI': {
210+
'OPENAI_API_KEY': os.environ.get('OPENAI_API_KEY'),
211+
'TEXT_EDITING_MODEL': LanguageModel.GPT_4O_MINI.model_name,
212+
},
213+
}
214+
215+
See `AI Configuration <technical/ai-configuration.html>`_ for full details.
216+
184217
Email Backend Configuration
185218
---------------------------
186219

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
Settings
9+
--------
10+
11+
Configure AI under ``DJANGO_EMAIL_LEARNING['AI']`` in your Django ``settings.py``.
12+
13+
.. code-block:: python
14+
15+
from django_email_learning.ai.language_models import LanguageModel
16+
17+
DJANGO_EMAIL_LEARNING = {
18+
'SITE_BASE_URL': 'https://yourdomain.com',
19+
'ENCRYPTION_SECRET_KEY': 'your-very-long-random-string',
20+
'AI': {
21+
'OPENAI_API_KEY': os.environ.get('OPENAI_API_KEY'),
22+
'TEXT_EDITING_MODEL': LanguageModel.GPT_4O_MINI.model_name,
23+
},
24+
}
25+
26+
``OPENAI_API_KEY``
27+
~~~~~~~~~~~~~~~~~~
28+
29+
API key used for OpenAI requests.
30+
31+
- Required only when you want to use AI editing features.
32+
- Keep this value in environment variables or a secure secret manager.
33+
34+
``TEXT_EDITING_MODEL``
35+
~~~~~~~~~~~~~~~~~~~~~~
36+
37+
Model name used by AI text editing features.
38+
39+
- Value should match one of the names exposed by ``LanguageModel``.
40+
- Defaults can be set in your own project settings.
41+
42+
Available Models
43+
----------------
44+
45+
The package currently provides OpenAI-backed models:
46+
47+
- ``gpt-4o-mini``
48+
- ``gpt-5-nano``
49+
- ``gpt-5-mini``
50+
51+
Python API Reference
52+
--------------------
53+
54+
The ``LanguageModel`` enum is documented from source docstrings:
55+
56+
.. automodule:: django_email_learning.ai.language_models
57+
:members:
58+
:undoc-members:
59+
:show-inheritance:

0 commit comments

Comments
 (0)