Skip to content

replicate.stream(...) is not a function or its return value is not async iterable #88

@hsmandavi111

Description

@hsmandavi111

// import Replicate from "replicate";
require('dotenv').config();

const Replicate = require("replicate");

console.log(process.env.REPLICATE_API_TOKEN);

async function fetchData() {

const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});

const input = {
debug: false,
top_k: -1,
top_p: 1,
prompt: "Tell me how to tailor a men's suit so I look fashionable.",
temperature: 0.75,
system_prompt: "You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.",
max_new_tokens: 800,
min_new_tokens: -1,
repetition_penalty: 1
};

for await (const event of replicate.stream("meta/llama-2-7b-chat", { input })) {
process.stdout.write(event.toString());
};
}

fetchData();

I am trying to run above code but getting error

for await (const event of replicate.stream("meta/llama-2-7b-chat", { input })) {
^

TypeError: replicate.stream(...) is not a function or its return value is not async iterable
at fetchData (H:\ANM\chatbot-backend\Llama_API.js:38:39)
at Object. (H:\ANM\chatbot-backend\Llama_API.js:43:3)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions