Skip to content

Commit 3c7b91a

Browse files
committed
Reapply logging configuration after AsyncLlamaStackAsLibraryClient
During initialization of AsyncLlamaStackAsLibraryClient, a logging configartion is generated and applied. We want the lightspeed-stack logging config to always be used.
1 parent 88f8bcb commit 3c7b91a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/client.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
enrich_byok_rag,
1919
enrich_solr,
2020
)
21-
from log import get_logger
21+
from log import get_logger, setup_logging
2222
from models.api.responses.error import ServiceUnavailableResponse
2323
from models.config import LlamaStackConfiguration
2424
from utils.types import Singleton
@@ -66,6 +66,11 @@ async def _load_library_client(self, config: LlamaStackConfiguration) -> None:
6666
await client.initialize()
6767
self._lsc = client
6868

69+
# Re-apply logging configuration after ogx's setup_logging() is called.
70+
# This ensures the desired logging configuration is applied when
71+
# using AsyncLlamaStackAsLibraryClient.
72+
setup_logging()
73+
6974
def _load_service_client(self, config: LlamaStackConfiguration) -> None:
7075
"""Initialize client in service mode (remote HTTP)."""
7176
logger.info("Using Llama stack running as a service")
@@ -151,6 +156,11 @@ async def reload_library_client(self) -> AsyncLlamaStackClient:
151156
)
152157
raise HTTPException(**error_response.model_dump()) from e
153158
self._lsc = client
159+
# Re-apply logging configuration after ogx's setup_logging() is called.
160+
# This ensures the desired logging configuration is applied when
161+
# using AsyncLlamaStackAsLibraryClient.
162+
setup_logging()
163+
154164
return client
155165

156166
async def check_model_available(self, model_id: str) -> tuple[bool, str]:
@@ -247,6 +257,11 @@ async def update_azure_token(self) -> AsyncLlamaStackClient:
247257
)
248258
await client.initialize()
249259
self._lsc = client
260+
# Re-apply logging configuration after ogx's setup_logging() is called.
261+
# This ensures the desired logging configuration is applied when
262+
# using AsyncLlamaStackAsLibraryClient.
263+
setup_logging()
264+
250265
return client
251266

252267
# Service client mode

0 commit comments

Comments
 (0)