Compare commits
2 commits
main
...
fix/openai
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b20da9ab58 | ||
|
|
97c9fdb2c6 |
2 changed files with 11 additions and 8 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import type { Dispatch, SetStateAction } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import OllamaLogo from "@/components/icons/ollama-logo";
|
||||
import { LabelInput } from "@/components/label-input";
|
||||
import { LabelWrapper } from "@/components/label-wrapper";
|
||||
import OllamaLogo from "@/components/icons/ollama-logo";
|
||||
import { useDebouncedValue } from "@/lib/debounce";
|
||||
import type { OnboardingVariables } from "../../api/mutations/useOnboardingMutation";
|
||||
import { useGetOllamaModelsQuery } from "../../api/queries/useGetModelsQuery";
|
||||
|
|
@ -28,7 +28,9 @@ export function OllamaOnboarding({
|
|||
existingEndpoint?: string;
|
||||
}) {
|
||||
const [endpoint, setEndpoint] = useState(
|
||||
alreadyConfigured ? undefined : (existingEndpoint || `http://localhost:11434`),
|
||||
alreadyConfigured
|
||||
? undefined
|
||||
: existingEndpoint || `http://localhost:11434`,
|
||||
);
|
||||
const [showConnecting, setShowConnecting] = useState(false);
|
||||
const debouncedEndpoint = useDebouncedValue(endpoint, 500);
|
||||
|
|
@ -40,7 +42,7 @@ export function OllamaOnboarding({
|
|||
error: modelsError,
|
||||
} = useGetOllamaModelsQuery(
|
||||
debouncedEndpoint ? { endpoint: debouncedEndpoint } : undefined,
|
||||
{ enabled: !!debouncedEndpoint || alreadyConfigured },
|
||||
{ enabled: !!debouncedEndpoint || alreadyConfigured || alreadyConfigured },
|
||||
);
|
||||
|
||||
// Use custom hook for model selection logic
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import type { Dispatch, SetStateAction } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import OpenAILogo from "@/components/icons/openai-logo";
|
||||
import { LabelInput } from "@/components/label-input";
|
||||
import { LabelWrapper } from "@/components/label-wrapper";
|
||||
import OpenAILogo from "@/components/icons/openai-logo";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import {
|
||||
Tooltip,
|
||||
|
|
@ -48,13 +48,13 @@ export function OpenAIOnboarding({
|
|||
getFromEnv
|
||||
? { apiKey: "" }
|
||||
: debouncedApiKey
|
||||
? { apiKey: debouncedApiKey }
|
||||
: undefined,
|
||||
? { apiKey: debouncedApiKey }
|
||||
: undefined,
|
||||
{
|
||||
// Only validate when the user opts in (env) or provides a key.
|
||||
// If a key was previously configured, let the user decide to reuse or replace it
|
||||
// without triggering an immediate validation error.
|
||||
enabled: debouncedApiKey !== "" || getFromEnv,
|
||||
enabled: debouncedApiKey !== "" || getFromEnv || alreadyConfigured,
|
||||
},
|
||||
);
|
||||
// Use custom hook for model selection logic
|
||||
|
|
@ -144,7 +144,8 @@ export function OpenAIOnboarding({
|
|||
/>
|
||||
{alreadyConfigured && (
|
||||
<p className="text-mmd text-muted-foreground">
|
||||
Existing OpenAI key detected. You can reuse it or enter a new one.
|
||||
Existing OpenAI key detected. You can reuse it or enter a new
|
||||
one.
|
||||
</p>
|
||||
)}
|
||||
{isLoadingModels && (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue