Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createPrediction returns an iterable object, but no data is returned #1

Open
japentaca opened this issue Sep 25, 2024 · 1 comment
Open

Comments

@japentaca
Copy link

japentaca commented Sep 25, 2024

I tried to run the example in the readme file ( replacing the url and chatId)
"flowise-sdk": "^1.0.9",
node version: 20.15.0
SO: Windows

// changed this because the original code breaks. I'll made another issue about this.
import pkg from 'flowise-sdk';
const { FlowiseClient } = pkg

const flowise = new FlowiseClient({ baseUrl: 'http://localhost:3000' });

async function main() {
  const completion = await flowise.createPrediction({
    chatflowId: '<id>',
    question: "hello",
    streaming: true
  });

  for await (const chunk of completion) {
    console.log(chunk);
  }
}
main();

In the console, the completion object look like this

{
  [Symbol(Symbol.asyncIterator)]: [AsyncGeneratorFunction: [Symbol.asyncIterator]]
}

But the for await loop gets nothing and the script ends.

@japentaca
Copy link
Author

japentaca commented Sep 25, 2024

Just for clarifying, everything works OK calling it using Curl.

This works OK ( obviously, without streaming)


async function query(data) {
  const response = await fetch(
    "https://{my-url}/api/v1/prediction/{my chat id}",
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify(data)
    }
  );
  const result = await response.json();
  return result;
}

query({
  "question": "Hey, how are you?",
  "overrideConfig": {
    "returnSourceDocuments": true
  }
}).then((response) => {
  console.log(response);
});

@japentaca japentaca changed the title createPredicton returns an iterable object, but no data is returned createPrediction returns an iterable object, but no data is returned Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant