Skip to content

Commit 69639cf

Browse files
authored
fix(demos): Updates to use alist_models from public API. (#511)
1 parent 9a383cc commit 69639cf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

demos/chat/backend/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
from typing import Any
55

6-
from any_llm import AnyLLM, LLMProvider, acompletion, list_models
6+
from any_llm import AnyLLM, LLMProvider, acompletion, alist_models
77
from any_llm.exceptions import MissingApiKeyError
88
from fastapi import FastAPI, HTTPException
99
from fastapi.middleware.cors import CORSMiddleware
@@ -56,7 +56,7 @@ async def get_providers():
5656
async def get_models(request: ListModelsRequest):
5757
"""List available models for a provider."""
5858
try:
59-
models = list_models(provider=request.provider)
59+
models = await alist_models(provider=request.provider)
6060

6161
return {
6262
"models": [

demos/finder/backend/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ruff: noqa: T201, S104
22
import os
33

4-
from any_llm import AnyLLM, LLMProvider, list_models
4+
from any_llm import AnyLLM, LLMProvider, alist_models
55
from any_llm.exceptions import MissingApiKeyError
66
from fastapi import FastAPI, HTTPException
77
from fastapi.middleware.cors import CORSMiddleware
@@ -109,7 +109,7 @@ async def search_models(request: SearchRequest):
109109
continue
110110

111111
try:
112-
models = list_models(provider=provider_name.value)
112+
models = await alist_models(provider=provider_name.value)
113113

114114
for model in models:
115115
# Check if the model matches the search query
@@ -190,7 +190,7 @@ async def stream_all_models():
190190
provider_display = provider_name.value.replace("_", " ").title()
191191
yield f"data: {json.dumps({'type': 'status', 'message': f'Loading {provider_display}...', 'progress': completed_providers, 'total': total_providers})}\n\n"
192192

193-
models = list_models(provider=provider_name.value)
193+
models = await alist_models(provider=provider_name.value)
194194

195195
provider_models = []
196196
for model in models:

0 commit comments

Comments
 (0)