Changes in symbol.py
Adopted changes from embedding.py
This commit is contained in:
1 parent
edeaf3aae9
commit
01ace5b7cc
1 file changed
+12
-1
@@ -40,7 +40,7 @@ class Symbol:
|
||||
return cls.from_dict(value)
|
||||
raise ValueError(f"Cannot convert {type(value)} to Symbol")
|
||||
|
||||
return core_schema.with_info_plain_validator_function(
|
||||
python_schema = core_schema.with_info_plain_validator_function(
|
||||
lambda value, _: validate_symbol(value),
|
||||
serialization=core_schema.plain_serializer_function_ser_schema(
|
||||
lambda x: {
|
||||
@@ -53,3 +53,14 @@ class Symbol:
|
||||
when_used="json",
|
||||
),
|
||||
)
|
||||
|
||||
return core_schema.json_or_python_schema(
|
||||
json_schema=core_schema.typed_dict_schema(
|
||||
{
|
||||
"id": core_schema.typed_dict_field(core_schema.int_schema()),
|
||||
"label": core_schema.typed_dict_field(core_schema.str_schema()),
|
||||
"image": core_schema.typed_dict_field(core_schema.str_schema()),
|
||||
}
|
||||
),
|
||||
python_schema=python_schema,
|
||||
)
|
||||
Reference in new issue
Block a user