|
3 | 3 | import logging |
4 | 4 | from typing import Annotated, Any |
5 | 5 |
|
6 | | -from fastapi import APIRouter, Request |
| 6 | +from fastapi import APIRouter, HTTPException, Request, status |
7 | 7 | from fastapi import Depends |
| 8 | +from llama_stack_client import APIConnectionError |
8 | 9 |
|
9 | 10 | from auth.interface import AuthTuple |
| 11 | +from client import AsyncLlamaStackClientHolder |
10 | 12 | from auth import get_auth_dependency |
11 | 13 | from authorization.middleware import authorize |
12 | 14 | from configuration import configuration |
@@ -49,4 +51,24 @@ async def info_endpoint_handler( |
49 | 51 | # Nothing interesting in the request |
50 | 52 | _ = request |
51 | 53 |
|
52 | | - return InfoResponse(name=configuration.configuration.name, version=__version__) |
| 54 | + try: |
| 55 | + # try to get Llama Stack client |
| 56 | + client = AsyncLlamaStackClientHolder().get_client() |
| 57 | + # retrieve version |
| 58 | + llama_stack_version_object = await client.inspect.version() |
| 59 | + llama_stack_version = llama_stack_version_object.version |
| 60 | + return InfoResponse( |
| 61 | + name=configuration.configuration.name, |
| 62 | + service_version=__version__, |
| 63 | + llama_stack_version=llama_stack_version, |
| 64 | + ) |
| 65 | + # connection to Llama Stack server |
| 66 | + except APIConnectionError as e: |
| 67 | + logger.error("Unable to connect to Llama Stack: %s", e) |
| 68 | + raise HTTPException( |
| 69 | + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, |
| 70 | + detail={ |
| 71 | + "response": "Unable to connect to Llama Stack", |
| 72 | + "cause": str(e), |
| 73 | + }, |
| 74 | + ) from e |
0 commit comments