Runware / sdk-js

Javascript SDK for integrating the runware.ai web sockets API
5 stars 0 forks source link

[Question] Having a problem getting this going #3

Closed dep closed 2 months ago

dep commented 2 months ago

Does this look correct as far as import goes? One thing missing from the README is how to import the library, which might seem obvious for some but others could struggle.

import { Runware } from "@runware/sdk-js";

export default defineComponent({
    const runware = new Runware({ apiKey: process.env.RUNWARE_API_KEY });

    const [firstImagesRequest, secondImagesRequest] = await Promise.all([
        runware.requestImages({
            positivePrompt: "hello world",
            height: 768,
            width: 512,
            model: 1,
            numberOfImages: 1,
            negativePrompt: "foobars",
        }),
    ])
    console.log({firstImagesRequest, secondImagesRequest})
});
YomiCasual commented 2 months ago

Thanks for the feedback @dep

We will update the SDK to include the import

Also if you are making images with the same prompt, you don't need to send two request, you can just increase the numberResults.

Also the negativePrompt is not required. It is only needed if you want to add a negative prompt.

 const images = await  runware.requestImages({
            positivePrompt: "hello world",
            height: 768,
            width: 512,
            model: 1,
            numberResults: 6,
            negativePrompt: "foobars",
        })

 console.log({Images})

Please, let us know if you have been able to resolve your blockers. Thanks

vanheerdena commented 2 months ago
 require('dotenv').config();
const { RunwareServer } = require('@runware/sdk-js'); 
const runware = new RunwareServer({ apiKey: process.env.RUNWARE_AI_API_TOKEN });

(async () => {
    const images = await  runware.requestImages({
        positivePrompt: "hello world",
        height: 768,
        width: 512,
        model: 1,
        numberResults: 6,
        negativePrompt: "foobars",
    })
    console.log({images})
})(); 

Gives me this error: \@runware\sdk-js\dist\index.js:886 images = images.map((image) => spreadProps(spreadValues({}, image), { ^

TypeError: Cannot read properties of undefined (reading 'map')

Any ideas how to fix this using node.js?

YomiCasual commented 2 months ago
 require('dotenv').config();
const { RunwareServer } = require('@runware/sdk-js'); 
const runware = new RunwareServer({ apiKey: process.env.RUNWARE_AI_API_TOKEN });

(async () => {
    const images = await  runware.requestImages({
        positivePrompt: "hello world",
        height: 768,
        width: 512,
        model: 1,
        numberResults: 6,
        negativePrompt: "foobars",
    })
    console.log({images})
})(); 

Gives me this error: @Runware\sdk-js\dist\index.js:886 images = images.map((image) => spreadProps(spreadValues({}, image), { ^

TypeError: Cannot read properties of undefined (reading 'map')

Any ideas how to fix this using node.js?

@vanheerdena, You are using a wrong model

Can you please try with runware:100@1.

We have also pushed a fix for the SDK and you should get the proper error now.

Please, let us know if you have been able to resolve your blockers. Thanks

vanheerdena commented 2 months ago

Thank you for the quick reply and fix. Using runware:100@1 as the model does indeed work (is there some resource to figure out these model ids?). However when I switched (as your document described to AIR identifiers) I cannot get an image to be returned. Could you please assist with the second issue please. I'm really looking forward to getting this working.

return runware.requestImages(
            {
                "taskType": "imageInference",
                "taskUUID": uuidv4(),
                "positivePrompt": prompt,
                "model": "civitai:618692@691639", //DOES NOT WORK
                //"model": "urn:air:flux1:checkpoint:civitai:618692@691639", - DOES NOT WORK
                //"model": "runware:100@1", - WORKS
                "height": 640,
                "width": 640,
                "numberResults": 1,
                "outputType": "URL",

                "includeCost": true,
                //HAVEN'T TESTED YET
                // "lora": [
                //     {
                //         "model": "urn:air:flux1:checkpoint:civitai:655408@733261",
                //         "weight": 1.0
                //     }
                // ]
            }
        ).catch((error) => {
            console.error("Error running image inference:", error);
            return null;
        });
YomiCasual commented 2 months ago

Thank you for the quick reply and fix. Using runware:100@1 as the model does indeed work (is there some resource to figure out these model ids?). However when I switched (as your document described to AIR identifiers) I cannot get an image to be returned. Could you please assist with the second issue please. I'm really looking forward to getting this working.

return runware.requestImages(
            {
                "taskType": "imageInference",
                "taskUUID": uuidv4(),
                "positivePrompt": prompt,
                "model": "civitai:618692@691639", //DOES NOT WORK
                //"model": "urn:air:flux1:checkpoint:civitai:618692@691639", - DOES NOT WORK
                //"model": "runware:100@1", - WORKS
                "height": 640,
                "width": 640,
                "numberResults": 1,
                "outputType": "URL",

                "includeCost": true,
                //HAVEN'T TESTED YET
                // "lora": [
                //     {
                //         "model": "urn:air:flux1:checkpoint:civitai:655408@733261",
                //         "weight": 1.0
                //     }
                // ]
            }
        ).catch((error) => {
            console.error("Error running image inference:", error);
            return null;
        });

Hello @vanheerdena, can you please use this model runware:101@1. It is equivalent to civitai:618692@691639.

Please, let us know if you have been able to resolve your blockers. Thanks

vanheerdena commented 2 months ago

Thank you, that works perfectly! If I needed a different civitai model for the lora, could I use the AIR code or do I need to request for each to be given a runware id?

YomiCasual commented 2 months ago

Hello @vanheerdena, some of these models are heavy and take some time before they are fully downloaded on first use. But if you need a compatible AIR code that has already been downloaded, Feel free to reach out to us to give you a compatible runware id that is already downloaded.

Thanks

dep commented 2 months ago

Thanks all. The leads here helped me get a 200 back. I'm in business! This ticket can probably be closed.

YomiCasual commented 2 months ago

I am closing this issue now, since all blockers have been resolved.