llm节点支持链接分析

This commit is contained in:
yp
2025-09-07 17:25:35 +08:00
parent aeec2f1939
commit e35664c204
4 changed files with 85 additions and 8 deletions

View File

@@ -28,7 +28,7 @@ def handler_google_analytics(prompt: str, model_id: str, media_file_path: str, b
if media_file_path and os.path.exists(media_file_path):
files['img_file'] = (os.path.basename(media_file_path), open(media_file_path, 'rb'),
mimetypes.guess_type(media_file_path)[0] or 'application/octet-stream')
if media_file_path.startswith("gs:"):
if bool(media_file_path) and media_file_path.startswith("gs:"):
files['img_url'] = (None, media_file_path)
try:
response = requests.post(f'{base_url}/api/llm/google/analysis', headers=headers, files=files,
@@ -62,7 +62,7 @@ class LLMUionNode:
"video": ("*",),
"image": ("IMAGE",),
"audio": ("AUDIO",),
"url": ("STRING", {"multiline": True, "default": "", "placeholder": "【可选】输入要分析的链接"}),
"url": ("STRING", {"multiline": True, "default": None, "placeholder": "【可选】输入要分析的链接"}),
"environment": (s.ENVIRONMENTS,),
"timeout": ("INT", {"default": 300, "min": 10, "max": 1200}),
}
@@ -155,7 +155,7 @@ class LLMUionNode:
timeout=300):
base_url = self.ENV_URLS.get(environment, self.ENV_URLS["prod"])
media_path = None
url = url.strip()
if video is not None:
if 'gemini' not in model_name:
raise ValueError(f'{model_name}暂不支持视频分析,\n请使用gemini-2.5-flash或者gemini-2.5-pro')
@@ -180,7 +180,6 @@ class LLMUionNode:
media_path = full_path
else:
return (f"错误: 无法在 'input' 文件夹中找到文件 '{unwrapped_input}'",)
elif image is not None:
print('多模态处理图片输出...')
pil_image = self.tensor_to_pil(image)
@@ -218,7 +217,7 @@ class LLMUionNode:
else:
return (f"错误: 不支持的音频输入格式或结构。收到类型: {type(audio_info)}",)
elif url is not None:
elif url:
url = url.strip()
model_name = model_name.strip()
is_google = model_name.startswith('gemini')