mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-13 04:22:35 +00:00
fix: Pydantic v2 discriminated union default handling
Remove invalid default parameters from KVStoreConfig and SqlStoreConfig Annotated types which were causing UnsupportedFieldAttributeWarning and producing incorrect string values instead of proper config objects. Add proper default_factory to all KVStoreConfig and SqlStoreConfig fields across core datatypes and provider configs, ensuring they instantiate SqliteKVStoreConfig or SqliteSqlStoreConfig objects with correct defaults. This improves usability by allowing configs to be instantiated without explicitly providing storage configuration while maintaining type safety and discriminated union functionality. Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
parent
359df3a37c
commit
7605631df7
37 changed files with 56 additions and 52 deletions
|
|
@ -10,8 +10,6 @@ from typing import Annotated, Literal
|
|||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
from llama_stack.core.utils.config_dirs import RUNTIME_BASE_DIR
|
||||
|
||||
|
||||
class KVStoreType(Enum):
|
||||
redis = "redis"
|
||||
|
|
@ -52,7 +50,7 @@ class RedisKVStoreConfig(CommonConfig):
|
|||
class SqliteKVStoreConfig(CommonConfig):
|
||||
type: Literal["sqlite"] = KVStoreType.sqlite.value
|
||||
db_path: str = Field(
|
||||
default=(RUNTIME_BASE_DIR / "kvstore.db").as_posix(),
|
||||
default="~/.llama/runtime/kvstore.db",
|
||||
description="File path for the sqlite database",
|
||||
)
|
||||
|
||||
|
|
@ -140,7 +138,7 @@ class MongoDBKVStoreConfig(CommonConfig):
|
|||
|
||||
KVStoreConfig = Annotated[
|
||||
RedisKVStoreConfig | SqliteKVStoreConfig | PostgresKVStoreConfig | MongoDBKVStoreConfig,
|
||||
Field(discriminator="type", default=KVStoreType.sqlite.value),
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue