|
63 | 63 | $m := widgets.model; |
64 | 64 | $r := widgets.resolution; |
65 | 65 | $isFlash := $contains($m, "nano banana 2"); |
66 | | - $flashPrices := {"1k": 0.0696, "2k": 0.0696, "4k": 0.123}; |
| 66 | + $flashPrices := {"1k": 0.0696, "2k": 0.1014, "4k": 0.154}; |
67 | 67 | $proPrices := {"1k": 0.134, "2k": 0.134, "4k": 0.24}; |
68 | 68 | $prices := $isFlash ? $flashPrices : $proPrices; |
69 | 69 | {"type":"usd","usd": $lookup($prices, $r), "format":{"suffix":"/Image","approximate":true}} |
@@ -188,10 +188,12 @@ def get_text_from_response(response: GeminiGenerateContentResponse) -> str: |
188 | 188 | return "\n".join([part.text for part in parts]) |
189 | 189 |
|
190 | 190 |
|
191 | | -async def get_image_from_response(response: GeminiGenerateContentResponse) -> Input.Image: |
| 191 | +async def get_image_from_response(response: GeminiGenerateContentResponse, thought: bool = False) -> Input.Image: |
192 | 192 | image_tensors: list[Input.Image] = [] |
193 | 193 | parts = get_parts_by_type(response, "image/*") |
194 | 194 | for part in parts: |
| 195 | + if (part.thought is True) != thought: |
| 196 | + continue |
195 | 197 | if part.inlineData: |
196 | 198 | image_data = base64.b64decode(part.inlineData.data) |
197 | 199 | returned_image = bytesio_to_image_tensor(BytesIO(image_data)) |
@@ -931,6 +933,11 @@ def define_schema(cls): |
931 | 933 | outputs=[ |
932 | 934 | IO.Image.Output(), |
933 | 935 | IO.String.Output(), |
| 936 | + IO.Image.Output( |
| 937 | + display_name="thought_image", |
| 938 | + tooltip="First image from the model's thinking process. " |
| 939 | + "Only available with thinking_level HIGH and IMAGE+TEXT modality.", |
| 940 | + ), |
934 | 941 | ], |
935 | 942 | hidden=[ |
936 | 943 | IO.Hidden.auth_token_comfy_org, |
@@ -992,7 +999,11 @@ async def execute( |
992 | 999 | response_model=GeminiGenerateContentResponse, |
993 | 1000 | price_extractor=calculate_tokens_price, |
994 | 1001 | ) |
995 | | - return IO.NodeOutput(await get_image_from_response(response), get_text_from_response(response)) |
| 1002 | + return IO.NodeOutput( |
| 1003 | + await get_image_from_response(response), |
| 1004 | + get_text_from_response(response), |
| 1005 | + await get_image_from_response(response, thought=True), |
| 1006 | + ) |
996 | 1007 |
|
997 | 1008 |
|
998 | 1009 | class GeminiExtension(ComfyExtension): |
|
0 commit comments