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:
Charlie Doern 2025-10-20 14:03:33 -04:00
parent 359df3a37c
commit 7605631df7
37 changed files with 56 additions and 52 deletions

View file

@ -5,7 +5,7 @@
# the root directory of this source tree.
from typing import Any
from pydantic import BaseModel
from pydantic import BaseModel, Field
from llama_stack.providers.utils.kvstore.config import (
KVStoreConfig,
@ -14,7 +14,7 @@ from llama_stack.providers.utils.kvstore.config import (
class MetaReferenceEvalConfig(BaseModel):
kvstore: KVStoreConfig
kvstore: KVStoreConfig = Field(default_factory=SqliteKVStoreConfig)
@classmethod
def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> dict[str, Any]: