1 Star 0 Fork 15

雪狐/ComfyUI_Lam_1

forked from yanlang0123/ComfyUI_Lam 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
GLM3Prompt.py 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
马噥 提交于 2023-11-22 09:54 +08:00 . 添加chatGLM3插件
import json
import openai
class GLM3Prompt:
"""
ChatGLM3接口调用
"""
def __init__(self):
pass
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"glm3_url": ("STRING",{"default": "http://localhost:8000/v1"}),
"system_prompt": ("STRING", {"multiline": True,"default":"你是名绘图提示词专家,你会根据客户的描述内容,精确返回对应图片提示,注意提示词必须是英文"}),
"text": ("STRING", {"multiline": True})
},
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("提示词",)
FUNCTION = "translate"
#OUTPUT_NODE = False
CATEGORY = "lam"
def translate(self, glm3_url,system_prompt,text):
openai.api_base = glm3_url
openai.api_key = "xxx"
params = dict(model="chatglm3", messages=[{"role": "system", "content": system_prompt},{"role": "user", "content": text}], stream=False)
response = openai.ChatCompletion.create(**params)
reply = response.choices[0].message.content
return (reply,)
# A dictionary that contains all nodes you want to export with their names
# NOTE: names should be globally unique
NODE_CLASS_MAPPINGS = {
"GLM3Prompt": GLM3Prompt
}
# A dictionary that contains the friendly/humanly readable titles for the nodes
NODE_DISPLAY_NAME_MAPPINGS = {
"GLM3Prompt": "ChatGLM3提示词生成工具"
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/assassindesign/ComfyUI_Lam_1.git
git@gitee.com:assassindesign/ComfyUI_Lam_1.git
assassindesign
ComfyUI_Lam_1
ComfyUI_Lam_1
cu121

搜索帮助