feat: Add extraction of default and descriptions for fields in Pydantic models#44
feat: Add extraction of default and descriptions for fields in Pydantic models#44Mahhheshh (Mahhheshh) wants to merge 1 commit intobraintrustdata:mainfrom
Conversation
Abhijeet Prasad (AbhiPrasad)
left a comment
There was a problem hiding this comment.
a single Pydantic model can have multiple fields. I'm not sure if you should keep metadata per field under schema.properties or flatten into multiple eval params. Can you try both and see what it looks like in the UI?
|
Also I finally fixed CI for fork PRs. Mind rebasing this PR? |
e5a97bc to
275d3d1
Compare
|
Apologies for the delay; The description and defaults are now an array of key-value pairs, I’m not great at UI, but the frontend could check if it’s a string; if it is, it could display as it did previously. If it's an array, perhaps under the EvalParams, we could have a also it would be great to hear from the PM/designers before merging this in. and; AI helped me with tests |
275d3d1 to
f87ba31
Compare
|
let me do some UI tests with this and adjust stuff accordingly. |
| raise ValueError(f"Cannot convert {model} to JSON schema - not a pydantic model") | ||
|
|
||
|
|
||
| def _extract_pydantic_fields(schema: dict[str, dict[str, Any]]) -> tuple[Any, Any] | tuple[dict[str, Any], dict[str, Any]]: |
There was a problem hiding this comment.
Returns scalar value if the model has single field, if has multiple fields then flattens the values in dicts.
compatible with validate_parameters()

fixes #31
Adds:
_extract_pydantic_fieldsmethod inpy/src/braintrustdata/parameters.pyfile.Question:
I should have asked this before; will there be multiple Pydantic fields for a Single Model? How do we need to handle that.
closure:
AI helped me with the tests