Skip to content

Commit bbf50ce

Browse files
Revert "Strip unsupported schema fields (#501)" (#502)
This reverts commit 07df667.
1 parent 07df667 commit bbf50ce

File tree

2 files changed

+1
-31
lines changed

2 files changed

+1
-31
lines changed

CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77
- MarkdownLoader (experimental): added a Markdown loader to support `.md` and `.markdown` files.
88

9-
### Fixed
10-
11-
- `VertexAILLM`: passing a Pydantic model with `extra="forbid"` as `response_format` no longer raises a `ParseError`. Unsupported JSON Schema fields (e.g. `additionalProperties`) are now stripped before the schema is forwarded to VertexAI's protobuf `Schema` type.
12-
139
### Changed
1410

1511
- SimpleKG pipeline (experimental): the `from_pdf` parameter is deprecated in favor of `from_file` (PDF and Markdown inputs). `from_pdf` still works but emits a deprecation warning and will be removed in a future version.

src/neo4j_graphrag/llm/vertexai_llm.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,6 @@
6969
_GENERATION_CONFIG_SCHEMA_PARAMS = {"response_schema", "response_mime_type"}
7070

7171

72-
def _strip_unsupported_schema_fields(schema: dict[str, Any]) -> dict[str, Any]:
73-
"""Recursively remove JSON Schema fields not supported by VertexAI's Schema proto.
74-
75-
For example, Pydantic adds ``additionalProperties: false`` when a model uses
76-
``extra="forbid"``, but the VertexAI protobuf Schema type does not have that
77-
field and raises a ``ParseError`` when it encounters it.
78-
"""
79-
_UNSUPPORTED = {"additionalProperties", "$defs", "$schema"}
80-
result = {k: v for k, v in schema.items() if k not in _UNSUPPORTED}
81-
if "properties" in result and isinstance(result["properties"], dict):
82-
result["properties"] = {
83-
k: _strip_unsupported_schema_fields(v)
84-
for k, v in result["properties"].items()
85-
}
86-
if "items" in result and isinstance(result["items"], dict):
87-
result["items"] = _strip_unsupported_schema_fields(result["items"])
88-
if "anyOf" in result and isinstance(result["anyOf"], list):
89-
result["anyOf"] = [
90-
_strip_unsupported_schema_fields(s) if isinstance(s, dict) else s
91-
for s in result["anyOf"]
92-
]
93-
return result
94-
95-
9672
def _extract_generation_config_params(
9773
config: Any, exclude_schema: bool = True
9874
) -> dict[str, Any]:
@@ -598,9 +574,7 @@ def _get_call_params_v2(
598574
response_format, BaseModel
599575
):
600576
# if we migrate to new google-genai-sdk, Pydantic models can be passed directly
601-
schema = _strip_unsupported_schema_fields(
602-
response_format.model_json_schema()
603-
)
577+
schema = response_format.model_json_schema()
604578
else:
605579
schema = response_format
606580
params["response_mime_type"] = "application/json"

0 commit comments

Comments
 (0)