Skip to content

Commit ddace9e

Browse files
authored
Merge pull request #9 from tisnik/endpoint-with-model-list
Endpoint with model list
2 parents 6a4d0e0 + 6474497 commit ddace9e

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/app/endpoints/models.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Handler for REST API call to provide info."""
2+
3+
import asyncio
4+
import logging
5+
from typing import Any, Optional
6+
7+
from fastapi import APIRouter, Request
8+
from llama_stack_client import Agent, AgentEventLogger, RAGDocument, LlamaStackClient
9+
10+
logger = logging.getLogger(__name__)
11+
router = APIRouter(tags=["models"])
12+
13+
14+
@router.get("/models")
15+
def models_endpoint_handler(request: Request) -> list[dict]:
16+
client = LlamaStackClient(base_url="http://localhost:8321")
17+
models = client.models.list()
18+
return [dict(m) for m in models]

src/app/routers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
from fastapi import FastAPI
44

5-
from app.endpoints import (
6-
info,
7-
)
5+
from app.endpoints import info, models
86

97

108
def include_routers(app: FastAPI) -> None:
@@ -14,3 +12,4 @@ def include_routers(app: FastAPI) -> None:
1412
app: The `FastAPI` app instance.
1513
"""
1614
app.include_router(info.router, prefix="/v1")
15+
app.include_router(models.router, prefix="/v1")

0 commit comments

Comments
 (0)