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

30 lines 1.14 kB
import { displayWarning } from '#src/consoleUtils.js'; import { env } from '#src/systemUtils.js'; import { writeFileIfNotExistsWithMessages } from '#src/utils.js'; // Function to process JSON config and create XAI LLM instance export async function processJsonConfig(llmConfig) { const { ChatXAI } = await import('@langchain/xai'); // Use config value if available, otherwise use the environment variable const apiKey = llmConfig.apiKey || env.XAI_API_KEY; return new ChatXAI({ ...llmConfig, apiKey, model: llmConfig.model || 'grok-4-0709', }); } const jsonContent = `{ "llm": { "type": "xai", "model": "grok-4-0709" } }`; 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 xAI API key, ` + 'or define XAI_API_KEY environment variable.'); } //# sourceMappingURL=xai.js.map