Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Changed

- (**breaking**) `AnthropicLLM.supports_structured_output` is now `True`. As a result, `SchemaFromTextExtractor` and `LLMEntityRelationExtractor` (and `SimpleKGPipeline`, which enables structured output automatically when the LLM supports it) now use structured output by default with `AnthropicLLM`. This requires a Claude 4.5+ model (e.g. `claude-sonnet-4-5`); using `AnthropicLLM` with an older Claude model in these components will now raise an error where it previously worked. To keep the previous behavior, use a Claude 4.5+ model, or construct `LLMEntityRelationExtractor` / `SchemaFromTextExtractor` directly with `use_structured_output=False`.
- (**breaking**) `GeminiLLM.supports_structured_output` is now `True`. `GeminiLLM` already implemented structured-output handling via `response_schema`/`response_mime_type` but never declared the capability flag, so components gating on it saw `False`. As a result, `SchemaFromTextExtractor` and `LLMEntityRelationExtractor` (and `SimpleKGPipeline`, which enables structured output automatically when the LLM supports it) now use structured output by default with `GeminiLLM`. To keep the previous behavior, construct `LLMEntityRelationExtractor` / `SchemaFromTextExtractor` directly with `use_structured_output=False`.

## 1.18.0

Expand Down
2 changes: 2 additions & 0 deletions src/neo4j_graphrag/llm/google_genai_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class GeminiLLM(LLMInterface, LLMInterfaceV2):
**kwargs (Any): Arguments passed to the genai.Client.
"""

supports_structured_output: bool = True

def __init__(
self,
model_name: str = "gemini-2.0-flash",
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/llm/test_google_genai_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,12 @@ def test_gemini_invoke_error(mock_genai: Tuple[MagicMock, MagicMock]) -> None:
llm = GeminiLLM("gemini-2.0-flash")
with pytest.raises(LLMGenerationError):
llm.invoke("hello")


def test_gemini_llm_supports_structured_output(
mock_genai: Tuple[MagicMock, MagicMock],
) -> None:
"""GeminiLLM implements structured output (response_schema/response_mime_type),
so it must declare the capability flag components gate on."""
llm = GeminiLLM("gemini-2.0-flash")
assert llm.supports_structured_output is True
Loading