Skip to main content
Version: 4.7.34

Render format

Developers can choose how the Gentrace UI renders an output key, making it easier to compare results from different code versions.

Example

Specify the render key in the gentrace context object when using the advanced SDK.

typescript
import { init, Pipeline } from "@gentrace/core";
import { createUserHtml } from "./ai";
 
init({
apiKey: process.env.GENTRACE_API_KEY
});
 
const pipeline = new Pipeline({
slug: "create-html",
});
 
const runner = pipeline.start();
 
const userId = "user-id-123";
 
await runner.measure(
(userId) => {
// Omitted: code for AI-generated HTML content
const htmlOutput = createUserHtml(userId);
return {
htmlOutput, // ⬅️ The 'key' in the context below references this 'htmlOutput'
};
},
[userId],
{
context: {
render: {
type: "html",
key: "htmlOutput", /* ⬅️ JSON path to the 'htmlOutput' returned above */
},
},
},
);
 
const pipelineRunId = await runner.submit();

The above example uses the measure() function from our core tracer. .

Types

render

The value type of the render key is an object with type and key keys. We only support one key type at this time (html). We will add more upon request.

If your generative AI pipeline returned the following JSON output:

json
{
"htmlOutput": "<h1>Hello world!</h1>"
}

You would describe the render value in the context in the following way:

json
{
"type": "html",
"key": "htmlOutput"
}
🛑danger

We only support top-level JSON keys. The following would not work.

json
{
"content": {
"htmlOutput": {
"html": "<h1>Hello world!</h1>"
}
}
}
json
{
"type": "html",
"key": "content.htmlOutput.html"
}

Here's an example of how the generated HTML might be rendered in the Gentrace UI:

html
<h1>Welcome to Vivek's home page</h1>
<p>Vivek is 30 years old and lives in Brooklyn, NYC.</p>

Limitations

caution

The render key is only supported when using the core tracer components like measure() and checkpoint(). Learn more about these tracing primitives here.

We intend to expand support for our provider-specific wrappers like OpenAI and Pinecone.