AgentMark provides utility functions for working with prompts and frontmatter.

Serialization

serialize(completionParams, name)

Converts model completion parameters into AgentMark mdx format.

TypeScript
import { serialize } from "@puzzlet/agentmark";

const params = {
  model: "gpt-4",
  messages: [
    { role: "system", content: "You are a helpful assistant" },
    { role: "user", content: "Hello!" }
  ],
  temperature: 0.7
};

const mdx = serialize(params, "my-prompt");

// Now you can save this mdx to a file as <prompt-name>.prompt.mdx and use it w/ AgentMark.

deserialize(prompt, props)

Converts AgentMark MDX content back into model completion parameters.

import { deserialize } from "@puzzlet/agentmark";

const params = await deserialize(prompt, props);

// Now you can call your api directly with the params

Frontmatter

getFrontMatter(prompt)

Extracts frontmatter metadata from an AgentMark prompt.

import { getFrontMatter, load } from "@puzzlet/agentmark";

const prompt = load("example.prompt.mdx");

const frontmatter = getFrontMatter(prompt);
// {
//   name: "example",
//   metadata: {
//     model: {
//       name: "gpt-4",
//       settings: {
//         temperature: 0.7
//       }
//     }
//   }
// }

Returns an object containing the frontmatter section.

The frontmatter contains:

  • name: Prompt identifier
  • metadata: Model configuration and settings
  • test_settings: (Optional) Test configuration

Have Questions?

We’re here to help! Choose the best way to reach us: