wenjin272 commented on PR #1383:
URL: https://github.com/apache/flink-agents/pull/1383#issuecomment-6819216639
Thanks for the update! I noticed one small mismatch between the generated
YAML schema and the loader: the schema accepts `content: [{text: "hello"}]`,
but loading it fails because the `type` discriminator is missing. The same
applies to `source.type`.
Could we mark these discriminators as required when exporting the YAML
schema? This would preserve the existing defaults and constructors such as
`TextBlock(text="hello")`, without introducing separate YAML block models.
For example, in `specs.py`:
```python
def export() -> str:
schema = YamlAgentsDocument.model_json_schema()
# YAML parsing requires an explicit discriminator, even though
# direct construction of concrete block/source models has defaults.
for name in (
"TextBlock",
"ImageBlock",
"AudioBlock",
"VideoBlock",
"DocumentBlock",
"UrlSource",
"Base64Source",
):
definition = schema["$defs"][name]
required = definition.setdefault("required", [])
if "type" not in required:
required.append("type")
return json.dumps(schema, indent=2, sort_keys=True) + "\n"
```
Please also regenerate both schema copies, update the manifest’s schema
hash, and add tests verifying that missing block/source discriminators are
rejected by schema validation while valid configurations still pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]