Skip to content

Commit

Permalink
fix: remove inactive models from model/default model alias dropdown o…
Browse files Browse the repository at this point in the history
…ptions (#992)
  • Loading branch information
ivyjeong13 authored Dec 20, 2024
1 parent 5e13c50 commit 6edea43
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ui/admin/app/components/agent/AgentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useForm } from "react-hook-form";
import useSWR from "swr";
import { z } from "zod";

import { Model, ModelUsage } from "~/lib/model/models";
import { Model, ModelUsage, filterModelsByActive } from "~/lib/model/models";
import { ModelApiService } from "~/lib/service/api/modelApiService";

import { TypographyH4 } from "~/components/Typography";
Expand Down Expand Up @@ -136,7 +136,7 @@ export function AgentForm({ agent, onSubmit, onChange }: AgentFormProps) {
);

function getModelOptionsByModelProvider(models: Model[]) {
const byModelProviderGroups = models.reduce(
const byModelProviderGroups = filterModelsByActive(models).reduce(
(acc, model) => {
acc[model.modelProvider] = acc[model.modelProvider] || [];
acc[model.modelProvider].push(model);
Expand Down
8 changes: 4 additions & 4 deletions ui/admin/app/components/model/DefaultModelAliasForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Model,
ModelAlias,
ModelUsage,
filterModelsByActive,
filterModelsByUsage,
getModelAliasLabel,
getModelUsageFromAlias,
Expand Down Expand Up @@ -166,9 +167,8 @@ export function DefaultModelAliasForm({
getModelUsageFromAlias(alias) ??
ModelUsage.Unknown;

const modelOptions = filterModelsByUsage(
models ?? [],
usage
const activeModelOptions = filterModelsByActive(
filterModelsByUsage(models ?? [], usage)
);

return (
Expand All @@ -195,7 +195,7 @@ export function DefaultModelAliasForm({

<SelectContent>
{renderSelectContent(
modelOptions,
activeModelOptions,
defaultModel,
usage,
alias
Expand Down
4 changes: 4 additions & 0 deletions ui/admin/app/lib/model/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export function filterModelsByUsage(
return models.filter((model) => _usages.includes(model.usage)).sort(sort);
}

export function filterModelsByActive(models: Model[]) {
return models.filter((model) => model.active);
}

export type ModelManifest = {
name?: string;
targetModel?: string;
Expand Down

0 comments on commit 6edea43

Please sign in to comment.