Merge pull request #5406 from open-webui/main

refac
This commit is contained in:
Timothy Jaeryang Baek 2024-09-13 19:26:51 +01:00 committed by GitHub
commit d75d638b9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 3 deletions

View File

@ -333,10 +333,24 @@ async def get_models(url_idx: Optional[int] = None, user=Depends(get_verified_us
r.raise_for_status()
response_data = r.json()
if "api.openai.com" in url:
response_data["data"] = list(
filter(lambda model: "gpt" in model["id"], response_data["data"])
)
# Filter the response data
response_data["data"] = [
model
for model in response_data["data"]
if not any(
name in model["id"]
for name in [
"babbage",
"dall-e",
"davinci",
"embedding",
"tts",
"whisper",
]
)
]
return response_data
except Exception as e: