llama-stack-mirror/llama_stack/providers/inline/batches/reference/config.py
Charlie Doern 7605631df7 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>
2025-10-20 14:12:28 -04:00

41 lines
1.2 KiB
Python

# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from pydantic import BaseModel, Field
from llama_stack.providers.utils.kvstore.config import KVStoreConfig, SqliteKVStoreConfig
class ReferenceBatchesImplConfig(BaseModel):
"""Configuration for the Reference Batches implementation."""
kvstore: KVStoreConfig = Field(
default_factory=SqliteKVStoreConfig,
description="Configuration for the key-value store backend.",
)
max_concurrent_batches: int = Field(
default=1,
description="Maximum number of concurrent batches to process simultaneously.",
ge=1,
)
max_concurrent_requests_per_batch: int = Field(
default=10,
description="Maximum number of concurrent requests to process per batch.",
ge=1,
)
# TODO: add a max requests per second rate limiter
@classmethod
def sample_run_config(cls, __distro_dir__: str) -> dict:
return {
"kvstore": SqliteKVStoreConfig.sample_run_config(
__distro_dir__=__distro_dir__,
db_name="batches.db",
),
}