mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-31 03:23:53 +00:00
feat(api): define a more coherent jobs api across different flows
Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
This commit is contained in:
parent
71ed47ea76
commit
0f50cfa561
15 changed files with 1864 additions and 1670 deletions
|
|
@ -562,6 +562,15 @@ else:
|
|||
return typing.get_type_hints(typ)
|
||||
|
||||
|
||||
def get_computed_fields(typ: type) -> dict[str, type]:
|
||||
"Returns all computed fields of a class."
|
||||
pydantic_decorators = getattr(typ, "__pydantic_decorators__", None)
|
||||
if not pydantic_decorators:
|
||||
return {}
|
||||
computed_fields = pydantic_decorators.computed_fields
|
||||
return {field_name: decorator.info.return_type for field_name, decorator in computed_fields.items()}
|
||||
|
||||
|
||||
def get_class_properties(typ: type) -> Iterable[Tuple[str, type | str]]:
|
||||
"Returns all properties of a class."
|
||||
|
||||
|
|
@ -569,7 +578,8 @@ def get_class_properties(typ: type) -> Iterable[Tuple[str, type | str]]:
|
|||
return ((field.name, field.type) for field in dataclasses.fields(typ))
|
||||
else:
|
||||
resolved_hints = get_resolved_hints(typ)
|
||||
return resolved_hints.items()
|
||||
computed_fields = get_computed_fields(typ)
|
||||
return (resolved_hints | computed_fields).items()
|
||||
|
||||
|
||||
def get_class_property(typ: type, name: str) -> Optional[type | str]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue