From f0f2aa9cbd48ecf29e22f35d39a312792267cbff Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 28 Jun 2024 11:51:56 -0700 Subject: [PATCH 1/3] core[patch]: Fix rollup warning --- langchain-core/package.json | 2 +- langchain-core/src/prompts/template.ts | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/langchain-core/package.json b/langchain-core/package.json index c64eaeeb70a4..80f77069c8dc 100644 --- a/langchain-core/package.json +++ b/langchain-core/package.json @@ -1,6 +1,6 @@ { "name": "@langchain/core", - "version": "0.2.10", + "version": "0.2.11", "description": "Core LangChain.js abstractions and schemas", "type": "module", "engines": { diff --git a/langchain-core/src/prompts/template.ts b/langchain-core/src/prompts/template.ts index 245641ccbe1d..8bf444ec6d6e 100644 --- a/langchain-core/src/prompts/template.ts +++ b/langchain-core/src/prompts/template.ts @@ -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. @@ -99,6 +101,7 @@ const mustacheTemplateToNodes = ( }); export const parseMustache = (template: string) => { + configureMustache(); const parsed = mustache.parse(template); return mustacheTemplateToNodes(parsed); }; @@ -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 From f6a4163e04429872e9204e0e8e500cda65b0ad98 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 28 Jun 2024 11:52:11 -0700 Subject: [PATCH 2/3] chore: lint files --- langchain-core/src/prompts/template.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain-core/src/prompts/template.ts b/langchain-core/src/prompts/template.ts index 8bf444ec6d6e..2188ba1f870f 100644 --- a/langchain-core/src/prompts/template.ts +++ b/langchain-core/src/prompts/template.ts @@ -121,7 +121,7 @@ export const interpolateFString = (template: string, values: InputValues) => 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 From f28fcfdc8a0dab2fe14ccc51fff4acd746c89ed6 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 28 Jun 2024 12:03:22 -0700 Subject: [PATCH 3/3] cr --- langchain-core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain-core/package.json b/langchain-core/package.json index 80f77069c8dc..c64eaeeb70a4 100644 --- a/langchain-core/package.json +++ b/langchain-core/package.json @@ -1,6 +1,6 @@ { "name": "@langchain/core", - "version": "0.2.11", + "version": "0.2.10", "description": "Core LangChain.js abstractions and schemas", "type": "module", "engines": {