cohere-ai / cohere-typescript

The Cohere TypeScript SDK
https://docs.cohere.ai
MIT License
122 stars 18 forks source link

Module '"cohere-ai"' has no exported member 'CohereClient' #98

Closed TephrosisDEV closed 10 months ago

TephrosisDEV commented 11 months ago

Hello,

I'm trying to use the chat functionality of Cohere. I copied the example code, but I get this error: Module '"cohere-ai"' has no exported member 'CohereClient'. Is the example outdated? If so, what's the correct way to use the chatStream functionality?

When I check the file I only see these accessible functions:

import { CohereClient } from "cohere-ai";

const cohere = new CohereClient({
    token: process.env.COHERE_API_KEY || '',
});

(async () => {
    const stream = await cohere.chatStream({
        model: "command",
        message: "Tell me a story in 5 parts!",
    });

    for await (const chat of stream) {
        if (chat.eventType === "text-generation") {
            process.stdout.write(chat.text);
        }
    }
})();
dsinghvi commented 10 months ago

@TephrosisDEV I setup a working version of the SDK in Stackblitz. You should be able to access chatStream and import CohereClient.

Let me know if that works for you!

TephrosisDEV commented 10 months ago

That helped a lot. I saw your version was 7.1.1, while mine was only 6.2.2 Now I have all autocomplete and I can experiment again. Thanks a lot!