feat: added e2e mechanism to ensure custom models can be selected for…#1
Open
AhtishamShahid wants to merge 2 commits into
Open
feat: added e2e mechanism to ensure custom models can be selected for…#1AhtishamShahid wants to merge 2 commits into
AhtishamShahid wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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_imageas an image provider withCUSTOM_IMAGE_URL/CUSTOM_IMAGE_API_KEY(optional) /CUSTOM_IMAGE_MODELsupport 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
killProcessfunction to reliably terminate processes, including polling and fallback toSIGKILLif necessary.SIGINTandSIGTERMin the Electron app to ensure a clean shutdown.Build Configuration
electron/build.js.New ENV needed for set defaults