Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Change the URL on line 40 to wherever you host your Kobold API.
- class z_local_llm_text:
- def __init__(self):
- pass
- @classmethod
- def INPUT_TYPES(s):
- return {
- "required": {
- "llmQuery": ("STRING", {
- "default": "",
- "display": "text"
- }),
- "maxLength": ("INT", {
- "default": 100,
- "display": "number"
- }),
- "seed": ("INT", {
- # This is only included so that you can drive a new prompt in large batch workflows.
- # Hook up a seed to it, and every time the seed changes, it will re-request to the LLM.
- "default": 7331,
- "step": 1, #Slider's step
- "display": "number" # Cosmetic only: display as "number" or "slider"
- }),
- },
- }
- RETURN_TYPES = ("STRING",)
- RETURN_NAMES = ("LLM Response",)
- FUNCTION = "zllt"
- CATEGORY = "zaq_nodes"
- def zllt(self, llmQuery, maxLength, seed):
- import requests, json, string
- # This is not the default port. I have a 3060 and a 3090 in my ComfyUI box, so I used port 3060 for Kobold. Har har.
- url = 'http://localhost:3060/api/v1/generate'
- kobold = { "max_context_length": 2048, "max_length": maxLength, "prompt": llmQuery, "quiet": False, "rep_pen": 1.1, "rep_pen_range": 256, "rep_pen_slope": 1, "temperature": 0.5, "tfs": 1, "top_a": 0, "top_k": 100, "top_p": 0.9, "typical": 1, "seed": seed }
- r2 = ""
- while len(r2) < 5:
- x1 = (requests.post(url, json=kobold))
- x2 = x1.text
- x3 = json.loads(x2)
- x4 = x3["results"][0]
- r1 = "" + x4["text"]
- r2 = r1.strip()
- return (r2,)
- # NOTE: names should be globally unique
- NODE_CLASS_MAPPINGS = {
- "z_local_llm_text": z_local_llm_text
- }
- NODE_DISPLAY_NAME_MAPPINGS = {
- "zllt": "z_local_llm_text"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement