import React from 'react'
import { Popover, PopoverContent, PopoverTrigger } from './ui/popover';
import { Button } from './ui/button';
import { Check, ChevronsUpDown } from 'lucide-react';
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from './ui/command';
import { LLMConfig } from '@/types/llm_config';
import { IMAGE_PROVIDERS } from '@/utils/providerConstants';
import { cn } from '@/lib/utils';
import { Select, SelectItem, SelectContent, SelectTrigger, SelectValue } from './ui/select';
const DALLE_3_QUALITY_OPTIONS = [
{
label: "Standard",
value: "standard",
description: "Faster generation with lower cost",
},
{
label: "HD",
value: "hd",
description: "Higher quality images with increased cost",
},
];
const GPT_IMAGE_1_5_QUALITY_OPTIONS = [
{
label: "Low",
value: "low",
description: "Fastest and most cost-effective",
},
{
label: "Medium",
value: "medium",
description: "Balanced quality and speed",
},
{
label: "High",
value: "high",
description: "Best quality with longer generation time",
},
];
const renderQualitySelector = (llmConfig: LLMConfig, input_field_changed: (value: string, field: string) => void) => {
if (llmConfig.IMAGE_PROVIDER === "dall-e-3") {
return (
{/* {DALLE_3_QUALITY_OPTIONS.map((option) => (
))} */}
);
}
if (llmConfig.IMAGE_PROVIDER === "gpt-image-1.5") {
return (
{/* {GPT_IMAGE_1_5_QUALITY_OPTIONS.map((option) => (
))} */}
);
}
return null;
};
const ImageSelectionConfig = ({ isImageGenerationDisabled, openImageProviderSelect, setOpenImageProviderSelect, llmConfig, input_field_changed, getApiKeyValue, handleApiKeyInputChange }: { isImageGenerationDisabled: boolean, openImageProviderSelect: boolean, setOpenImageProviderSelect: (open: boolean) => void, llmConfig: LLMConfig, input_field_changed: (value: string, field: string) => void, getApiKeyValue: (field: string) => string, handleApiKeyInputChange: (field: string, value: string) => void }) => {
return (
Image Generation Settings
Choosing where images come from.
{!isImageGenerationDisabled && (
<>
{/* Image Provider Selection */}
No provider found.
{Object.values(IMAGE_PROVIDERS).map(
(provider, index) => (
{
input_field_changed(value, "image_provider");
setOpenImageProviderSelect(false);
}}
>
{provider.label}
{provider.description}
)
)}
{renderQualitySelector(llmConfig, input_field_changed)}
{/* Dynamic API Key Input for Image Provider */}
{llmConfig.IMAGE_PROVIDER &&
IMAGE_PROVIDERS[llmConfig.IMAGE_PROVIDER] &&
(() => {
const provider = IMAGE_PROVIDERS[llmConfig.IMAGE_PROVIDER];
// Show info message when using same API key as main provider
if (
provider.value === "dall-e-3" &&
llmConfig.LLM === "openai"
) {
return <>>;
}
if (
provider.value === "gpt-image-1.5" &&
llmConfig.LLM === "openai"
) {
return <>>;
}
if (
provider.value === "gemini_flash" &&
llmConfig.LLM === "google"
) {
return <>>;
}
if (
provider.value === "nanobanana_pro" &&
llmConfig.LLM === "google"
) {
return <>>;
}
// Show ComfyUI configuration
if (provider.value === "comfyui") {
return (
Export your workflow from ComfyUI using "Export
(API)" and paste the JSON here.
);
}
// Show API key input for other providers
return (
);
})()}
>
)}
)
}
export default ImageSelectionConfig