mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-15 14:22:42 +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
|
|
@ -15,7 +15,7 @@ from llama_stack.schema_utils import json_schema_type
|
|||
@json_schema_type
|
||||
class ChromaVectorIOConfig(BaseModel):
|
||||
db_path: str
|
||||
kvstore: KVStoreConfig = Field(description="Config for KV store backend")
|
||||
kvstore: KVStoreConfig = Field(default_factory=SqliteKVStoreConfig, description="Config for KV store backend")
|
||||
|
||||
@classmethod
|
||||
def sample_run_config(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from llama_stack.providers.utils.kvstore.config import (
|
||||
KVStoreConfig,
|
||||
|
|
@ -17,7 +17,7 @@ from llama_stack.schema_utils import json_schema_type
|
|||
|
||||
@json_schema_type
|
||||
class FaissVectorIOConfig(BaseModel):
|
||||
kvstore: KVStoreConfig
|
||||
kvstore: KVStoreConfig = Field(default_factory=SqliteKVStoreConfig)
|
||||
|
||||
@classmethod
|
||||
def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> dict[str, Any]:
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ from llama_stack.schema_utils import json_schema_type
|
|||
@json_schema_type
|
||||
class MilvusVectorIOConfig(BaseModel):
|
||||
db_path: str
|
||||
kvstore: KVStoreConfig = Field(description="Config for KV store backend (SQLite only for now)")
|
||||
kvstore: KVStoreConfig = Field(
|
||||
default_factory=SqliteKVStoreConfig, description="Config for KV store backend (SQLite only for now)"
|
||||
)
|
||||
consistency_level: str = Field(description="The consistency level of the Milvus server", default="Strong")
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from llama_stack.providers.utils.kvstore.config import (
|
||||
KVStoreConfig,
|
||||
|
|
@ -19,7 +19,7 @@ from llama_stack.schema_utils import json_schema_type
|
|||
@json_schema_type
|
||||
class QdrantVectorIOConfig(BaseModel):
|
||||
path: str
|
||||
kvstore: KVStoreConfig
|
||||
kvstore: KVStoreConfig = Field(default_factory=SqliteKVStoreConfig)
|
||||
|
||||
@classmethod
|
||||
def sample_run_config(cls, __distro_dir__: str) -> dict[str, Any]:
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ from llama_stack.providers.utils.kvstore.config import (
|
|||
|
||||
class SQLiteVectorIOConfig(BaseModel):
|
||||
db_path: str = Field(description="Path to the SQLite database file")
|
||||
kvstore: KVStoreConfig = Field(description="Config for KV store backend (SQLite only for now)")
|
||||
kvstore: KVStoreConfig = Field(
|
||||
default_factory=SqliteKVStoreConfig, description="Config for KV store backend (SQLite only for now)"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def sample_run_config(cls, __distro_dir__: str) -> dict[str, Any]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue