requirements.txt remove zhipuai

This commit is contained in:
chflame163
2024-12-28 20:41:49 +08:00
parent b090d94d12
commit bafd400040
3 changed files with 2 additions and 130 deletions
-126
View File
@@ -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)",
}
+1 -1
View File
@@ -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"]
+1 -3
View File
@@ -32,6 +32,4 @@ protobuf
hydra-core
blind-watermark
qrcode
pyzbar
psd-tools
zhipuai
pyzbar