UNPKG

gaunt-sloth-assistant

Version:

[![Tests and Lint](https://github.com/Galvanized-Pukeko/gaunt-sloth-assistant/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/Galvanized-Pukeko/gaunt-sloth-assistant/actions/workflows/unit-tests.yml) [![Integration Tests](https://github.co

34 lines 1.35 kB
import { displayWarning } from '#src/utils/consoleUtils.js'; import { writeFileIfNotExistsWithMessages } from '#src/utils/fileUtils.js'; import { env } from '#src/utils/systemUtils.js'; /** * Function to process JSON config and create Anthropic LLM instance */ // noinspection JSUnusedGlobalSymbols export async function processJsonConfig(llmConfig) { const anthropic = await import('@langchain/anthropic'); // Use config value if available, otherwise use the environment variable const anthropicApiKey = llmConfig.apiKey || env.ANTHROPIC_API_KEY; return new anthropic.ChatAnthropic({ ...llmConfig, apiKey: anthropicApiKey, model: llmConfig.model || 'claude-sonnet-4-20250514', }); } const jsonContent = `{ "llm": { "type": "anthropic", "model": "claude-sonnet-4-20250514" } }`; // noinspection JSUnusedGlobalSymbols export function init(configFileName) { // Determine which content to use based on file extension if (!configFileName.endsWith('.json')) { throw new Error('Only JSON config is supported.'); } writeFileIfNotExistsWithMessages(configFileName, jsonContent); displayWarning(`You need to update your ${configFileName} to add your Anthropic API key, ` + 'or define ANTHROPIC_API_KEY environment variable.'); } //# sourceMappingURL=anthropic.js.map