A class that enables calls to the Cloudflare Workers AI API to access large language models in a chat-like fashion. It extends the SimpleChatModel class and implements the CloudflareWorkersAIInput interface.

Example

const model = new ChatCloudflareWorkersAI({
model: "@cf/meta/llama-2-7b-chat-int8",
cloudflareAccountId: process.env.CLOUDFLARE_ACCOUNT_ID,
cloudflareApiToken: process.env.CLOUDFLARE_API_TOKEN
});

const response = await model.invoke([
["system", "You are a helpful assistant that translates English to German."],
["human", `Translate "I love programming".`]
]);

console.log(response);

Hierarchy

  • SimpleChatModel
    • ChatCloudflareWorkersAI

Implements

Constructors

Properties

baseUrl: string
model: string = "@cf/meta/llama-2-7b-chat-int8"
streaming: boolean = false
cloudflareAccountId?: string
cloudflareApiToken?: string

Accessors

Methods

  • Get the parameters used to invoke the model

    Parameters

    • Optional _options: Omit<BaseLanguageModelCallOptions, never>

    Returns {
        model: string;
    }

    • model: string

Generated using TypeDoc