Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(model-selector): correct combinations provider model (#8135)

Hassieb Pakzadcb65391c2dc3
diff --git a/web/src/components/ModelParameters/index.tsx b/web/src/components/ModelParameters/index.tsx
index aa1e9d905e..f21c6215e0 100644
--- a/web/src/components/ModelParameters/index.tsx
+++ b/web/src/components/ModelParameters/index.tsx
@@ -33,6 +33,7 @@ export type ModelParamsContext = {
modelParams: UIModelParams;
availableProviders: string[];
availableModels: string[];
+ providerModelCombinations: string[];
updateModelParamValue: <Key extends keyof UIModelParams>(
key: Key,
value: UIModelParams[Key]["value"],
@@ -41,13 +42,14 @@ export type ModelParamsContext = {
formDisabled?: boolean;
modelParamsDescription?: string;
customHeader?: React.ReactNode;
- layout?: "vertical" | "compact";
+ layout?: "compact" | "vertical";
};
export const ModelParameters: React.FC<ModelParamsContext> = ({
modelParams,
availableProviders,
availableModels,
+ providerModelCombinations,
updateModelParamValue,
setModelParamEnabled,
formDisabled = false,
@@ -168,12 +170,6 @@ export const ModelParameters: React.FC<ModelParamsContext> = ({
if (layout === "compact") {
// Create combined options in "Provider: model" format
// We create combinations of all available providers with all available models
- const combinedOptions: string[] = [];
- availableProviders.forEach((provider) => {
- availableModels.forEach((model) => {
- combinedOptions.push(`${provider}: ${model}`);
- });
- });
// Current combined value in "Provider: model" format
const currentCombinedValue = `${modelParams.provider.value}: ${modelParams.model.value}`;
@@ -202,7 +198,7 @@ export const ModelParameters: React.FC<ModelParamsContext> = ({
<SelectValue />
</SelectTrigger>
<SelectContent>
- {combinedOptions.map((option) => (
+ {(providerModelCombinations ?? []).map((option) => (
<SelectItem value={option} key={option}>
{option}
</SelectItem>
diff --git a/web/src/features/evals/components/template-form.tsx b/web/src/features/evals/components/template-form.tsx
index f0e626430e..ecbac3278c 100644
--- a/web/src/features/evals/components/template-form.tsx
+++ b/web/src/features/evals/components/template-form.tsx
@@ -185,6 +185,7 @@ export const InnerEvalTemplateForm = (props: {
updateModelParamValue,
setModelParamEnabled,
availableModels,
+ providerModelCombinations,
availableProviders,
} = useModelParams();
@@ -424,6 +425,7 @@ export const InnerEvalTemplateForm = (props: {
{...{
modelParams,
availableModels,
+ providerModelCombinations,
availableProviders,
updateModelParamValue: updateModelParamValue,
setModelParamEnabled,
diff --git a/web/src/features/evals/pages/default-evaluation-model.tsx b/web/src/features/evals/pages/default-evaluation-model.tsx
index 53778df591..28aa5f36b9 100644
--- a/web/src/features/evals/pages/default-evaluation-model.tsx
+++ b/web/src/features/evals/pages/default-evaluation-model.tsx
@@ -47,6 +47,7 @@ export default function DefaultEvaluationModelPage() {
updateModelParamValue,
setModelParamEnabled,
availableModels,
+ providerModelCombinations,
availableProviders,
} = useModelParams();
@@ -156,6 +157,7 @@ export default function DefaultEvaluationModelPage() {
{...{
modelParams,
availableModels,
+ providerModelCombinations,
availableProviders,
updateModelParamValue,
setModelParamEnabled,
diff --git a/web/src/features/experiments/components/PromptExperimentsForm.tsx b/web/src/features/experiments/components/PromptExperimentsForm.tsx
index ee3d3a31e7..3dc3c34957 100644
--- a/web/src/features/experiments/components/PromptExperimentsForm.tsx
+++ b/web/src/features/experiments/components/PromptExperimentsForm.tsx
@@ -172,6 +172,7 @@ export const PromptExperimentsForm = ({
updateModelParamValue,
setModelParamEnabled,
availableModels,
+ providerModelCombinations,
availableProviders,
} = useModelParams();
@@ -465,6 +466,7 @@ export const PromptExperimentsForm = ({
{...{
modelParams,
availableModels,
+ providerModelCombinations,
availableProviders,
updateModelParamValue: updateModelParamValue,
setModelParamEnabled,
diff --git a/web/src/features/playground/page/context/index.tsx b/web/src/features/playground/page/context/index.tsx
index 9f8da485a4..0b828c1cc1 100644
--- a/web/src/features/playground/page/context/index.tsx
+++ b/web/src/features/playground/page/context/index.tsx
@@ -125,6 +125,7 @@ export const PlaygroundProvider: React.FC<PlaygroundProviderProps> = ({
availableModels,
updateModelParamValue,
setModelParamEnabled,
+ providerModelCombinations,
} = useModelParams(windowId);
const { registerWindow, unregisterWindow } = useWindowCoordination();
@@ -635,6 +636,7 @@ export const PlaygroundProvider: React.FC<PlaygroundProviderProps> = ({
modelParams,
updateModelParamValue,
setModelParamEnabled,
+ providerModelCombinations,
output,
outputJson,
diff --git a/web/src/features/playground/page/hooks/useModelParams.ts b/web/src/features/playground/page/hooks/useModelParams.ts
index 2f5daf4c62..cff124f05b 100644
--- a/web/src/features/playground/page/hooks/useModelParams.ts
+++ b/web/src/features/playground/page/hooks/useModelParams.ts
@@ -56,6 +56,18 @@ export const useModelParams = (windowId?: string) => {
(key) => key.provider === modelParams.provider.value,
);
+ const providerModelCombinations =
+ availableLLMApiKeys.data?.data.reduce((acc, v) => {
+ if (v.withDefaultModels) {
+ acc.push(
+ ...supportedModels[v.adapter].map((m) => `${v.provider}: ${m}`),
+ );
+ }
+ acc.push(...v.customModels.map((m) => `${v.provider}: ${m}`));
+
+ return acc;
+ }, [] as string[]) ?? [];
+
const availableModels = useMemo(
() =>
!selectedProviderApiKey
@@ -182,6 +194,7 @@ export const useModelParams = (windowId?: string) => {
availableModels,
updateModelParamValue,
setModelParamEnabled,
+ providerModelCombinations,
};
};