代码拉取完成,页面将自动刷新
同步操作将从 yanlang0123/ComfyUI_Lam 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
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提示词生成工具"
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。