From 49df442cdfd5c879d00341d5439a6286937c8a92 Mon Sep 17 00:00:00 2001 From: silveroxides Date: Wed, 7 May 2025 18:42:33 +0200 Subject: [PATCH] Expand and Reconfigure --- .github/workflows/publish.yml | 2 +- gemini_nodes.py | 32 +++++++++++++++++++++++++++----- pyproject.toml | 10 +++++----- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 85d84ed..12e0b59 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,7 +15,7 @@ jobs: publish-node: name: Publish Custom Node to registry runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'tatookan' }} + if: ${{ github.repository_owner == 'silveroxides' }} steps: - name: Check out code uses: actions/checkout@v4 diff --git a/gemini_nodes.py b/gemini_nodes.py index d57cfd5..f89e3e8 100644 --- a/gemini_nodes.py +++ b/gemini_nodes.py @@ -65,7 +65,8 @@ class SSL_GeminiTextPrompt: "required": { "config": ("GEMINI_CONFIG",), "prompt": ("STRING", {"multiline": True}), - "model": (["gemini-2.0-flash", "gemini-2.0-flash-exp", "gemini-2.0-pro"], {"default": "gemini-2.0-flash"}), + "system_instruction": ("STRING", {"default": "You are a helpful AI assistant.", "multiline": True}), + "model": (["gemini-1.0-pro", "gemini-exp-1206", "gemini-1.5-flash", "gemini-1.5-pro", "gemini-2.0-flash", "gemini-2.0-flash-lite-001", "gemini-2.0-flash-exp", "gemini-2.0-pro", "gemini-2.0-pro-exp-02-05"], {"default": "gemini-2.0-flash"}), "temperature": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}), "top_p": ("FLOAT", {"default": 0.95, "min": 0.0, "max": 1.0, "step": 0.01}), "top_k": ("INT", {"default": 40, "min": 1, "max": 100, "step": 1}), @@ -111,7 +112,7 @@ class SSL_GeminiTextPrompt: tensor = torch.from_numpy(empty_image).unsqueeze(0) return tensor - def generate(self, config, prompt, model, temperature, top_p, top_k, max_output_tokens, include_images, + def generate(self, config, prompt, system_instruction, model, temperature, top_p, top_k, max_output_tokens, include_images, input_image=None, input_image_2=None, use_proxy="False", proxy_host="127.0.0.1", proxy_port=7890, use_seed="True", seed=0): original_http_proxy = os.environ.get('HTTP_PROXY') @@ -290,7 +291,28 @@ class SSL_GeminiTextPrompt: top_p=top_p, top_k=top_k, max_output_tokens=max_output_tokens, + safety_settings=[ + types.SafetySetting( + category="HARM_CATEGORY_HARASSMENT", + threshold="BLOCK_NONE", # Block none + ), + types.SafetySetting( + category="HARM_CATEGORY_HATE_SPEECH", + threshold="BLOCK_NONE", # Block none + ), + types.SafetySetting( + category="HARM_CATEGORY_SEXUALLY_EXPLICIT", + threshold="BLOCK_NONE", # Block none + ), + types.SafetySetting( + category="HARM_CATEGORY_DANGEROUS_CONTENT", + threshold="BLOCK_NONE", # Block none + ), + ], response_modalities=response_modalities, + system_instruction=[ + types.Part.from_text(text=system_instruction), + ], ) if use_seed == "True" and actual_seed is not None: @@ -387,9 +409,9 @@ class SSL_GeminiTextPrompt: if image_tensor is None: image_tensor = self.generate_empty_image() - if use_seed == "True" and actual_seed is not None: - seed_info = f"\n\n[种子信息: {actual_seed}]" - text_output += seed_info + # if use_seed == "True" and actual_seed is not None: + # seed_info = f"\n\n[种子信息: {actual_seed}]" + # text_output += seed_info return (text_output, image_tensor, actual_seed if actual_seed is not None else 0) finally: diff --git a/pyproject.toml b/pyproject.toml index d258fd3..4b072e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,15 @@ [project] -name = "ssl_gemini_exp" -description = "Calling gemini2.0 at comfyui . The project will continue to organize good APIs!" +name = "ComfyUI_Gemini_Expanded_API" +description = "Node for usage of Gemini API" version = "1.0.2" license = {file = "LICENSE"} dependencies = ["google-genai", "numpy", "torch"] [project.urls] -Repository = "https://github.com/tatookan/comfyui_ssl_gemini_EXP" +Repository = "https://github.com/silveroxides/comfyui_ssl_gemini_EXP" # Used by Comfy Registry https://comfyregistry.org [tool.comfy] -PublisherId = "tatookan" -DisplayName = "comfyui_ssl_gemini_EXP" +PublisherId = "silveroxides" +DisplayName = "ComfyUI Gemini Expanded API" Icon = ""