Skip to content

Feature/style system consolidation#5

Merged
Limbicnation merged 3 commits intomainfrom
feature/style-system-consolidation
Feb 27, 2026
Merged

Feature/style system consolidation#5
Limbicnation merged 3 commits intomainfrom
feature/style-system-consolidation

Conversation

@Limbicnation
Copy link
Copy Markdown
Owner

No description provided.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors and enhances the prompt generation capabilities by introducing a consolidated and extensible style system. The changes centralize style definitions, expand the range of available prompt styles, and improve the robustness of style loading and error reporting. This makes the prompt generation nodes more flexible and easier to manage for future additions and modifications.

Highlights

  • Consolidated Style System: The style definition and management have been centralized into a new style_presets.py module, making it easier to define, extend, and maintain prompt styles. This includes new StyleMode, StyleKeywords, and StyleDefinition dataclasses.
  • Expanded Prompt Generation Styles: The PromptGeneratorNode now supports 9 style presets, including new 'Anime', 'Photorealistic', 'Fantasy', 'Abstract', 'Cyberpunk', and 'Sci-Fi' options. These styles are loaded dynamically from a templates.yaml file, with a fallback to default definitions.
  • Improved Error Handling and Messaging: Error messages within the PromptGeneratorNode have been standardized with a [PromptGenerator] prefix, replacing generic warning symbols for clearer logging.
  • New Still Image Style: A detailed 'Still Image (Photography)' style has been added to the PromptGeneratorNode's default styles, providing specific keywords for sharp, realistic photography prompts.
  • Configurable Chunk Timeout: A CHUNK_TIMEOUT constant was introduced in PromptGeneratorNode to make the streaming chunk timeout configurable.
Changelog
  • .gitignore
    • Added new entries for project artifacts like .zip, social/, and code-review-.md to prevent them from being committed.
  • init.py
    • Removed a trailing newline character for minor formatting consistency.
  • nodes/prompt_generator_node.py
    • Updated the docstring to reflect the increase to 9 style presets loaded from templates.yaml.
    • Introduced a CHUNK_TIMEOUT class constant for streaming operations.
    • Added a new 'still_image' style definition to the DEFAULT_STYLES dictionary.
    • Implemented a _get_style_list class method to dynamically load available styles from config/templates.yaml or fall back to DEFAULT_STYLES keys.
    • Modified INPUT_TYPES to use the dynamically loaded available_styles for the 'style' dropdown, setting the default to the first available style.
    • Updated the _render_template method to gracefully handle cases where a requested style is not found, logging a warning and falling back to the 'cinematic' style.
    • Replaced hardcoded chunk_timeout with the self.CHUNK_TIMEOUT constant in _generate_with_streaming.
    • Standardized error messages by replacing '⚠️' with '[PromptGenerator]' prefix for better consistency and searchability.
  • nodes/style_applier_node.py
    • Adjusted docstring and method signature formatting for improved readability.
    • Updated error message formatting to be consistent with other nodes.
    • Ensured StylePreset is correctly imported and used for retrieving style choices.
  • style_presets.py
    • Updated the module docstring to reflect the new modular style system.
    • Expanded the StyleMode enumeration to include new styles: ANIME, PHOTOREALISTIC, FANTASY, ABSTRACT, CYBERPUNK, SCI_FI, and VIDEO_WAN.
    • Introduced StyleKeywords dataclass to structure keywords by category (primary, lighting, technical, composition, texture).
    • Created StyleDefinition dataclass to encapsulate style name, description, and associated StyleKeywords.
    • Populated the STYLE_DEFINITIONS dictionary with comprehensive keyword sets for all new and existing styles.
    • Refactored StylePreset class to utilize the new STYLE_DEFINITIONS structure for retrieving style information.
    • Added get_style_keywords method to retrieve keywords for a given style.
    • Modified get_style_prompt to construct the prompt string from the categorized keywords, allowing for conditional inclusion of technical terms and emphasis.
    • Updated the __all__ export list to include new functions and classes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request consolidates the style system for the ComfyUI Prompt Generator by moving style definitions out of the code and into configuration files and dedicated modules, enhancing extensibility. However, a potential Denial of Service vulnerability was identified in the streaming generation logic, specifically due to the use of unmanaged threads for fetching chunks from the Ollama API, which could lead to thread exhaustion if the API hangs. It is recommended to use a more robust streaming implementation, such as a thread pool with a fixed size or an asynchronous approach, to prevent resource depletion. Furthermore, the review includes suggestions to improve maintainability by reducing data duplication across style implementations and addresses a minor issue with exception handling.

Comment on lines +215 to +232
"still_image": {
"name": "Still Image (Photography)",
"description": "Sharp, realistic photography with technical camera specifications",
"template": """Write a detailed Stable Diffusion prompt for: {{ description }}

Style: Generate a professional photography still image with sharp focus.
{% if emphasis %}Focus particularly on: {{ emphasis }}{% endif %}
{% if mood %}Mood/Atmosphere: {{ mood }}{% endif %}

Include specific details about:
- Camera settings (ISO 100, f/2.8 aperture, sharp optics)
- Natural or studio lighting
- Realistic textures and fine details
- Clean, balanced composition
- Professional photography qualities

Format the response as a single, detailed photography prompt.""",
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While adding this style to the DEFAULT_STYLES fallback is necessary with the current design, this large dictionary duplicates all the templates from config/templates.yaml. This creates a maintenance burden, as any changes to templates.yaml must be manually synchronized here. This is error-prone and goes against the goal of consolidating the style system. Consider reducing this duplication. One approach is to embed the default YAML content as a single multi-line string and parse it, ensuring there's only one source of truth for the default templates. Another is to make templates.yaml a required file and raise an error if it's missing or unreadable, removing the need for a large fallback dictionary.

Comment thread nodes/prompt_generator_node.py Outdated
Comment thread style_presets.py
Comment on lines +143 to +172
StyleMode.ANIME: StyleDefinition(
name="Anime",
description="Vibrant anime-style illustration with dynamic colors",
keywords=StyleKeywords(
primary=[
"anime style",
"manga illustration",
"cel shading",
"vibrant colors",
],
lighting=[
"soft glow",
"dramatic backlighting",
"ambient light",
"bloom effect",
],
technical=[
"clean linework",
"flat color areas",
"high contrast",
"detailed eyes",
],
composition=[
"dynamic pose",
"expressive composition",
"layered background",
],
texture=["smooth gradients", "soft skin tones", "vivid saturation"],
),
),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This PR consolidates styles, which is great. However, it maintains two separate sources of truth for style definitions: the keyword lists here in STYLE_DEFINITIONS, and the LLM prompt templates in config/templates.yaml (with a fallback in prompt_generator_node.py). While they serve different nodes, they represent the same conceptual styles. This means adding or modifying a style requires changes in multiple places, increasing maintenance overhead and risk of them becoming out of sync. For true consolidation, consider deriving one from the other, or defining them together in a single source file (e.g., a more structured YAML) from which both the keyword lists and the LLM templates are generated.

@Limbicnation Limbicnation merged commit 8af6785 into main Feb 27, 2026
1 of 2 checks passed
@Limbicnation Limbicnation deleted the feature/style-system-consolidation branch February 27, 2026 05:12
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.

1 participant