From bafd400040cf5aa8648166ccfaff2e77b78b7316 Mon Sep 17 00:00:00 2001 From: chflame163 Date: Sat, 28 Dec 2024 20:41:49 +0800 Subject: [PATCH] requirements.txt remove zhipuai --- py/zhipu_glm4.py | 126 ----------------------------------------------- pyproject.toml | 2 +- requirements.txt | 4 +- 3 files changed, 2 insertions(+), 130 deletions(-) delete mode 100644 py/zhipu_glm4.py diff --git a/py/zhipu_glm4.py b/py/zhipu_glm4.py deleted file mode 100644 index af1958f..0000000 --- a/py/zhipu_glm4.py +++ /dev/null @@ -1,126 +0,0 @@ -# layerstyle advance -import os -import torch -import base64 -import requests -from io import BytesIO - -import folder_paths -from PIL import Image -from .imagefunc import log, tensor2pil, get_api_key - - -# apikey申请地址:https://bigmodel.cn/usercenter/proj-mgmt/apikeys -class LS_ZhipuImage: - - def __init__(self): - self.NODE_NAME = 'ZhipuGLM4V' - - @classmethod - def INPUT_TYPES(cls): - glm_model_list = ["glm-4v-flash", "glm-4v", "glm-4v-plus"] - return {"required":{ - "image": ("IMAGE",), - "model": (glm_model_list,), - "user_prompt": ("STRING", {"default": "describe this image", "multiline": True}), - }, - "optional": { - } - } - - RETURN_TYPES = ("STRING",) - RETURN_NAMES = ("text",) - FUNCTION = "zhipu_glm4v" - CATEGORY = '😺dzNodes/LayerUtility' - - def zhipu_glm4v(self, image, model, user_prompt,): - from zhipuai import ZhipuAI - client = ZhipuAI(api_key=get_api_key('zhipu_api_key')) # APIKey - - - img = tensor2pil(image).convert('RGB') - - img_data = BytesIO() - img.save(img_data, format="JPEG") - img_url = base64.b64encode(img_data.getvalue()).decode("utf-8") - - messages = [ - {"role": "user", - "content": [ - {"type": "text", - "text": user_prompt - }, - {"type": "image_url", - "image_url": {"url": img_url} - } - ] - } - - ] - - response = client.chat.completions.create( - model=model, # 填写需要调用的模型名称 - messages=messages - ) - ret_message = response.choices[0].message.content - log(f"{self.NODE_NAME} response is: {ret_message}") - - return (ret_message,) - -class LS_ZhipuText: - - def __init__(self): - self.NODE_NAME = 'ZhipuGLM4' - - @classmethod - def INPUT_TYPES(cls): - glm_model_list = ["GLM-4-Flash", "GLM-4-FlashX", "GLM-4-Plus", "GLM-4-Long","GLM-4-Air", "GLM-4-AirX"] - return {"required":{ - "model": (glm_model_list,), - "user_prompt": ("STRING", {"default": "where is the capital of France?", "multiline": True}), - "history_length": ("INT", {"default": 8, "min": 1, "max": 64, "step": 1}), - }, - "optional": { - "history": ("GLM4_HISTORY",), - } - } - - RETURN_TYPES = ("STRING", "GLM4_HISTORY",) - RETURN_NAMES = ("text", "history",) - FUNCTION = "zhipu_glm4" - CATEGORY = '😺dzNodes/LayerUtility' - - def zhipu_glm4(self, model, user_prompt, history_length, history=None): - - from zhipuai import ZhipuAI - client = ZhipuAI(api_key=get_api_key('zhipu_api_key')) # APIKey - - if history is not None: - messages = history["messages"] - messages = messages[-history_length *2:] - else: - messages = [] - task = {"role": "user", "content": user_prompt} - messages.append(task) - - response = client.chat.completions.create( - model=model, # 填写需要调用的模型名称 - messages=messages - ) - ret_message = response.choices[0].message.content - messages.append({"role": "assistant", "content": ret_message}) - log(f"{self.NODE_NAME} response is: {ret_message}") - - return (ret_message, {"messages":messages},) - - -NODE_CLASS_MAPPINGS = { - "LayerUtility: ZhipuGLM4V": LS_ZhipuImage, - "LayerUtility: ZhipuGLM4": LS_ZhipuText, -} - -NODE_DISPLAY_NAME_MAPPINGS = { - "LayerUtility: ZhipuGLM4V": "LayerUtility: ZhipuGLM4V(Advance)", - "LayerUtility: ZhipuGLM4": "LayerUtility: ZhipuGLM4(Advance)", -} - diff --git a/pyproject.toml b/pyproject.toml index a831c10..602a0e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui_layerstyle_advance" description = "The nodes detached from ComfyUI Layer Style are mainly those with complex requirements for dependency packages." -version = "2.0.10" +version = "2.0.11" license = "MIT" dependencies = ["numpy", "matplotlib", "scikit_image", "scikit_learn", "opencv-contrib-python", "pymatting", "timm", "blend_modes", "transformers", "diffusers", "loguru", "colour-science", "huggingface_hub", "segment_anything", "addict", "omegaconf", "yapf", "wget", "iopath", "mediapipe", "typer_config", "fastapi", "rich", "google-generativeai", "ultralytics", "transparent-background", "accelerate", "onnxruntime", "bitsandbytes", "peft", "protobuf", "hydra-core", "blind-watermark", "qrcode", "pyzbar", "psd-tools", "wandb"] diff --git a/requirements.txt b/requirements.txt index 5b9633a..8902fac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,6 +32,4 @@ protobuf hydra-core blind-watermark qrcode -pyzbar -psd-tools -zhipuai \ No newline at end of file +pyzbar \ No newline at end of file