Inference Engine
@idiomark/inference is the core Idiomark product — it applies personality characterization to AI responses. Load a Idiomark file, point the engine at a provider, and every response comes back in-character.
Installation
pnpm add @idiomark/inference
Quick Start
import { InferenceEngine, createPrompt } from "@idiomark/inference";
// Load a Idiomark personality file
const myIdiomark = JSON.parse(fs.readFileSync("my-personality.idiomark.json"));
// Create the engine
const engine = new InferenceEngine({
idiomark: myIdiomark,
provider: "anthropic",
mode: "balanced",
});
// Get personality-enhanced responses
const response = await engine.respond("How do I center a div?");
console.log(response.content);
// "Sure thing! 🚀 Just use flexbox or grid..."
Response Modes
Control how strongly the personality influences output:
| Mode | Description |
|---|---|
strict | Follow personality exactly — every response is fully in-character |
balanced | Personality + helpfulness (default) — natural blend |
subtle | Light personality touch — minimal stylistic influence |
custom | User-defined mix — fine-grained control |
Prompt Utilities
Build personality-aware prompts directly:
import { createPrompt, applyPersonality } from "@idiomark/inference";
// Create a system prompt from Idiomark data
const systemPrompt = createPrompt(idiomarkFile);
// Apply personality to any message
const enhanced = applyPersonality(message, idiomarkFile);
API Reference
| Method | Description |
|---|---|
respond(message) | Get personality-enhanced response |
setPersonality(idiomark) | Update the active personality |
setMode(mode) | Change response mode |
setContext(context) | Set conversation history |
clearContext() | Clear conversation history |
Exports
// Engine
export { InferenceEngine } from "./inference";
// Types
export type {
InferenceOptions,
InferenceResponse,
ResponseMode,
} from "./types";
// Utilities
export { createPrompt, applyPersonality } from "./prompts";