Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(export): messages key in jsonl output format (#1236)

Marc Klingen4db7dab8ae4d
diff --git a/web/src/server/api/routers/generations/exportQuery/transforms/transformStreamToJsonLines.ts b/web/src/server/api/routers/generations/exportQuery/transforms/transformStreamToJsonLines.ts
index 1bf4f3ecd2..eba18a6ebd 100644
--- a/web/src/server/api/routers/generations/exportQuery/transforms/transformStreamToJsonLines.ts
+++ b/web/src/server/api/routers/generations/exportQuery/transforms/transformStreamToJsonLines.ts
@@ -29,17 +29,19 @@ export function transformStreamToJsonLines(): Transform {
const parsedOutput = outputSchema.safeParse(row.output);
if (parsedInput.success && parsedOutput.success) {
- const output = JSON.stringify([
- ...parsedInput.data,
- {
- role: "assistant",
- content:
- typeof parsedOutput.data === "object" &&
- "completion" in parsedOutput.data
- ? JSON.stringify(parsedOutput.data.completion)
- : JSON.stringify(parsedOutput.data),
- },
- ]);
+ const output = JSON.stringify({
+ messages: [
+ ...parsedInput.data,
+ {
+ role: "assistant",
+ content:
+ typeof parsedOutput.data === "object" &&
+ "completion" in parsedOutput.data
+ ? JSON.stringify(parsedOutput.data.completion)
+ : JSON.stringify(parsedOutput.data),
+ },
+ ],
+ });
this.push(output + "\n");
}