Skip to content

Commit

Permalink
core[patch]: Fix rollup warning (#5929)
Browse files Browse the repository at this point in the history
* core[patch]: Fix rollup warning

* chore: lint files

* cr
  • Loading branch information
bracesproul authored Jun 28, 2024
1 parent 0079bf8 commit db470a2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions langchain-core/src/prompts/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import mustache from "mustache";
import { MessageContent } from "../messages/index.js";
import type { InputValues } from "../utils/types/index.js";

// Use unescaped HTML
// https://github.com/janl/mustache.js?tab=readme-ov-file#variables
mustache.escape = (text) => text;
function configureMustache() {
// Use unescaped HTML
// https://github.com/janl/mustache.js?tab=readme-ov-file#variables
mustache.escape = (text) => text;
}

/**
* Type that specifies the format of a template.
Expand Down Expand Up @@ -99,6 +101,7 @@ const mustacheTemplateToNodes = (
});

export const parseMustache = (template: string) => {
configureMustache();
const parsed = mustache.parse(template);
return mustacheTemplateToNodes(parsed);
};
Expand All @@ -115,8 +118,10 @@ export const interpolateFString = (template: string, values: InputValues) =>
return res + node.text;
}, "");

export const interpolateMustache = (template: string, values: InputValues) =>
mustache.render(template, values);
export const interpolateMustache = (template: string, values: InputValues) => {
configureMustache();
return mustache.render(template, values);
};

/**
* Type that represents a function that takes a template string and a set
Expand Down

0 comments on commit db470a2

Please sign in to comment.