Skip to content

Commit 428feb9

Browse files
Merge pull request #67 from shcherbak-ai/dev
Dev
2 parents 9ca411c + acc01da commit 428feb9

File tree

13 files changed

+194
-28
lines changed

13 files changed

+194
-28
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55

66
- **Refactor**: Code reorganization that doesn't change functionality but improves structure or maintainability
77

8+
## [0.16.1](https://github.com/shcherbak-ai/contextgem/releases/tag/v0.16.1) - 2025-08-19
9+
### Fixed
10+
- Added support for `"minimal"` reasoning effort for gpt-5 models.
11+
812
## [0.16.0](https://github.com/shcherbak-ai/contextgem/releases/tag/v0.16.0) - 2025-08-19
913
### Added
1014
- Reasoning-aware extraction prompts: Automatically enables private chain-of-thought guidance on models that support reasoning, yielding higher-quality outputs (no change for other models).

contextgem/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
ContextGem - Effortless LLM extraction from documents
2121
"""
2222

23-
__version__ = "0.16.0"
23+
__version__ = "0.16.1"
2424
__author__ = "Shcherbak AI AS"
2525

2626
from contextgem.public import (

contextgem/internal/base/llms.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,7 +2832,10 @@ class _DocumentLLM(_GenericLLMProcessor):
28322832
) # for reasoning (CoT-capable) models
28332833
reasoning_effort: ReasoningEffort | None = Field(
28342834
default=None,
2835-
description="Reasoning effort for CoT models: 'low' | 'medium' | 'high'.",
2835+
description=(
2836+
"Reasoning effort for CoT-capable models: 'minimal' (gpt-5 models only) | "
2837+
"'low' | 'medium' | 'high'."
2838+
),
28362839
) # for reasoning (CoT-capable) models
28372840
num_retries_failed_request: StrictInt = Field(
28382841
default=3,
@@ -3000,6 +3003,15 @@ def _post_init(self, __context: Any):
30003003
stacklevel=2,
30013004
)
30023005

3006+
# "minimal" reasoning effort is supported only for gpt-5 models
3007+
if self.reasoning_effort == "minimal" and not (
3008+
self.model.startswith("azure/gpt-5")
3009+
or self.model.startswith("openai/gpt-5")
3010+
):
3011+
raise ValueError(
3012+
"`reasoning_effort='minimal'` is supported only for gpt-5 models."
3013+
)
3014+
30033015
def _set_private_attrs(self) -> None:
30043016
"""
30053017
Initialize and configure private attributes for the LLM instance.
@@ -3457,12 +3469,14 @@ def _validate_document_llm_post(self) -> Self:
34573469
stacklevel=2,
34583470
)
34593471

3460-
# Extractor role with reasoning-capable model - suggest using a reasoner role
3472+
# Extractor role with reasoning-capable model - suggest aligning role for routing clarity
34613473
if self.role.startswith("extractor") and self._supports_reasoning:
34623474
warnings.warn(
34633475
f"Model `{self.model}` is assigned extractor role `{self.role}`, "
3464-
f"while the model is reasoning-capable. Consider using a reasoner role "
3465-
f"to enable reasoning-related instructions for higher quality responses.",
3476+
f"while the model is reasoning-capable. If you intend to route reasoning tasks "
3477+
f"to this model, consider using a `reasoner_*` role to match aspect/concept `llm_role` "
3478+
f"and keep pipeline roles consistent. See "
3479+
f"https://contextgem.dev/optimizations/optimization_choosing_llm.html",
34663480
stacklevel=2,
34673481
)
34683482

contextgem/internal/typings/aliases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@
8484
default_factory=lambda: Decimal("0.00000"), ge=Decimal("0.00000")
8585
)
8686

87-
ReasoningEffort = Literal["low", "medium", "high"]
87+
ReasoningEffort = Literal["minimal", "low", "medium", "high"]
8888

8989
TextMode = Literal["raw", "markdown"]

contextgem/public/llms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ class DocumentLLM(_DocumentLLM):
102102
(CoT-capable) models. Defaults to 16000.
103103
:vartype max_completion_tokens: int
104104
:ivar reasoning_effort: The effort level for the LLM to reason about the input. Can be set to
105-
``"low"``, ``"medium"``, or ``"high"``. Relevant for reasoning (CoT-capable) models.
106-
Defaults to None.
105+
``"minimal"`` (gpt-5 models only), ``"low"``, ``"medium"``, or ``"high"``.
106+
Relevant for reasoning (CoT-capable) models. Defaults to None.
107107
:vartype reasoning_effort: ReasoningEffort | None
108108
:ivar top_p: Nucleus sampling value (0.0 to 1.0) controlling output focus/randomness.
109109
Lower values make output more deterministic, higher values produce more diverse outputs.

dev/usage_examples/docs/llm_config/o1_o4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
model="openai/o3-mini",
66
api_key="<your-openai-api-key>",
77
max_completion_tokens=8000, # Specific to reasoning (CoT-capable) models
8-
reasoning_effort="medium", # Optional: "low", "medium", "high"
8+
reasoning_effort="medium", # Optional
99
)

docs/docs-raw-for-llm.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8763,7 +8763,8 @@ The "DocumentLLM" class accepts the following parameters:
87638763
| ens" | | | (CoT-capable) models. |
87648764
+----------------------+-----------------+-----------------+----------------------------------------------------+
87658765
| "reasoning_effort" | "str | None" | "None" | Reasoning effort for reasoning (CoT-capable) |
8766-
| | | | models. Values: ""low"", ""medium"", ""high"". |
8766+
| | | | models. Values: ""minimal"" (gpt-5 models only), |
8767+
| | | | ""low"", ""medium"", ""high"". |
87678768
+----------------------+-----------------+-----------------+----------------------------------------------------+
87688769
| "timeout" | "int" | "120" | Timeout in seconds for LLM API calls. |
87698770
+----------------------+-----------------+-----------------+----------------------------------------------------+
@@ -8935,7 +8936,7 @@ Using model-specific parameters
89358936
model="openai/o3-mini",
89368937
api_key="<your-openai-api-key>",
89378938
max_completion_tokens=8000, # Specific to reasoning (CoT-capable) models
8938-
reasoning_effort="medium", # Optional: "low", "medium", "high"
8939+
reasoning_effort="medium", # Optional
89398940
)
89408941

89418942

@@ -15967,8 +15968,9 @@ class contextgem.public.llms.DocumentLLM(**data)
1596715968

1596815969
* **reasoning_effort** (*ReasoningEffort** | **None*) -- The
1596915970
effort level for the LLM to reason about the input. Can be set
15970-
to ""low"", ""medium"", or ""high"". Relevant for reasoning
15971-
(CoT-capable) models. Defaults to None.
15971+
to ""minimal"" (gpt-5 models only), ""low"", ""medium"", or
15972+
""high"". Relevant for reasoning (CoT-capable) models.
15973+
Defaults to None.
1597215974

1597315975
* **top_p** (*float** | **None*) -- Nucleus sampling value (0.0
1597415976
to 1.0) controlling output focus/randomness. Lower values make
@@ -16072,8 +16074,8 @@ class contextgem.public.llms.DocumentLLM(**data)
1607216074
* **max_completion_tokens** (*Annotated**[**int**,
1607316075
**Strict**(**strict=True**)**]*)
1607416076

16075-
* **reasoning_effort** (*Literal**[**'low'**, **'medium'**,
16076-
**'high'**] **| **None*)
16077+
* **reasoning_effort** (*Literal**[**'minimal'**, **'low'**,
16078+
**'medium'**, **'high'**] **| **None*)
1607716079

1607816080
* **num_retries_failed_request** (*Annotated**[**int**,
1607916081
**Strict**(**strict=True**)**]*)

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
project = "ContextGem"
2626
copyright = "2025, Shcherbak AI AS"
2727
author = "Sergii Shcherbak"
28-
release = "0.16.0"
28+
release = "0.16.1"
2929

3030

3131
# Add path to the package

docs/source/llms/llm_config.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ The :class:`~contextgem.public.llms.DocumentLLM` class accepts the following par
102102
* - ``reasoning_effort``
103103
- ``str | None``
104104
- ``None``
105-
- Reasoning effort for reasoning (CoT-capable) models. Values: ``"low"``, ``"medium"``, ``"high"``.
105+
- Reasoning effort for reasoning (CoT-capable) models. Values: ``"minimal"`` (gpt-5 models only), ``"low"``, ``"medium"``, ``"high"``.
106106
* - ``timeout``
107107
- ``int``
108108
- ``120``

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "contextgem"
3-
version = "0.16.0"
3+
version = "0.16.1"
44
description = "Effortless LLM extraction from documents"
55
authors = [{ name = "shcherbak-ai", email = "[email protected]" }]
66
requires-python = ">=3.10,<3.14"

0 commit comments

Comments
 (0)