mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-04 04:04:14 +00:00
feat(files): fix expires_after API shape (#3604)
This was just quite incorrect. See source here: https://platform.openai.com/docs/api-reference/files/create
This commit is contained in:
parent
5e7fed8bbb
commit
3a09f00cdb
9 changed files with 705 additions and 448 deletions
|
@ -567,6 +567,22 @@ def get_class_properties(typ: type) -> Iterable[Tuple[str, type | str]]:
|
|||
|
||||
if is_dataclass_type(typ):
|
||||
return ((field.name, field.type) for field in dataclasses.fields(typ))
|
||||
elif hasattr(typ, "model_fields"):
|
||||
# Pydantic BaseModel - use model_fields to exclude ClassVar and other non-field attributes
|
||||
# Reconstruct Annotated type if discriminator exists to preserve metadata
|
||||
from typing import Annotated, Any, cast
|
||||
from pydantic.fields import FieldInfo
|
||||
|
||||
def get_field_type(name: str, field: Any) -> type | str:
|
||||
# If field has discriminator, wrap in Annotated to preserve it for schema generation
|
||||
if field.discriminator:
|
||||
field_info = FieldInfo(annotation=None, discriminator=field.discriminator)
|
||||
# Annotated returns _AnnotatedAlias which isn't a type but is valid here
|
||||
return Annotated[field.annotation, field_info] # type: ignore[return-value]
|
||||
# field.annotation can be Union types, Annotated, etc. which aren't type but are valid
|
||||
return field.annotation # type: ignore[return-value,no-any-return]
|
||||
|
||||
return ((name, get_field_type(name, field)) for name, field in typ.model_fields.items())
|
||||
else:
|
||||
resolved_hints = get_resolved_hints(typ)
|
||||
return resolved_hints.items()
|
||||
|
|
|
@ -92,7 +92,12 @@ def get_class_property_docstrings(
|
|||
:returns: A dictionary mapping property names to descriptions.
|
||||
"""
|
||||
|
||||
result = {}
|
||||
result: Dict[str, str] = {}
|
||||
# Only try to get MRO if data_type is actually a class
|
||||
# Special types like Literal, Union, etc. don't have MRO
|
||||
if not inspect.isclass(data_type):
|
||||
return result
|
||||
|
||||
for base in inspect.getmro(data_type):
|
||||
docstr = docstring.parse_type(base)
|
||||
for param in docstr.params.values():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue