Skip to content

feat: added e2e mechanism to ensure custom models can be selected for…#1

Open
AhtishamShahid wants to merge 2 commits into
mainfrom
ahtisham/update_models_defaults_flow
Open

feat: added e2e mechanism to ensure custom models can be selected for…#1
AhtishamShahid wants to merge 2 commits into
mainfrom
ahtisham/update_models_defaults_flow

Conversation

@AhtishamShahid
Copy link
Copy Markdown
Collaborator

@AhtishamShahid AhtishamShahid commented May 6, 2026

This pull request adds support for a custom OpenAI-compatible image generation provider throughout the application. It introduces new environment variables, backend logic, and UI enhancements to allow users to configure and use a custom image generation endpoint in addition to existing providers.

Custom Image Provider Integration

  • Added support for a "custom image" provider (CUSTOM_IMAGE_URL, CUSTOM_IMAGE_API_KEY, CUSTOM_IMAGE_MODEL) in both the backend (servers/fastapi) and Electron app (electron/app/main.ts, docker-compose.yml).
    Frontend/UI Enhancements

  • Updated the image provider settings UI to support configuration of the custom provider, including model selection and API key entry, and added loading and notification states.

Process Management Improvements

  • Enhanced the killProcess function to reliably terminate processes, including polling and fallback to SIGKILL if necessary.
  • Added signal handling for SIGINT and SIGTERM in the Electron app to ensure a clean shutdown.

Build Configuration

  • Minor adjustments to build targets and identity for macOS and Windows in electron/build.js.

New ENV needed for set defaults

"CUSTOM_IMAGE_URL": "$LITELLM_ENDPOINT_NO_V1",
"CUSTOM_IMAGE_API_KEY": "$API_KEY",
"CUSTOM_IMAGE_MODEL": "dall-e-3",
"IMAGE_PROVIDER": "custom_image",

Copilot AI review requested due to automatic review settings May 6, 2026 05:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Custom (OpenAI-compatible) image provider end-to-end, including UI for selecting/fetching available models and backend support for generating images against a custom base URL. It also updates config-loading behavior to merge env- and file-based user config, and includes a few Electron build/runtime tweaks.

Changes:

  • Add custom_image as an image provider with CUSTOM_IMAGE_URL / CUSTOM_IMAGE_API_KEY (optional) / CUSTOM_IMAGE_MODEL support across Next.js, FastAPI, Electron, and Docker.
  • Add UI flows (Settings + Onboarding) to fetch available models from a provided OpenAI-compatible endpoint and enforce selecting a model.
  • Update Next.js user-config API to merge env config with on-disk config (env base, file override), plus some Electron packaging/process-handling adjustments.

Reviewed changes

Copilot reviewed 19 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
start.js Adds env-to-config wiring for new image provider fields.
servers/nextjs/utils/storeHelpers.ts Adds validation for custom_image requiring URL + model.
servers/nextjs/utils/providerConstants.ts Registers custom_image provider option.
servers/nextjs/types/llm_config.ts Adds CUSTOM_IMAGE_* fields to the shared config type.
servers/nextjs/components/OnBoarding/PresentonMode.tsx Adds onboarding UI to configure/fetch/select custom image models.
servers/nextjs/app/api/user-config/route.ts Merges env + file config for UI consumption and persistence behavior.
servers/nextjs/app/(presentation-generator)/(dashboard)/settings/SettingPage.tsx Syncs local settings state when Redux config updates.
servers/nextjs/app/(presentation-generator)/(dashboard)/settings/ImageProvider.tsx Adds custom image provider UI, model fetching, and selection flow.
servers/fastapi/utils/user_config.py Adds env+config plumbing for CUSTOM_IMAGE_* fields.
servers/fastapi/utils/set_env.py Adds setters for CUSTOM_IMAGE_* environment variables.
servers/fastapi/utils/get_env.py Adds getters for CUSTOM_IMAGE_* environment variables.
servers/fastapi/utils/image_provider.py Adds is_custom_image_selected() helper.
servers/fastapi/services/image_generation_service.py Implements generate_image_custom() using an OpenAI-compatible endpoint.
servers/fastapi/models/user_config.py Adds CUSTOM_IMAGE_* fields to the user config model.
servers/fastapi/enums/image_provider.py Adds CUSTOM_IMAGE enum value.
electron/build.js Adjusts macOS signing identity and Windows targets.
electron/app/utils/index.ts Makes process termination more robust via polling + SIGKILL fallback.
electron/app/types/index.d.ts Extends env/user-config typings with CUSTOM_IMAGE_* fields.
electron/app/main.ts Passes new env fields through and adds SIGINT/SIGTERM shutdown hooks.
docker-compose.yml Adds CUSTOM_IMAGE_* env passthrough for services.
.gitignore Ignores .idea and normalizes fastembed cache entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +32 to +37
function buildConfigFromEnv(): LLMConfig {
const config: Record<string, unknown> = {};
for (const key of ENV_CONFIG_KEYS) {
const value = process.env[key];
if (value !== undefined && value !== "") {
config[key] = value;
Comment on lines +261 to +263
api_key = get_custom_image_api_key_env() or "not-needed"

client = AsyncOpenAI(base_url=base_url.rstrip("/"), api_key=api_key)
Comment on lines +53 to +59
export function killProcess(pid: number, signal: NodeJS.Signals = "SIGTERM", timeoutMs: number = 3000): Promise<void> {
return new Promise((resolve) => {
treeKill(pid, signal, (err: any) => {
if (err) {
console.error(`Error killing process ${pid}:`, err)
reject(err)
} else {
console.log(`Process ${pid} killed (${signal})`)
resolve(true)
console.warn(`SIGTERM failed for PID ${pid}, sending SIGKILL`);
treeKill(pid, "SIGKILL", () => resolve());
return;
Comment on lines +561 to +565
{/* No models found warning */}
{!isImageGenerationDisabled && llmConfig.IMAGE_PROVIDER === "custom_image" && customImageModelsChecked && customImageModels.length === 0 && (
<div className="mt-3 p-3 bg-yellow-50 border border-yellow-200 rounded-lg">
<p className="text-sm text-yellow-800">
No models found. Please check your URL and API key and try again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants