


























此工具包在agent 周年使用还是挺多的,同时支持不少配置参数
import { VfsSandbox } from "@langchain/node-vfs";
import turndown from "turndown"
import fecth from "node-fetch"
const sandbox = await VfsSandbox.create({
initialFiles: {
"/src/index.js": "console.log('Hello from VFS!')",
},
});
const markdown = new turndown().turndown(`
<h1>Turndown Demo</h1>
<p>This demonstrates <a href="https://github.com/mixmark-io/turndown">turndown</a> – an HTML to Markdown converter in JavaScript.</p>
<h2>Usage</h2>
<pre><code class="language-js">var turndownService = new TurndownService()
console.log(
turndownService.turndown('<h1>Hello world</h1>')
)</code></pre>
<hr />
<p>It aims to be <a href="http://commonmark.org/">CommonMark</a>
compliant, and includes options to style the output. These options include:</p>
<ul>
<li>headingStyle (setext or atx)</li>
<li>horizontalRule (*, -, or _)</li>
<li>bullet (*, -, or +)</li>
<li>codeBlockStyle (indented or fenced)</li>
<li>fence ( or ~)</li>
<li>emDelimiter (_ or *)</li>
<li>strongDelimiter (** or __)</li>
<li>linkStyle (inlined or referenced)</li>
<li>linkReferenceStyle (full, collapsed, or shortcut)</li>
</ul>
`);
const result = await sandbox.execute(`echo "${markdown}" > /src/hello.md && cat /src/hello.md`);
let fileLists = await sandbox.ls("/src");
const fileContent = await sandbox.readRaw("/src/hello.md");
console.log(fileContent.data.content);
turndown 同时还支持配置参数,不少agent 框架 在用
https://www.npmjs.com/package/turndown
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。