Skip to main content

createAIEngine()

function createAIEngine(cfg): AIEngine;

Creates an AI Engine with the given configuration.

The AI Engine provides utilities for creating and running conversational workflows with large language models, specifically OpenAI GPT models.

Parameters​

ParameterType
cfgEngineConfig

Returns​

AIEngine

An AIEngine instance.

Example​

const engine = createAIEngine({
logger: customLogger,
basePath: '/path/to/prompts'
});

const workflow = await engine.createWorkflow(
engine.createStep({
name: 'generate-response',
prompt: engine.loadFile('prompts/response.txt'),
execute: (response) => conversation.setProposedReply(response)
})
);

const reply = await workflow.run(conversation);