Added dropdown selector for ibm endpoint
This commit is contained in:
parent
07f97eb12a
commit
391a53af76
2 changed files with 57 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { LabelInput } from "@/components/label-input";
|
import { LabelInput } from "@/components/label-input";
|
||||||
|
import { LabelWrapper } from "@/components/label-wrapper";
|
||||||
import IBMLogo from "@/components/logo/ibm-logo";
|
import IBMLogo from "@/components/logo/ibm-logo";
|
||||||
import { useDebouncedValue } from "@/lib/debounce";
|
import { useDebouncedValue } from "@/lib/debounce";
|
||||||
import type { OnboardingVariables } from "../../api/mutations/useOnboardingMutation";
|
import type { OnboardingVariables } from "../../api/mutations/useOnboardingMutation";
|
||||||
|
|
@ -7,6 +8,7 @@ import { useGetIBMModelsQuery } from "../../api/queries/useGetModelsQuery";
|
||||||
import { useModelSelection } from "../hooks/useModelSelection";
|
import { useModelSelection } from "../hooks/useModelSelection";
|
||||||
import { useUpdateSettings } from "../hooks/useUpdateSettings";
|
import { useUpdateSettings } from "../hooks/useUpdateSettings";
|
||||||
import { AdvancedOnboarding } from "./advanced";
|
import { AdvancedOnboarding } from "./advanced";
|
||||||
|
import { ModelSelector } from "./model-selector";
|
||||||
|
|
||||||
export function IBMOnboarding({
|
export function IBMOnboarding({
|
||||||
setSettings,
|
setSettings,
|
||||||
|
|
@ -17,10 +19,42 @@ export function IBMOnboarding({
|
||||||
sampleDataset: boolean;
|
sampleDataset: boolean;
|
||||||
setSampleDataset: (dataset: boolean) => void;
|
setSampleDataset: (dataset: boolean) => void;
|
||||||
}) {
|
}) {
|
||||||
const [endpoint, setEndpoint] = useState("");
|
const [endpoint, setEndpoint] = useState("https://us-south.ml.cloud.ibm.com");
|
||||||
const [apiKey, setApiKey] = useState("");
|
const [apiKey, setApiKey] = useState("");
|
||||||
const [projectId, setProjectId] = useState("");
|
const [projectId, setProjectId] = useState("");
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
{
|
||||||
|
value: "https://us-south.ml.cloud.ibm.com",
|
||||||
|
label: "https://us-south.ml.cloud.ibm.com",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "https://eu-de.ml.cloud.ibm.com",
|
||||||
|
label: "https://eu-de.ml.cloud.ibm.com",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "https://eu-gb.ml.cloud.ibm.com",
|
||||||
|
label: "https://eu-gb.ml.cloud.ibm.com",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "https://au-syd.ml.cloud.ibm.com",
|
||||||
|
label: "https://au-syd.ml.cloud.ibm.com",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "https://jp-tok.ml.cloud.ibm.com",
|
||||||
|
label: "https://jp-tok.ml.cloud.ibm.com",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "https://ca-tor.ml.cloud.ibm.com",
|
||||||
|
label: "https://ca-tor.ml.cloud.ibm.com",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
const debouncedEndpoint = useDebouncedValue(endpoint, 500);
|
const debouncedEndpoint = useDebouncedValue(endpoint, 500);
|
||||||
const debouncedApiKey = useDebouncedValue(apiKey, 500);
|
const debouncedApiKey = useDebouncedValue(apiKey, 500);
|
||||||
const debouncedProjectId = useDebouncedValue(projectId, 500);
|
const debouncedProjectId = useDebouncedValue(projectId, 500);
|
||||||
|
|
@ -68,15 +102,21 @@ export function IBMOnboarding({
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<LabelInput
|
<LabelWrapper
|
||||||
label="watsonx.ai API Endpoint"
|
label="watsonx.ai API Endpoint"
|
||||||
helperText="The API endpoint for your watsonx.ai account."
|
helperText="The API endpoint for your watsonx.ai account."
|
||||||
id="api-endpoint"
|
id="api-endpoint"
|
||||||
required
|
required
|
||||||
placeholder="https://us-south.ml.cloud.ibm.com"
|
>
|
||||||
value={endpoint}
|
<ModelSelector
|
||||||
onChange={(e) => setEndpoint(e.target.value)}
|
options={options}
|
||||||
/>
|
value={endpoint}
|
||||||
|
onValueChange={setEndpoint}
|
||||||
|
searchPlaceholder="Search endpoint..."
|
||||||
|
noOptionsPlaceholder="No endpoints available"
|
||||||
|
placeholder="Select endpoint..."
|
||||||
|
/>
|
||||||
|
</LabelWrapper>
|
||||||
<LabelInput
|
<LabelInput
|
||||||
label="IBM API key"
|
label="IBM API key"
|
||||||
helperText="The API key for your watsonx.ai account."
|
helperText="The API key for your watsonx.ai account."
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ export function ModelSelector({
|
||||||
value,
|
value,
|
||||||
onValueChange,
|
onValueChange,
|
||||||
icon,
|
icon,
|
||||||
|
placeholder = "Select model...",
|
||||||
|
searchPlaceholder = "Search model...",
|
||||||
|
noOptionsPlaceholder = "No models available",
|
||||||
}: {
|
}: {
|
||||||
options: {
|
options: {
|
||||||
value: string;
|
value: string;
|
||||||
|
|
@ -29,6 +32,9 @@ export function ModelSelector({
|
||||||
}[];
|
}[];
|
||||||
value: string;
|
value: string;
|
||||||
icon?: React.ReactNode;
|
icon?: React.ReactNode;
|
||||||
|
placeholder?: string;
|
||||||
|
searchPlaceholder?: string;
|
||||||
|
noOptionsPlaceholder?: string;
|
||||||
onValueChange: (value: string) => void;
|
onValueChange: (value: string) => void;
|
||||||
}) {
|
}) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
@ -50,7 +56,7 @@ export function ModelSelector({
|
||||||
>
|
>
|
||||||
{value ? (
|
{value ? (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className="w-4 h-4">{icon}</div>
|
{icon && <div className="w-4 h-4">{icon}</div>}
|
||||||
{options.find((framework) => framework.value === value)?.label}
|
{options.find((framework) => framework.value === value)?.label}
|
||||||
{options.find((framework) => framework.value === value)
|
{options.find((framework) => framework.value === value)
|
||||||
?.default && (
|
?.default && (
|
||||||
|
|
@ -60,18 +66,18 @@ export function ModelSelector({
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : options.length === 0 ? (
|
) : options.length === 0 ? (
|
||||||
"No models available"
|
noOptionsPlaceholder
|
||||||
) : (
|
) : (
|
||||||
"Select model..."
|
placeholder
|
||||||
)}
|
)}
|
||||||
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent align="start" className="w-[400px] p-0">
|
<PopoverContent align="start" className="w-[400px] p-0">
|
||||||
<Command>
|
<Command>
|
||||||
<CommandInput placeholder="Search model..." />
|
<CommandInput placeholder={searchPlaceholder} />
|
||||||
<CommandList>
|
<CommandList>
|
||||||
<CommandEmpty>No model found.</CommandEmpty>
|
<CommandEmpty>{noOptionsPlaceholder}</CommandEmpty>
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
{options.map((option) => (
|
{options.map((option) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue