mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-28 02:22:00 +00:00
refactor: Add ProviderContext for a flexible storage directory
- Introduce ProviderContext class to decouple provider storage paths from absolute paths - Add storage_dir attribute to StackRunConfig to accept CLI options - Implement storage directory resolution with prioritized fallbacks: 1. CLI option (--state-directory) 2. Environment variable (LLAMA_STACK_STATE_DIR) 3. Default distribution directory - Standardize provider signatures to follow context, config, deps pattern - Update provider implementations to use the new context-based approach - Add comprehensive tests to verify state directory resolution
This commit is contained in:
parent
dd07c7a5b5
commit
e6c9aebe47
41 changed files with 242 additions and 81 deletions
|
|
@ -7,14 +7,16 @@
|
|||
from typing import Any
|
||||
|
||||
from llama_stack.distribution.datatypes import Api
|
||||
from llama_stack.providers.datatypes import ProviderContext
|
||||
|
||||
from .config import MetaReferenceAgentsImplConfig
|
||||
|
||||
|
||||
async def get_provider_impl(config: MetaReferenceAgentsImplConfig, deps: dict[Api, Any]):
|
||||
async def get_provider_impl(context: ProviderContext, config: MetaReferenceAgentsImplConfig, deps: dict[Api, Any]):
|
||||
from .agents import MetaReferenceAgentsImpl
|
||||
|
||||
impl = MetaReferenceAgentsImpl(
|
||||
context,
|
||||
config,
|
||||
deps[Api.inference],
|
||||
deps[Api.vector_io],
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ from llama_stack.apis.inference import (
|
|||
from llama_stack.apis.safety import Safety
|
||||
from llama_stack.apis.tools import ToolGroups, ToolRuntime
|
||||
from llama_stack.apis.vector_io import VectorIO
|
||||
from llama_stack.providers.datatypes import ProviderContext
|
||||
from llama_stack.providers.utils.kvstore import InmemoryKVStoreImpl, kvstore_impl
|
||||
from llama_stack.providers.utils.pagination import paginate_records
|
||||
|
||||
|
|
@ -51,6 +52,7 @@ logger = logging.getLogger()
|
|||
class MetaReferenceAgentsImpl(Agents):
|
||||
def __init__(
|
||||
self,
|
||||
context: ProviderContext,
|
||||
config: MetaReferenceAgentsImplConfig,
|
||||
inference_api: Inference,
|
||||
vector_io_api: VectorIO,
|
||||
|
|
@ -58,6 +60,7 @@ class MetaReferenceAgentsImpl(Agents):
|
|||
tool_runtime_api: ToolRuntime,
|
||||
tool_groups_api: ToolGroups,
|
||||
):
|
||||
self.context = context
|
||||
self.config = config
|
||||
self.inference_api = inference_api
|
||||
self.vector_io_api = vector_io_api
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue