| 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | # All rights reserved. |
| 3 | # |
| 4 | # This source code is licensed under the terms described in the LICENSE file in |
| 5 | # the root directory of this source tree. |
| 6 | |
| 7 | from typing import List, Optional, Protocol |
| 8 | |
| 9 | from llama_models.schema_utils import json_schema_type, webmethod |
| 10 | from pydantic import BaseModel, Field |
| 11 | |
| 12 | from llama_stack.apis.memory import MemoryBankType |
| 13 | |
| 14 | from llama_stack.distribution.datatypes import GenericProviderConfig |
| 15 | |
| 16 | |
| 17 | @json_schema_type |
| 18 | class MemoryBankSpec(BaseModel): |
| 19 | bank_type: MemoryBankType |
| 20 | provider_config: GenericProviderConfig = Field( |
| 21 | description="Provider config for the model, including provider_id, and corresponding config. ", |
| 22 | ) |
| 23 | |
| 24 | |
| 25 | class MemoryBanks(Protocol): |
| 26 | @webmethod(route="/memory_banks/list", method="GET") |
| 27 | async def list_available_memory_banks(self) -> List[MemoryBankSpec]: ... |
| 28 | |
| 29 | @webmethod(route="/memory_banks/get", method="GET") |
| 30 | async def get_serving_memory_bank( |
| 31 | self, bank_type: MemoryBankType |
| 32 | ) -> Optional[MemoryBankSpec]: ... |