feat: 新增 Grok 图像节点、前端 UI 增强、重构 nano-banana 系列
- 新增 Grok Image 节点及客户端 - 新增 save_image_format 节点 - 新增前端 JS 扩展:画笔工具、点阵网格、侧边栏隐藏、资源切换、重命名等 - 重构 nano-banana 节点,移除 pro 版本 - 移除 multi_res_preview 节点 - 新增 http_error 工具模块 - 各客户端和节点优化改进 Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
@@ -187,6 +187,7 @@ class GeminiAPIClient(BaseAPIClient):
|
||||
enable_grounding: bool = False,
|
||||
enable_image_search: bool = False,
|
||||
image_compression: str = None,
|
||||
thinking_level: str = None,
|
||||
**kwargs
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
@@ -227,15 +228,15 @@ class GeminiAPIClient(BaseAPIClient):
|
||||
})
|
||||
|
||||
# 估算完整 body 大小(不含工具字段,工具字段很小可忽略)
|
||||
est_image_config = {"imageSize": resolution}
|
||||
if aspect_ratio and aspect_ratio != "智能":
|
||||
est_image_config["aspectRatio"] = aspect_ratio
|
||||
estimated = self._estimate_body_size(
|
||||
parts + img_parts,
|
||||
{
|
||||
"generationConfig": {
|
||||
"responseModalities": ["IMAGE"],
|
||||
"imageConfig": {
|
||||
"aspectRatio": aspect_ratio,
|
||||
"imageSize": resolution
|
||||
}
|
||||
"imageConfig": est_image_config
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -267,6 +268,10 @@ class GeminiAPIClient(BaseAPIClient):
|
||||
parts.extend(img_parts)
|
||||
|
||||
# 构建请求体
|
||||
image_config = {"imageSize": resolution}
|
||||
if aspect_ratio and aspect_ratio != "智能":
|
||||
image_config["aspectRatio"] = aspect_ratio
|
||||
|
||||
request_body = {
|
||||
"contents": [
|
||||
{
|
||||
@@ -276,13 +281,17 @@ class GeminiAPIClient(BaseAPIClient):
|
||||
],
|
||||
"generationConfig": {
|
||||
"responseModalities": ["IMAGE"],
|
||||
"imageConfig": {
|
||||
"aspectRatio": aspect_ratio,
|
||||
"imageSize": resolution
|
||||
}
|
||||
"imageConfig": image_config
|
||||
}
|
||||
}
|
||||
|
||||
# 添加思考深度配置
|
||||
if thinking_level:
|
||||
request_body["generationConfig"]["thinkingConfig"] = {
|
||||
"thinkingLevel": thinking_level,
|
||||
"includeThoughts": True
|
||||
}
|
||||
|
||||
# 添加图片压缩参数
|
||||
if image_compression:
|
||||
request_body["image_compression"] = image_compression
|
||||
@@ -564,6 +573,7 @@ class GeminiAPIClient(BaseAPIClient):
|
||||
enable_grounding: bool = False,
|
||||
enable_image_search: bool = False,
|
||||
image_format: str = "base64",
|
||||
thinking_level: str = None,
|
||||
) -> tuple[List[Image.Image], Dict[str, Any]]:
|
||||
"""
|
||||
单次异步生成请求(极简单行日志)
|
||||
@@ -602,6 +612,7 @@ class GeminiAPIClient(BaseAPIClient):
|
||||
resolution=resolution,
|
||||
enable_grounding=enable_grounding,
|
||||
enable_image_search=enable_image_search,
|
||||
thinking_level=thinking_level,
|
||||
)
|
||||
build_time = time.time() - build_start
|
||||
|
||||
@@ -737,6 +748,7 @@ class GeminiAPIClient(BaseAPIClient):
|
||||
enable_grounding: bool = False,
|
||||
enable_image_search: bool = False,
|
||||
image_format: str = "base64",
|
||||
thinking_level: str = None,
|
||||
) -> List[Image.Image]:
|
||||
"""
|
||||
批量全并发生成 - 改进版:支持分批处理和内存管理
|
||||
@@ -801,6 +813,7 @@ class GeminiAPIClient(BaseAPIClient):
|
||||
enable_grounding=enable_grounding,
|
||||
enable_image_search=enable_image_search,
|
||||
image_format=image_format,
|
||||
thinking_level=thinking_level,
|
||||
),
|
||||
name=f"task_{task_index}"
|
||||
)
|
||||
@@ -873,6 +886,7 @@ class GeminiAPIClient(BaseAPIClient):
|
||||
enable_grounding: bool = False,
|
||||
enable_image_search: bool = False,
|
||||
image_format: str = "base64",
|
||||
thinking_level: str = None,
|
||||
) -> List[Image.Image]:
|
||||
"""
|
||||
同步生成接口(用于 ComfyUI)
|
||||
@@ -906,6 +920,7 @@ class GeminiAPIClient(BaseAPIClient):
|
||||
enable_grounding=enable_grounding,
|
||||
enable_image_search=enable_image_search,
|
||||
image_format=image_format,
|
||||
thinking_level=thinking_level,
|
||||
)
|
||||
|
||||
return self.run_async_in_thread(coro)
|
||||
|
||||
Reference in New Issue
Block a user