@pomlight/pomlight
v0.1.8
Published
Lightweight library for parsing and rendering POML prompts
Readme
pomlight — Node.js
Lightweight Node.js library for parsing and rendering POML prompts.
Built from the Deno source using dnt.
Install
npm install @pomlight/pomlightimport { poml } from "@pomlight/pomlight";Usage
import { poml } from "@pomlight/pomlight";
const messages = await poml(`
<poml>
<system>You are a helpful assistant.</system>
<user>What is 2 + 2?</user>
</poml>
`);
console.log(messages[0].content); // "You are a helpful assistant."
console.log(messages[1].content); // "What is 2 + 2?"Use with OpenAI SDK
import OpenAI from "openai";
import { poml } from "@pomlight/pomlight";
const client = new OpenAI();
const params = await poml<OpenAI.ChatCompletionCreateParamsNonStreaming>(`
<poml>
<runtime model="gpt-4o-mini" />
<system>You are a helpful assistant. Reply in one short sentence.</system>
<user>What is the capital of France?</user>
</poml>
`, { format: "openai_chat" });
const response = await client.chat.completions.create(params);
console.log(response.choices[0].message.content);Build
The Node.js package is generated from the Deno source:
cd packages/nodejs
deno run -A build.tsThis produces the npm package in the npm/ directory, ready to publish.
