Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make model listing more generic #5022

Merged
merged 7 commits into from
Oct 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions src/phoenix/server/api/queries.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections import defaultdict
from datetime import datetime
from typing import DefaultDict, Dict, List, Optional, Set, Union, assert_never
from typing import DefaultDict, Dict, List, Optional, Set, Union

import numpy as np
import numpy.typing as npt
Expand Down Expand Up @@ -172,20 +172,14 @@ async def models(self, input: Optional[ModelsInput] = None) -> List[GenerativeMo
for model_name in anthropic_models
]

if input is None or input.provider_key is None:
return (
openai_generative_models
+ azure_openai_generative_models
+ anthropic_generative_models
)
if (provider_key := input.provider_key) == GenerativeProviderKey.OPENAI:
return openai_generative_models
if provider_key == GenerativeProviderKey.AZURE_OPENAI:
return azure_openai_generative_models
if provider_key == GenerativeProviderKey.ANTHROPIC:
return anthropic_generative_models

assert_never(provider_key)
all_models = (
openai_generative_models + azure_openai_generative_models + anthropic_generative_models
)

if input is not None and input.provider_key is not None:
return [model for model in all_models if model.provider_key == input.provider_key]
Comment on lines +150 to +151
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

smart


return all_models

@strawberry.field(permission_classes=[IsAdmin]) # type: ignore
async def users(
Expand Down
Loading