Skip to content

using await fetch inside  #6

@xlinx

Description

@xlinx

Hi great plugin author, thx ur plugin make prompt so powerful.
Im using it to call LLM generate more content for prompt by JS await fetch(), found some issues as follow:

1.the plugin use await fetch, (SD) will wait fetch method then render pic,
2. but webui didnt get the return value form LLM
3. the attachment red box is return content, but SD still using the JS code content not return content

Q1. How get correct way return value --sloved
Q2. Is it possible use last time variable? like: last one return value
Q3 Keep return value, When batch size set 2 or more:
the script will call 2 or more times; how keep only call js one time use same return value when SD batch size set 2 ?
Ihave trying so many different type return method, but still not lucky.
How get return value for prompt, big thX~

%% {
          result = await fetch('http://localhost:1234/v1/chat/completions', {
            method: 'POST',
            body: JSON.stringify({
                "messages":[
                    {
                        "role": "system",
                        "content": "You are an AI prompt word engineer. Use the provided keywords to create a beautiful composition. You only need the prompt words, not your feelings. Customize the style, scene, decoration, etc., and be as detailed as possible."
                    },
                    {"role": "user", "content": "a superstar on stage"}
                ],
                "temperature": 0.7,
                "max_tokens": -1,
                "stream": false
            }),
            headers: {
                'Content-Type': 'application/json'
            }
        }).then(res => {
            return res.json();
        }).then(result => {
            return result['choices'][0]['message']['content'];
        });
         return result;
} %%

js prompt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions