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.
class ChatCloudflareWorkersAISimpleChatModelconst 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);The async caller should be used by subclasses to make any async calls, which will thus benefit from the concurrency and retry logic.
A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.
Whether to print out response text.