mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-08 02:37:42 +08:00
feat(api-nodes): add Gemini 3.1 Flash Lite model to LLM node (#12803)
Some checks are pending
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
Some checks are pending
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
This commit is contained in:
parent
3b93d5d571
commit
34e55f0061
@ -72,18 +72,6 @@ GEMINI_IMAGE_2_PRICE_BADGE = IO.PriceBadge(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class GeminiModel(str, Enum):
|
|
||||||
"""
|
|
||||||
Gemini Model Names allowed by comfy-api
|
|
||||||
"""
|
|
||||||
|
|
||||||
gemini_2_5_pro_preview_05_06 = "gemini-2.5-pro-preview-05-06"
|
|
||||||
gemini_2_5_flash_preview_04_17 = "gemini-2.5-flash-preview-04-17"
|
|
||||||
gemini_2_5_pro = "gemini-2.5-pro"
|
|
||||||
gemini_2_5_flash = "gemini-2.5-flash"
|
|
||||||
gemini_3_0_pro = "gemini-3-pro-preview"
|
|
||||||
|
|
||||||
|
|
||||||
class GeminiImageModel(str, Enum):
|
class GeminiImageModel(str, Enum):
|
||||||
"""
|
"""
|
||||||
Gemini Image Model Names allowed by comfy-api
|
Gemini Image Model Names allowed by comfy-api
|
||||||
@ -237,10 +225,14 @@ def calculate_tokens_price(response: GeminiGenerateContentResponse) -> float | N
|
|||||||
input_tokens_price = 0.30
|
input_tokens_price = 0.30
|
||||||
output_text_tokens_price = 2.50
|
output_text_tokens_price = 2.50
|
||||||
output_image_tokens_price = 30.0
|
output_image_tokens_price = 30.0
|
||||||
elif response.modelVersion == "gemini-3-pro-preview":
|
elif response.modelVersion in ("gemini-3-pro-preview", "gemini-3.1-pro-preview"):
|
||||||
input_tokens_price = 2
|
input_tokens_price = 2
|
||||||
output_text_tokens_price = 12.0
|
output_text_tokens_price = 12.0
|
||||||
output_image_tokens_price = 0.0
|
output_image_tokens_price = 0.0
|
||||||
|
elif response.modelVersion == "gemini-3.1-flash-lite-preview":
|
||||||
|
input_tokens_price = 0.25
|
||||||
|
output_text_tokens_price = 1.50
|
||||||
|
output_image_tokens_price = 0.0
|
||||||
elif response.modelVersion == "gemini-3-pro-image-preview":
|
elif response.modelVersion == "gemini-3-pro-image-preview":
|
||||||
input_tokens_price = 2
|
input_tokens_price = 2
|
||||||
output_text_tokens_price = 12.0
|
output_text_tokens_price = 12.0
|
||||||
@ -292,8 +284,16 @@ class GeminiNode(IO.ComfyNode):
|
|||||||
),
|
),
|
||||||
IO.Combo.Input(
|
IO.Combo.Input(
|
||||||
"model",
|
"model",
|
||||||
options=GeminiModel,
|
options=[
|
||||||
default=GeminiModel.gemini_2_5_pro,
|
"gemini-2.5-pro-preview-05-06",
|
||||||
|
"gemini-2.5-flash-preview-04-17",
|
||||||
|
"gemini-2.5-pro",
|
||||||
|
"gemini-2.5-flash",
|
||||||
|
"gemini-3-pro-preview",
|
||||||
|
"gemini-3-1-pro",
|
||||||
|
"gemini-3-1-flash-lite",
|
||||||
|
],
|
||||||
|
default="gemini-3-1-pro",
|
||||||
tooltip="The Gemini model to use for generating responses.",
|
tooltip="The Gemini model to use for generating responses.",
|
||||||
),
|
),
|
||||||
IO.Int.Input(
|
IO.Int.Input(
|
||||||
@ -363,11 +363,16 @@ class GeminiNode(IO.ComfyNode):
|
|||||||
"usd": [0.00125, 0.01],
|
"usd": [0.00125, 0.01],
|
||||||
"format": { "approximate": true, "separator": "-", "suffix": " per 1K tokens" }
|
"format": { "approximate": true, "separator": "-", "suffix": " per 1K tokens" }
|
||||||
}
|
}
|
||||||
: $contains($m, "gemini-3-pro-preview") ? {
|
: ($contains($m, "gemini-3-pro-preview") or $contains($m, "gemini-3-1-pro")) ? {
|
||||||
"type": "list_usd",
|
"type": "list_usd",
|
||||||
"usd": [0.002, 0.012],
|
"usd": [0.002, 0.012],
|
||||||
"format": { "approximate": true, "separator": "-", "suffix": " per 1K tokens" }
|
"format": { "approximate": true, "separator": "-", "suffix": " per 1K tokens" }
|
||||||
}
|
}
|
||||||
|
: $contains($m, "gemini-3-1-flash-lite") ? {
|
||||||
|
"type": "list_usd",
|
||||||
|
"usd": [0.00025, 0.0015],
|
||||||
|
"format": { "approximate": true, "separator": "-", "suffix": " per 1K tokens" }
|
||||||
|
}
|
||||||
: {"type":"text", "text":"Token-based"}
|
: {"type":"text", "text":"Token-based"}
|
||||||
)
|
)
|
||||||
""",
|
""",
|
||||||
@ -436,12 +441,14 @@ class GeminiNode(IO.ComfyNode):
|
|||||||
files: list[GeminiPart] | None = None,
|
files: list[GeminiPart] | None = None,
|
||||||
system_prompt: str = "",
|
system_prompt: str = "",
|
||||||
) -> IO.NodeOutput:
|
) -> IO.NodeOutput:
|
||||||
validate_string(prompt, strip_whitespace=False)
|
if model == "gemini-3-pro-preview":
|
||||||
|
model = "gemini-3.1-pro-preview" # model "gemini-3-pro-preview" will be soon deprecated by Google
|
||||||
|
elif model == "gemini-3-1-pro":
|
||||||
|
model = "gemini-3.1-pro-preview"
|
||||||
|
elif model == "gemini-3-1-flash-lite":
|
||||||
|
model = "gemini-3.1-flash-lite-preview"
|
||||||
|
|
||||||
# Create parts list with text prompt as the first part
|
|
||||||
parts: list[GeminiPart] = [GeminiPart(text=prompt)]
|
parts: list[GeminiPart] = [GeminiPart(text=prompt)]
|
||||||
|
|
||||||
# Add other modal parts
|
|
||||||
if images is not None:
|
if images is not None:
|
||||||
parts.extend(await create_image_parts(cls, images))
|
parts.extend(await create_image_parts(cls, images))
|
||||||
if audio is not None:
|
if audio is not None:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user