Initial TrueGrowth source import

This commit is contained in:
2026-07-07 09:36:36 +08:00
commit 3b6781d695
2283 changed files with 691996 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
## Context
The current image generation path already supports provider profiles, runtime model discovery, model bindings, and image adapters. The safest first local model integration is a provider profile for locally running OpenAI-compatible services.
## Goals / Non-Goals
- Goals: support local `/v1/models` discovery, no-auth local calls, generic `/v1/images/generations` image requests, Model Center image model installation/application, and user-facing defaults for LocalAI-style runtimes.
- Non-Goals: ComfyUI, A1111/Forge native APIs, remote LAN exposure, direct execution of every downloaded model format, or hidden license acceptance.
## Decisions
- Represent local image services as `openai-compatible` provider profiles with `authType: none`.
- Keep the request schema as `openai.image.basic-json` so existing image adapter routing remains compatible.
- Treat optional fields such as `negative_prompt`, `steps`, `cfg_scale`, and `seed` as provider extensions in the JSON body.
- Store downloaded/imported image models in a lightweight local registry separate from AIGCPanel `config.json` model packages.
- Model Center can register official model metadata and local paths, but actual generation requires a reachable OpenAI-compatible local service that has loaded the model.
## Risks / Trade-offs
- Some local runtimes use non-OpenAI APIs. They remain out of scope until a dedicated adapter is added.
- Local runtimes differ in supported parameters. Unsupported extension fields are expected to be ignored or rejected by the local service with a visible API error.
- Hugging Face model downloads may require large files, authentication, or license acknowledgement. The first implementation exposes official links and supports importing a local path instead of silently pretending all models can be downloaded through the app.

View File

@@ -0,0 +1,15 @@
# Change: Add local image provider support
## Why
TrueGrowth already supports online provider profiles for image generation, but users also need locally running OpenAI-compatible image services to appear in the same model selector and canvas generation flow.
## What Changes
- Add a local image provider template for OpenAI-compatible `/v1/models` and `/v1/images/generations` services.
- Allow local provider discovery and invocation without an API key.
- Route local image models through the existing generic OpenAI-compatible image adapter.
- Extend Model Center with a dedicated image category, official model entries, local install/import state, realtime `/v1/models` status, and an "apply to image generation" action.
- Document recommended local runtimes and model choices without introducing ComfyUI in this change.
## Impact
- Affected specs: runtime-model-discovery, provider-routing, image-generation
- Affected code: provider settings dialog, provider profile normalization, runtime model discovery, provider transport, generic image adapter request body, local runtime model assets, Model Center UI

View File

@@ -0,0 +1,28 @@
## ADDED Requirements
### Requirement: Pass Local Image Extension Parameters
The system SHALL pass common local image runtime parameters through generic OpenAI-compatible image generation requests.
#### Scenario: Local image request includes advanced parameters
- **GIVEN** an image generation request includes `negative_prompt`, `steps`, `cfg_scale`, or `seed`
- **AND** the selected binding uses `openai.image.basic-json`
- **WHEN** the image adapter sends `/images/generations`
- **THEN** the request body SHALL include those parameters alongside `model`, `prompt`, and `size`
### Requirement: Keep Generated Local Images In Existing Results Flow
The system SHALL handle local image generation results using the existing task and media result flow.
#### Scenario: Local provider returns image data
- **GIVEN** a local OpenAI-compatible image service returns image URLs or base64 image data
- **WHEN** the image task completes
- **THEN** the task result SHALL be normalized like online provider image results
- **AND** the image SHALL remain eligible for canvas insertion and media library reuse
### Requirement: Apply Installed Local Image Models From Model Center
The system SHALL allow installed local image model assets to be applied as the default image generation model.
#### Scenario: User applies local image model
- **GIVEN** a local image model asset is installed in Model Center
- **WHEN** the user selects "apply to image generation"
- **THEN** the system SHALL create or update a no-auth OpenAI-compatible local image provider profile
- **AND** add the model to that provider catalog
- **AND** set the active image invocation route to that model

View File

@@ -0,0 +1,18 @@
## ADDED Requirements
### Requirement: Route Local Image Models Through Basic OpenAI Image Binding
The system SHALL route local OpenAI-compatible image models through the generic OpenAI image generation binding.
#### Scenario: Local image model is selected
- **GIVEN** a local provider profile exposes an image model from `/v1/models`
- **WHEN** image bindings are inferred for that model
- **THEN** the selected binding SHALL use protocol `openai.images.generations`
- **AND** request schema `openai.image.basic-json`
- **AND** submit path `/images/generations`
### Requirement: Support No-Auth Provider Transport
The system SHALL support provider profiles that intentionally send no authentication credentials.
#### Scenario: Provider auth type is none
- **GIVEN** a provider profile uses no authentication
- **WHEN** a provider request is prepared
- **THEN** the system SHALL NOT add Authorization, API key header, or API key query parameters

View File

@@ -0,0 +1,29 @@
## ADDED Requirements
### Requirement: Discover Local Image Providers Without API Key
The system SHALL allow a local image provider profile to discover models from an OpenAI-compatible `/v1/models` endpoint without requiring an API key.
#### Scenario: Local provider has no API key
- **GIVEN** a provider profile is configured for a local OpenAI-compatible image service
- **AND** the profile uses no authentication
- **WHEN** the user discovers runtime models
- **THEN** the system SHALL request `/v1/models` without an Authorization header
- **AND** discovered image models SHALL be available for selection
### Requirement: Provide Local Image Provider Defaults
The system SHALL provide a local image provider template with defaults suitable for OpenAI-compatible local image runtimes.
#### Scenario: User creates local image provider
- **WHEN** the user adds a local image provider
- **THEN** the profile SHALL default to `http://127.0.0.1:8080/v1`
- **AND** use no authentication
- **AND** enable image generation and model discovery capabilities
- **AND** use OpenAI-compatible basic image compatibility
### Requirement: Surface Local Image Models In Model Center
The system SHALL expose local image model assets in Model Center with install state and live service information.
#### Scenario: User views image models
- **WHEN** the user opens Model Center
- **THEN** official local image model entries SHALL be available under an image category
- **AND** each entry SHALL show license, recommended runtime, model ID, and provider base URL where available
- **AND** installed image models SHALL be matched against the local `/v1/models` response to indicate whether the model is loaded by the running service

View File

@@ -0,0 +1,13 @@
## 1. Implementation
- [x] 1.1 Add OpenSpec deltas for local image provider discovery, routing, and generation.
- [x] 1.2 Add no-auth provider support and local image provider settings template.
- [x] 1.3 Allow runtime model discovery to call local `/v1/models` without an API key.
- [x] 1.4 Ensure local image models infer generic OpenAI-compatible image bindings.
- [x] 1.5 Pass local image parameters through the generic image adapter.
- [x] 1.6 Add targeted tests for empty-key discovery, no-auth transport, local template defaults, routing, and image request payload.
- [x] 1.7 Add Model Center image model assets with official links, license/runtime metadata, import/install state, and `/v1/models` live status.
- [x] 1.8 Add a Model Center action that applies an installed local image model to the active image generation route.
## 2. Validation
- [x] 2.1 Run focused Vitest coverage for settings, discovery, routing, transport, and media executor.
- [x] 2.2 Validate local runtime script and frontend type/build checks; record existing Sass build blocker.