diff --git a/CHANGELOG.md b/CHANGELOG.md index f0e2d65..21c4a2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +## [1.1.2 - 2025-06-26] + +### Added + +- `temperature` and `num_predict` optional parameters. + ## [1.1.1 - 2025-06-26] ### Added diff --git a/README.md b/README.md index 239475b..ff7125b 100644 --- a/README.md +++ b/README.md @@ -66,5 +66,9 @@ These nodes integrate the Gemini API into ComfyUI, allowing you to send prompts - **error_fallback_value (STRING, Optional, Lazy Input)**: - Value to return if an error occurs when accessing Gemini. - If not set, the node will raise an exception on error. +- **temperature (FLOAT, Optional, Lazy Input)**: + - Controls the randomness of the output. Any **negative value** means to use default value for model. +- **num_predict (INT, Optional, Lazy Input)**: + - The maximum number of tokens to include in a candidate, value `0` means to use default value for model. ![Race and Gender Detection](https://raw.githubusercontent.com/Visionatrix/ComfyUI-Gemini/main/screenshots/race_gender.jpg) diff --git a/nodes.py b/nodes.py index 5ed7ede..8a079e6 100644 --- a/nodes.py +++ b/nodes.py @@ -39,6 +39,8 @@ class GeminiNode: "system_instruction": ("STRING", {}), "error_fallback_value": ("STRING", {"lazy": True}), "seed": ("INT", {"default": seed, "min": 0, "max": 2**31, "step": 1}), + "temperature": ("FLOAT", {"default": -0.05, "min": -0.05, "max": 1, "step": 0.05}), + "num_predict": ("INT", {"default": 0, "min": 0, "max": 1048576, "step": 1}), }, } @@ -67,6 +69,8 @@ class GeminiNode: image_3: Tensor | list[Tensor] | None = None, system_instruction: str | None = None, error_fallback_value: str | None = None, + temperature: float | None = None, + num_predict: int | None = None, **kwargs, ): self.text_output = None @@ -84,6 +88,10 @@ class GeminiNode: generation_config = genai.GenerationConfig( response_mime_type="application/json" if response_type == "json" else "text/plain" ) + if temperature is not None and temperature >= 0: + generation_config.temperature = temperature + if num_predict is not None and num_predict > 0: + generation_config.max_output_tokens = num_predict try: with temporary_env_var("HTTP_PROXY", proxy), temporary_env_var("HTTPS_PROXY", proxy): response = model.generate_content([prompt, *images_to_send], generation_config=generation_config) diff --git a/pyproject.toml b/pyproject.toml index 8f9508e..0280a54 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "comfyui-gemini" -version = "1.1.1" +version = "1.1.2" description = "Nodes for Google Gemini API, focusing on backward compatibility and stability within ComfyUI." license = { file = "LICENSE" } requires-python = ">=3.10" @@ -11,7 +11,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", ] -dependencies = [ "google-generativeai>=0.8.3" ] +dependencies = [ "google-generativeai>=0.8.5" ] urls.Changelog = "https://github.com/Visionatrix/ComfyUI-Gemini/blob/main/CHANGELOG.md" urls.Repository = "https://github.com/Visionatrix/ComfyUI-Gemini" urls.Source = "https://github.com/Visionatrix/ComfyUI-Gemini"