feat: added "temperature" and "num_predict" optional parameters

Signed-off-by: bigcat88 <bigcat88@icloud.com>
This commit is contained in:
Alexander Piskun
2025-06-26 17:44:49 +03:00
committed by bigcat88
parent b34a3d3c44
commit 72d8afc3bf
4 changed files with 20 additions and 2 deletions
+6
View File
@@ -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
+4
View File
@@ -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)
+8
View File
@@ -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)
+2 -2
View File
@@ -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"