Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
LlamaStackAsLibraryClient, # type: ignore
)
from llama_stack_client import AsyncLlamaStackClient, LlamaStackClient # type: ignore
from models.config import LLamaStackConfiguration
from models.config import LlamaStackConfiguration
from utils.types import Singleton


Expand All @@ -21,7 +21,7 @@ class LlamaStackClientHolder(metaclass=Singleton):

_lsc: Optional[LlamaStackClient] = None

def load(self, llama_stack_config: LLamaStackConfiguration) -> None:
def load(self, llama_stack_config: LlamaStackConfiguration) -> None:
"""Retrieve Llama stack client according to configuration."""
if llama_stack_config.use_as_library_client is True:
if llama_stack_config.library_client_config_path is not None:
Expand Down Expand Up @@ -57,7 +57,7 @@ class AsyncLlamaStackClientHolder(metaclass=Singleton):

_lsc: Optional[AsyncLlamaStackClient] = None

async def load(self, llama_stack_config: LLamaStackConfiguration) -> None:
async def load(self, llama_stack_config: LlamaStackConfiguration) -> None:
"""Retrieve Async Llama stack client according to configuration."""
if llama_stack_config.use_as_library_client is True:
if llama_stack_config.library_client_config_path is not None:
Expand Down
4 changes: 2 additions & 2 deletions src/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from models.config import (
Configuration,
Customization,
LLamaStackConfiguration,
LlamaStackConfiguration,
UserDataCollection,
ServiceConfiguration,
ModelContextProtocolServer,
Expand Down Expand Up @@ -60,7 +60,7 @@ def service_configuration(self) -> ServiceConfiguration:
return self._configuration.service

@property
def llama_stack_configuration(self) -> LLamaStackConfiguration:
def llama_stack_configuration(self) -> LlamaStackConfiguration:
"""Return Llama stack configuration."""
assert (
self._configuration is not None
Expand Down
4 changes: 2 additions & 2 deletions src/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ModelContextProtocolServer(BaseModel):
url: str


class LLamaStackConfiguration(BaseModel):
class LlamaStackConfiguration(BaseModel):
"""Llama stack configuration."""

url: Optional[str] = None
Expand Down Expand Up @@ -174,7 +174,7 @@ class Configuration(BaseModel):

name: str
service: ServiceConfiguration
llama_stack: LLamaStackConfiguration
llama_stack: LlamaStackConfiguration
user_data_collection: UserDataCollection
mcp_servers: list[ModelContextProtocolServer] = []
authentication: Optional[AuthenticationConfiguration] = (
Expand Down
28 changes: 14 additions & 14 deletions tests/unit/models/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from models.config import (
AuthenticationConfiguration,
Configuration,
LLamaStackConfiguration,
LlamaStackConfiguration,
ServiceConfiguration,
UserDataCollection,
TLSConfiguration,
Expand Down Expand Up @@ -57,20 +57,20 @@ def test_service_configuration_workers_value() -> None:

def test_llama_stack_configuration_constructor() -> None:
"""Test the LLamaStackConfiguration constructor."""
llama_stack_configuration = LLamaStackConfiguration(
llama_stack_configuration = LlamaStackConfiguration(
use_as_library_client=True, library_client_config_path="foo"
)
assert llama_stack_configuration is not None

llama_stack_configuration = LLamaStackConfiguration(
llama_stack_configuration = LlamaStackConfiguration(
use_as_library_client=False, url="http://localhost"
)
assert llama_stack_configuration is not None

llama_stack_configuration = LLamaStackConfiguration(url="http://localhost")
llama_stack_configuration = LlamaStackConfiguration(url="http://localhost")
assert llama_stack_configuration is not None

llama_stack_configuration = LLamaStackConfiguration(
llama_stack_configuration = LlamaStackConfiguration(
use_as_library_client=False, url="http://localhost", api_key="foo"
)
assert llama_stack_configuration is not None
Expand All @@ -82,7 +82,7 @@ def test_llama_stack_wrong_configuration_constructor_no_url() -> None:
ValueError,
match="LLama stack URL is not specified and library client mode is not specified",
):
LLamaStackConfiguration()
LlamaStackConfiguration()


def test_llama_stack_wrong_configuration_constructor_library_mode_off() -> None:
Expand All @@ -91,14 +91,14 @@ def test_llama_stack_wrong_configuration_constructor_library_mode_off() -> None:
ValueError,
match="LLama stack URL is not specified and library client mode is not enabled",
):
LLamaStackConfiguration(use_as_library_client=False)
LlamaStackConfiguration(use_as_library_client=False)


def test_llama_stack_wrong_configuration_no_config_file() -> None:
"""Test the LLamaStackConfiguration constructor."""
m = "LLama stack library client mode is enabled but a configuration file path is not specified"
with pytest.raises(ValueError, match=m):
LLamaStackConfiguration(use_as_library_client=True)
LlamaStackConfiguration(use_as_library_client=True)


def test_user_data_collection_feedback_enabled() -> None:
Expand Down Expand Up @@ -297,7 +297,7 @@ def test_configuration_empty_mcp_servers() -> None:
cfg = Configuration(
name="test_name",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=True, library_client_config_path="foo"
),
user_data_collection=UserDataCollection(
Expand All @@ -318,7 +318,7 @@ def test_configuration_single_mcp_server() -> None:
cfg = Configuration(
name="test_name",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=True, library_client_config_path="foo"
),
user_data_collection=UserDataCollection(
Expand All @@ -345,7 +345,7 @@ def test_configuration_multiple_mcp_servers() -> None:
cfg = Configuration(
name="test_name",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=True, library_client_config_path="foo"
),
user_data_collection=UserDataCollection(
Expand All @@ -367,7 +367,7 @@ def test_dump_configuration(tmp_path) -> None:
cfg = Configuration(
name="test_name",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=True, library_client_config_path="foo"
),
user_data_collection=UserDataCollection(
Expand Down Expand Up @@ -449,7 +449,7 @@ def test_dump_configuration_with_one_mcp_server(tmp_path) -> None:
cfg = Configuration(
name="test_name",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=True, library_client_config_path="foo"
),
user_data_collection=UserDataCollection(
Expand Down Expand Up @@ -534,7 +534,7 @@ def test_dump_configuration_with_more_mcp_servers(tmp_path) -> None:
cfg = Configuration(
name="test_name",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=True, library_client_config_path="foo"
),
user_data_collection=UserDataCollection(
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import pytest

from client import LlamaStackClientHolder, AsyncLlamaStackClientHolder
from models.config import LLamaStackConfiguration
from models.config import LlamaStackConfiguration


def test_get_llama_stack_library_client() -> None:
"""Test if Llama Stack can be initialized in library client mode."""
cfg = LLamaStackConfiguration(
cfg = LlamaStackConfiguration(
url=None,
api_key=None,
use_as_library_client=True,
Expand All @@ -21,7 +21,7 @@ def test_get_llama_stack_library_client() -> None:

def test_get_llama_stack_remote_client() -> None:
"""Test if Llama Stack can be initialized in remove client (server) mode."""
cfg = LLamaStackConfiguration(
cfg = LlamaStackConfiguration(
url="http://localhost:8321",
api_key=None,
use_as_library_client=False,
Expand All @@ -34,7 +34,7 @@ def test_get_llama_stack_remote_client() -> None:

def test_get_llama_stack_wrong_configuration() -> None:
"""Test if configuration is checked before Llama Stack is initialized."""
cfg = LLamaStackConfiguration(
cfg = LlamaStackConfiguration(
url=None,
api_key=None,
use_as_library_client=True,
Expand All @@ -51,7 +51,7 @@ def test_get_llama_stack_wrong_configuration() -> None:

async def test_get_async_llama_stack_library_client() -> None:
"""Test the initialization of asynchronous Llama Stack client in library mode."""
cfg = LLamaStackConfiguration(
cfg = LlamaStackConfiguration(
url=None,
api_key=None,
use_as_library_client=True,
Expand All @@ -64,7 +64,7 @@ async def test_get_async_llama_stack_library_client() -> None:

async def test_get_async_llama_stack_remote_client() -> None:
"""Test the initialization of asynchronous Llama Stack client in server mode."""
cfg = LLamaStackConfiguration(
cfg = LlamaStackConfiguration(
url="http://localhost:8321",
api_key=None,
use_as_library_client=False,
Expand All @@ -77,7 +77,7 @@ async def test_get_async_llama_stack_remote_client() -> None:

async def test_get_async_llama_stack_wrong_configuration() -> None:
"""Test if configuration is checked before Llama Stack is initialized."""
cfg = LLamaStackConfiguration(
cfg = LlamaStackConfiguration(
url=None,
api_key=None,
use_as_library_client=True,
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/utils/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from models.config import (
Configuration,
ServiceConfiguration,
LLamaStackConfiguration,
LlamaStackConfiguration,
UserDataCollection,
ModelContextProtocolServer,
)
Expand All @@ -38,7 +38,7 @@ async def test_register_mcp_servers_empty_list(mocker):
config = Configuration(
name="test",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=False, url="http://localhost:8321"
),
user_data_collection=UserDataCollection(feedback_disabled=True),
Expand Down Expand Up @@ -78,7 +78,7 @@ async def test_register_mcp_servers_single_server_not_registered(mocker):
config = Configuration(
name="test",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=False, url="http://localhost:8321"
),
user_data_collection=UserDataCollection(feedback_disabled=True),
Expand Down Expand Up @@ -122,7 +122,7 @@ async def test_register_mcp_servers_single_server_already_registered(mocker):
config = Configuration(
name="test",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=False, url="http://localhost:8321"
),
user_data_collection=UserDataCollection(feedback_disabled=True),
Expand Down Expand Up @@ -169,7 +169,7 @@ async def test_register_mcp_servers_multiple_servers_mixed_registration(mocker):
config = Configuration(
name="test",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=False, url="http://localhost:8321"
),
user_data_collection=UserDataCollection(feedback_disabled=True),
Expand Down Expand Up @@ -223,7 +223,7 @@ async def test_register_mcp_servers_with_custom_provider(mocker):
config = Configuration(
name="test",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=False, url="http://localhost:8321"
),
user_data_collection=UserDataCollection(feedback_disabled=True),
Expand Down Expand Up @@ -267,7 +267,7 @@ async def test_register_mcp_servers_async_with_library_client(mocker):
config = Configuration(
name="test",
service=ServiceConfiguration(),
llama_stack=LLamaStackConfiguration(
llama_stack=LlamaStackConfiguration(
use_as_library_client=True,
library_client_config_path="/path/to/config.yaml",
),
Expand Down