def get_typed_kwargs_from_simple_json_schema(
simple_json_schema: dict | str
) -> TypedKwargs:
if isinstance(simple_json_schema, str):
simple_json_schema = json.loads(simple_json_schema)
typed_kwargs_dict = {}
try:
for name, type_ in simple_json_schema.items():
if isinstance(type_, str):
typed_kwargs_dict[name] = TYPE_STRING_TO_ANNOTATION_MAP[type_.lower()]
if isinstance(type_, dict):
for type_1, type_2 in type_.items():
typed_kwargs_dict[name] = dict[
TYPE_STRING_TO_ANNOTATION_MAP[type_1.lower()],
TYPE_STRING_TO_ANNOTATION_MAP[type_2.lower()]
]
break
if isinstance(type_, list):
if len(type_) > 0:
typed_kwargs_dict[name] = list[
TYPE_STRING_TO_ANNOTATION_MAP[type_[0]]
]
else:
typed_kwargs_dict[name] = list
except KeyError:
message = f'Type {simple_json_schema_str} is not recognized'
raise TypingRecoverableException(message)
return TypedKwargs(typed_kwargs_dict)