🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

@langchain/core

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@langchain/core - npm Package Compare versions

Comparing version

to
0.3.51

export function parseJsonMarkdown(s, parser = parsePartialJson) {
// eslint-disable-next-line no-param-reassign
s = s.trim();
const match = /```(json)?(.*)```/s.exec(s);
if (!match) {
const firstFenceIndex = s.indexOf("```");
if (firstFenceIndex === -1) {
return parser(s);
}
else {
return parser(match[2]);
let contentAfterFence = s.substring(firstFenceIndex + 3);
if (contentAfterFence.startsWith("json\n")) {
contentAfterFence = contentAfterFence.substring(5);
}
else if (contentAfterFence.startsWith("json")) {
contentAfterFence = contentAfterFence.substring(4);
}
else if (contentAfterFence.startsWith("\n")) {
contentAfterFence = contentAfterFence.substring(1);
}
const closingFenceIndex = contentAfterFence.indexOf("```");
let finalContent = contentAfterFence;
if (closingFenceIndex !== -1) {
finalContent = contentAfterFence.substring(0, closingFenceIndex);
}
return parser(finalContent.trim());
}

@@ -12,0 +25,0 @@ // Adapted from https://github.com/KillianLucas/open-interpreter/blob/main/interpreter/core/llm/utils/parse_partial_json.py

{
"name": "@langchain/core",
"version": "0.3.50",
"version": "0.3.51",
"description": "Core LangChain.js abstractions and schemas",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet