diff --git a/packages/core/src/parsers.ts b/packages/core/src/parsers.ts index a9e71784c..12d950b92 100644 --- a/packages/core/src/parsers.ts +++ b/packages/core/src/parsers.ts @@ -28,6 +28,7 @@ import { jinjaRender } from "./jinja" import { createDiff, llmifyDiff } from "./diff" import { tidyData } from "./tidy" import { hash } from "./crypto" +import { jq } from "./jq" export async function createParsers(options: { trace: MarkdownTrace @@ -122,5 +123,6 @@ export async function createParsers(options: { tidyData: (rows, options) => tidyData(rows, options), hash: async (text, options) => await hash(text, options), unfence: unfence, + jq: jq, }) } diff --git a/packages/core/src/types/prompt_template.d.ts b/packages/core/src/types/prompt_template.d.ts index e6c80c37b..3ca5a7ba2 100644 --- a/packages/core/src/types/prompt_template.d.ts +++ b/packages/core/src/types/prompt_template.d.ts @@ -1568,6 +1568,7 @@ interface Parsers { * @param data data to render */ mustache(text: string | WorkspaceFile, data: Record): string + /** * Renders a jinja template */ @@ -1589,6 +1590,13 @@ interface Parsers { */ tidyData(rows: object[], options?: DataFilter): object[] + /** + * Applies a jq query to the data + * @param data data object to filter + * @param query jq query + */ + jq(data: any, query: string): any + /** * Computes a sha1 that can be used for hashing purpose, not cryptographic. * @param content content to hash