Skip to content

Commit 0826159

Browse files
committed
add /models endpoint
Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
1 parent 586bda8 commit 0826159

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

python/packages/autogen-studio/autogenstudio/web/app.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from .config import settings
1616
from .deps import cleanup_managers, init_auth_manager, init_managers, register_auth_dependencies
1717
from .initialization import AppInitializer
18-
from .routes import gallery, runs, sessions, settingsroute, teams, tool_servers, tools, validation, ws
18+
from .routes import gallery, models, runs, sessions, settingsroute, teams, tool_servers, tools, validation, ws
1919

2020
# Initialize application
2121
app_file_path = os.path.dirname(os.path.abspath(__file__))
@@ -155,6 +155,13 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
155155
responses={404: {"description": "Not found"}},
156156
)
157157

158+
api.include_router(
159+
models.router,
160+
prefix="/models",
161+
tags=["models"],
162+
responses={404: {"description": "Not found"}},
163+
)
164+
158165
# Version endpoint
159166

160167

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from typing import Dict, List
2+
3+
from autogen_ext.models.anthropic._model_info import _MODEL_INFO as anthropic_models
4+
from autogen_ext.models.ollama._model_info import _MODEL_INFO as ollama_models
5+
from autogen_ext.models.openai._model_info import _MODEL_INFO as openai_models
6+
from fastapi import APIRouter
7+
8+
router = APIRouter()
9+
10+
11+
@router.get("/")
12+
async def list_models() -> Dict[str, List[str]]:
13+
response = {
14+
"anthropic": list(anthropic_models.keys()),
15+
"ollama": list(ollama_models.keys()),
16+
"openAI": list(openai_models.keys()),
17+
"azureOpenAI": list(openai_models.keys()),
18+
}
19+
20+
return response

python/packages/autogen-studio/pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ dependencies = [
2222
"pydantic",
2323
"pydantic-settings",
2424
"fastapi[standard]",
25-
"typer",
25+
"typer",
2626
"aiofiles",
2727
"python-dotenv",
28-
"websockets",
28+
"websockets",
2929
"sqlmodel",
3030
"psycopg",
3131
"alembic",
@@ -36,6 +36,7 @@ dependencies = [
3636
"autogen-agentchat>=0.4.9.2,<0.6",
3737
"autogen-ext[magentic-one, openai, azure]>=0.4.2,<0.6",
3838
"anthropic",
39+
"ollama>=0.4.7",
3940
]
4041
optional-dependencies = {web = ["fastapi", "uvicorn"], database = ["psycopg"]}
4142

0 commit comments

Comments
 (0)