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 (view full)

Implements

Constructors

Properties

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

Accessors

Methods

  • Parameters

    • tools: any[]
    • Optional kwargs: Partial<unknown>

    Returns Runnable<BaseLanguageModelInput, AIMessageChunk, this["ParsedCallOptions"]>

Generated using TypeDoc