genkitx-anthropic
Version:
Firebase Genkit AI framework plugin for Anthropic APIs.
43 lines • 1.25 kB
JavaScript
import {
__async
} from "./chunk-MLCSNVBT.mjs";
import { genkitPlugin } from "genkit/plugin";
import Anthropic from "@anthropic-ai/sdk";
import {
claude37Sonnet,
claude35Sonnet,
claude3Opus,
claude3Sonnet,
claude3Haiku,
claude35Haiku,
claudeModel,
SUPPORTED_CLAUDE_MODELS
} from "./claude.js";
const anthropic = (options) => genkitPlugin("anthropic", (ai) => __async(void 0, null, function* () {
let apiKey = (options == null ? void 0 : options.apiKey) || process.env.ANTHROPIC_API_KEY;
if (!apiKey) {
throw new Error(
"Please pass in the API key or set the ANTHROPIC_API_KEY environment variable"
);
}
let defaultHeaders = {};
if ((options == null ? void 0 : options.cacheSystemPrompt) == true) {
defaultHeaders["anthropic-beta"] = "prompt-caching-2024-07-31";
}
const client = new Anthropic({ apiKey, defaultHeaders });
for (const name of Object.keys(SUPPORTED_CLAUDE_MODELS)) {
claudeModel(ai, name, client, options == null ? void 0 : options.cacheSystemPrompt);
}
}));
var src_default = anthropic;
export {
anthropic,
claude35Haiku,
claude35Sonnet,
claude37Sonnet,
claude3Haiku,
claude3Opus,
claude3Sonnet,
src_default as default
};
//# sourceMappingURL=index.mjs.map