mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-04 14:47:09 +08:00
First commit
This commit is contained in:
parent
bab836d88d
commit
c14a400e45
71
comfy_api_nodes/nodes_vertex_gemini.py
Normal file
71
comfy_api_nodes/nodes_vertex_gemini.py
Normal file
@ -0,0 +1,71 @@
|
||||
from inspect import cleandoc
|
||||
from google import genai
|
||||
from google.genai.types import HttpOptions
|
||||
|
||||
from comfy.comfy_types.node_typing import IO, ComfyNodeABC, InputTypeDict
|
||||
from comfy_api_nodes.apinode_utils import validate_string
|
||||
from server import PromptServer
|
||||
|
||||
|
||||
class VertexGeminiAPI(ComfyNodeABC):
|
||||
"""
|
||||
Generates images synchronously via OpenAI's GPT Image 1 endpoint.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> InputTypeDict:
|
||||
return {
|
||||
"required": {
|
||||
"prompt": (
|
||||
IO.STRING,
|
||||
{
|
||||
"multiline": True,
|
||||
"default": "",
|
||||
"tooltip": "Text prompt for GPT Image 1",
|
||||
},
|
||||
),
|
||||
"model": (
|
||||
IO.STRING,
|
||||
{
|
||||
"default": "gemini-2.0-flash-001",
|
||||
"tooltip": "The gemini model to use"
|
||||
}
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = (IO.STRING,)
|
||||
FUNCTION = "api_call"
|
||||
CATEGORY = "api node/text/gemini/vertex"
|
||||
DESCRIPTION = cleandoc(__doc__ or "")
|
||||
API_NODE = True
|
||||
|
||||
def api_call(
|
||||
self,
|
||||
prompt,
|
||||
model="gemini-2.0-flash-001",
|
||||
**kwargs
|
||||
):
|
||||
validate_string(prompt, strip_whitespace=False)
|
||||
client = genai.Client(http_options=HttpOptions(api_version="v1"))
|
||||
response = client.models.generate_content(
|
||||
model=model,
|
||||
contents=prompt,
|
||||
)
|
||||
print(response.text)
|
||||
PromptServer.instance.send_progress_text(response.text)
|
||||
return response.text
|
||||
|
||||
# A dictionary that contains all nodes you want to export with their names
|
||||
# NOTE: names should be globally unique
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"VertexGeminiAPI": VertexGeminiAPI,
|
||||
}
|
||||
|
||||
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"VertexGeminiAPI": "VertexGeminiAPI",
|
||||
}
|
||||
1
nodes.py
1
nodes.py
@ -2280,6 +2280,7 @@ def init_builtin_api_nodes():
|
||||
api_nodes_files = [
|
||||
"nodes_ideogram.py",
|
||||
"nodes_openai.py",
|
||||
"nodes_vertex_gemini.py",
|
||||
"nodes_minimax.py",
|
||||
"nodes_veo2.py",
|
||||
"nodes_kling.py",
|
||||
|
||||
@ -17,6 +17,7 @@ Pillow
|
||||
scipy
|
||||
tqdm
|
||||
psutil
|
||||
google-genai
|
||||
|
||||
#non essential dependencies:
|
||||
kornia>=0.7.1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user