Skip to content

llm-exe

A package that provides simplified base components to make building and maintaining LLM-powered applications easier.

llm-exe

Quick Example

ts
const PROMPT = `You are a senior TypeScript developer. 

Write a concise implementation for the task: "{{spec}}". 

Respond with only the code (no questions or explanation), inside a single ts code block`;

export async function writeCodeFromSpec(spec: string) {
  const llm = useLlm("openai.gpt-4o-mini"); // change this if you want
  const prompt = createChatPrompt<{ spec: string }>(PROMPT);
  const parser = createParser("markdownCodeBlock");

  const executor = createLlmExecutor({ llm, prompt, parser });

  return executor.execute({ spec });
}
ts
const code = await writeCodeFromSpec("add two numbers together");
console.log(code.code); // => function add(a: number, b: number) { ... }