Skip to content

feat(llm): GeminiLLM declares supports_structured_output = True - #622

Closed
matteomedioli wants to merge 1 commit into
mainfrom
matteo/gemini-supports-structured-output
Closed

feat(llm): GeminiLLM declares supports_structured_output = True#622
matteomedioli wants to merge 1 commit into
mainfrom
matteo/gemini-supports-structured-output

Conversation

@matteomedioli

@matteomedioli matteomedioli commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What & Why

GeminiLLM already supports structured output via response_schema/response_mime_type, but never declared the supports_structured_output capability flag. Pipeline components that check the flag (SimpleKGPipeline, SchemaFromTextExtractor, LLMEntityRelationExtractor) saw False and silently fell back to prompt-based JSON instead of schema-enforced structured output.

Reimplements the intent of #573 (closed without merging, and now badly stale — 193 files of drift) fresh on current main.

Breaking for pipeline users: the components above now enable structured output by default with GeminiLLM. To keep the previous behavior, construct them with use_structured_output=False. Same shape as the existing AnthropicLLM.supports_structured_output breaking-change entry in 1.19.0's CHANGELOG.

How

  • Set supports_structured_output: bool = True on BaseGeminiLLM (same place BaseVertexAILLM/AnthropicLLM declare it).
  • Added a regression test and a CHANGELOG entry.

Testing

uv run pytest tests/unit/ -q --ignore=tests/unit/llm/test_mistralai_llm.py

1329 passed — no fallout from the flag flip elsewhere in the suite. mypy/ruff clean.

@matteomedioli
matteomedioli marked this pull request as ready for review September 9, 2026 08:57
@matteomedioli
matteomedioli requested a review from a team as a code owner September 9, 2026 08:57
GeminiLLM already supports structured output via response_schema/
response_mime_type, but never declared the capability flag — pipeline
components checking it fell back to prompt-based JSON.

Breaking: SimpleKGPipeline, SchemaFromTextExtractor, and
LLMEntityRelationExtractor now enable structured output by default with
GeminiLLM. Use use_structured_output=False to keep the previous behavior.

Reimplements the intent of #573 (closed, badly stale) fresh on current
main. Independent of #572/#621 — different concern, no conflict.

@AmirLayegh AmirLayegh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! 🚀

@matteomedioli
matteomedioli force-pushed the matteo/gemini-supports-structured-output branch from 715eede to 8ac30ec Compare September 9, 2026 11:15
capability flag must say so, or SimpleKGPipeline/SchemaFromTextExtractor/
LLMEntityRelationExtractor silently fall back to prompt-based JSON."""
llm = GeminiLLM("gemini-2.0-flash")
assert llm.supports_structured_output is True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the most LLM test ever... set a default... test the default is default :D

@matteomedioli

Copy link
Copy Markdown
Contributor Author

postponed for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants