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(frontend): Improve models input UI/UX in settings #3530

Merged
merged 22 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
Add verified models
  • Loading branch information
amanape committed Aug 22, 2024
commit 41301c1239293e42779c3d8cdee2308acb9c86c8
31 changes: 19 additions & 12 deletions frontend/src/components/modals/settings/ModelSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "@nextui-org/react";
import React from "react";
import { mapProvider } from "#/utils/mapProvider";
import { VERIFIED_PROVIDERS } from "#/utils/verified-models";
import { VERIFIED_MODELS, VERIFIED_PROVIDERS } from "#/utils/verified-models";
import { extractModelAndProvider } from "#/utils/extractModelAndProvider";

interface ModelSelectorProps {
Expand Down Expand Up @@ -96,17 +96,24 @@ export function ModelSelector({
extractModelAndProvider(defaultModel ?? "")?.model ?? undefined
}
>
{selectedProvider ? (
models[selectedProvider].models.map((model) => (
<AutocompleteItem key={model} value={model}>
{model}
</AutocompleteItem>
))
) : (
<AutocompleteItem key="" value="">
Select a model
</AutocompleteItem>
)}
<AutocompleteSection title="Verified">
{models[selectedProvider || ""]?.models
.filter((model) => VERIFIED_MODELS.includes(model))
.map((model) => (
<AutocompleteItem key={model} value={model}>
{model}
</AutocompleteItem>
))}
</AutocompleteSection>
<AutocompleteSection title="Others">
{models[selectedProvider || ""]?.models
.filter((model) => !VERIFIED_MODELS.includes(model))
.map((model) => (
<AutocompleteItem key={model} value={model}>
{model}
</AutocompleteItem>
))}
</AutocompleteSection>
</Autocomplete>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/modals/settings/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ function SettingsModal({ isOpen, onOpenChange }: SettingsProps) {
React.useEffect(() => {
(async () => {
try {
setModels(await fetchModels());
setAgents(await fetchAgents());
const fetchedModels = await fetchModels();
const fetchedAgents = await fetchAgents();
setModels(fetchedModels);
setAgents(fetchedAgents);
setSecurityAnalyzers(await fetchSecurityAnalyzers());
} catch (error) {
toast.error("settings", t(I18nKey.CONFIGURATION$ERROR_FETCH_MODELS));
Expand Down
10 changes: 3 additions & 7 deletions frontend/src/utils/verified-models.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export const VERIFIED_PROVIDERS = [
"openai",
"azure",
"anthropic",
"palm",
"ollama",
];
export const VERIFIED_PROVIDERS = ["openai", "azure", "anthropic"];

export const VERIFIED_MODELS = ["gpt-4o", "claude-3-5-sonnet-20240620-v1:0"];

export const VERIFIED_OPENAI_MODELS = [
"gpt-4o",
Expand Down