mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-06 02:32:40 +00:00
fix: raise error when request param failed to convert
# What does this PR do? similar to #1339 ## Test Plan LLAMA_STACK_CONFIG=dev pytest -s -v tests/integration/ --safety-shield meta-llama/Llama-Guard-3-8B --text-model accounts/fireworks/models/llama-v3p1-8b-instruct
This commit is contained in:
parent
39e094736f
commit
4da4ee6411
1 changed files with 5 additions and 7 deletions
|
@ -83,17 +83,15 @@ def convert_to_pydantic(annotation: Any, value: Any) -> Any:
|
|||
item_type = get_args(annotation)[0]
|
||||
try:
|
||||
return [convert_to_pydantic(item_type, item) for item in value]
|
||||
except Exception:
|
||||
logger.error(f"Error converting list {value} into {item_type}")
|
||||
return value
|
||||
except Exception as e:
|
||||
raise ValueError(f"Failed to convert list {value} into {item_type}: {e}") from e
|
||||
|
||||
elif origin is dict:
|
||||
key_type, val_type = get_args(annotation)
|
||||
val_type = get_args(annotation)
|
||||
try:
|
||||
return {k: convert_to_pydantic(val_type, v) for k, v in value.items()}
|
||||
except Exception:
|
||||
logger.error(f"Error converting dict {value} into {val_type}")
|
||||
return value
|
||||
except Exception as e:
|
||||
raise ValueError(f"Failed to convert dict {value} into {val_type}: {e}") from e
|
||||
|
||||
try:
|
||||
# Handle Pydantic models and discriminated unions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue