{"id":33022,"date":"2025-07-22T10:18:41","date_gmt":"2025-07-22T02:18:41","guid":{"rendered":"https:\/\/www.kdjingpai.com\/?p=33022"},"modified":"2025-07-22T10:18:41","modified_gmt":"2025-07-22T02:18:41","slug":"zerograph","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/en\/zerograph\/","title":{"rendered":"ZeroGraph\uff1a\u8f7b\u91cf\u7ea7 AI \u4ee3\u7406\u7f16\u7a0b\u6846\u67b6"},"content":{"rendered":"<h2>\u7efc\u5408\u4ecb\u7ecd<\/h2>\n<p>ZeroGraph \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u5f00\u6e90\u6846\u67b6\uff0c\u4e13\u4e3a AI \u4ee3\u7406\u7f16\u7a0b\u8bbe\u8ba1\uff0c\u4f7f\u7528 TypeScript \u5f00\u53d1\uff0c\u4ee3\u7801\u4ec5 300 \u884c\uff08\u7ea6 10KB\uff09\uff0c\u65e0\u4efb\u4f55\u4f9d\u8d56\u3002\u5b83\u57fa\u4e8e\u8282\u70b9\uff08Node\uff09\u548c\u6d41\uff08Flow\uff09\u67b6\u6784\uff0c\u652f\u6301\u5feb\u901f\u6784\u5efa\u9ad8\u6548\u7684 AI \u4ee3\u7406\u5de5\u4f5c\u6d41\u3002ZeroGraph \u63d0\u4f9b\u7c7b\u578b\u5b89\u5168\u548c\u5f3a\u5927\u7684 IDE \u652f\u6301\uff0c\u9002\u5408\u5f00\u53d1\u8005\u521b\u5efa\u4ece\u7b80\u5355\u95ee\u5019\u5230\u590d\u6742\u591a\u4ee3\u7406\u534f\u4f5c\u7684\u4efb\u52a1\u3002\u9879\u76ee\u57fa\u4e8e MIT \u8bb8\u53ef\u8bc1\uff0c\u6587\u6863\u548c\u793a\u4f8b\u4e30\u5bcc\uff0c\u6613\u4e8e\u4e0a\u624b\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u7814\u7a76\u548c\u5f00\u53d1\u573a\u666f\u3002<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li><strong>\u8282\u70b9\u4e0e\u6d41\u67b6\u6784<\/strong>\u00a0\uff1a\u901a\u8fc7 Node \u548c Flow \u7c7b\u5b9e\u73b0\u6a21\u5757\u5316\u4efb\u52a1\u5904\u7406\u548c\u6d41\u7a0b\u7f16\u6392\u3002<\/li>\n<li><strong>\u8f7b\u91cf\u7ea7\u8bbe\u8ba1<\/strong>\u00a0\uff1a\u4ec5 300 \u884c\u4ee3\u7801\uff0c\u65e0\u4f9d\u8d56\uff0c\u8fd0\u884c\u9ad8\u6548\u4e14\u65e0\u5382\u5546\u9501\u5b9a\u3002<\/li>\n<li><strong>\u7c7b\u578b\u5b89\u5168<\/strong>\u00a0\uff1aTypeScript \u539f\u751f\u652f\u6301\uff0c\u63d0\u4f9b\u5b8c\u6574\u7684\u7c7b\u578b\u68c0\u67e5\u548c IDE \u63d0\u793a\u3002<\/li>\n<li><strong>\u6279\u5904\u7406\u652f\u6301<\/strong>\u00a0\uff1a\u901a\u8fc7 BatchNode \u5904\u7406\u591a\u6761\u6570\u636e\uff0c\u63d0\u5347\u5904\u7406\u6548\u7387\u3002<\/li>\n<li><strong>\u5f02\u6b65\u64cd\u4f5c<\/strong>\u00a0\uff1a\u652f\u6301 AsyncNode\uff0c\u9002\u5408\u7f51\u7edc\u8bf7\u6c42\u7b49\u5f02\u6b65\u4efb\u52a1\u3002<\/li>\n<li><strong>\u4ee3\u7406\u7f16\u7a0b<\/strong>\u00a0\uff1a\u652f\u6301\u591a\u4ee3\u7406\u534f\u4f5c\u3001\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff08RAG\uff09\u7b49\u590d\u6742\u5de5\u4f5c\u6d41\u3002<\/li>\n<li><strong>\u4e30\u5bcc\u793a\u4f8b<\/strong>\u00a0\uff1a\u63d0\u4f9b\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u7684\u793a\u4f8b\u4ee3\u7801\uff0c\u5982\u95ee\u5019\u3001\u641c\u7d22\u548c\u591a\u4ee3\u7406\u534f\u4f5c\u3002<\/li>\n<\/ul>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<h3>\u5b89\u88c5\u6d41\u7a0b<\/h3>\n<p>ZeroGraph \u4f7f\u7528 TypeScript \u5f00\u53d1\uff0c\u9700\u5b89\u88c5 Node.js \u548c npm\/yarn\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u5b89\u88c5\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li><strong>\u73af\u5883\u51c6\u5907<\/strong>\n<ul>\n<li>\u786e\u4fdd\u5b89\u88c5 Node.js\uff08\u63a8\u8350 16+\uff09\u548c npm\/yarn\u3002<\/li>\n<li>\u9a8c\u8bc1\u73af\u5883\uff1a\n<pre><code>node -v\r\nnpm -v\r\n<\/code><\/pre>\n<\/li>\n<li>\u53ef\u9009\uff1a\u5b89\u88c5 TypeScript \u4ee5\u652f\u6301\u7c7b\u578b\u68c0\u67e5\uff1a\n<pre><code>npm install -g typescript\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5b89\u88c5 ZeroGraph<\/strong><br \/>\n\u4f7f\u7528 npm \u5b89\u88c5\uff1a<\/p>\n<pre><code>npm install @u0z\/zero-graph\r\n<\/code><\/pre>\n<p>\u6216\u4f7f\u7528 yarn\uff1a<\/p>\n<pre><code>yarn add @u0z\/zero-graph\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><br \/>\n\u521b\u5efa\u4e00\u4e2a\u7b80\u5355 TypeScript \u6587\u4ef6\uff08\u4f8b\u5982\u00a0<code>test.ts<\/code>\uff09\u5e76\u8fd0\u884c\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code>import { Node, Flow } from '@u0z\/zero-graph';\r\nconsole.log(\"ZeroGraph installed successfully!\");\r\n<\/code><\/pre>\n<p>\u7f16\u8bd1\u5e76\u8fd0\u884c\uff1a<\/p>\n<pre><code>tsc test.ts\r\nnode test.js\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8f93\u51fa\u6210\u529f\u4fe1\u606f\uff0c\u8bf4\u660e\u5b89\u88c5\u65e0\u8bef\u3002<\/li>\n<\/ol>\n<h3>\u4e3b\u8981\u529f\u80fd\u64cd\u4f5c<\/h3>\n<h4>1. \u8282\u70b9\u4e0e\u6d41\uff08Node \u548c Flow\uff09<\/h4>\n<p>ZeroGraph \u7684\u6838\u5fc3\u662f Node \u548c Flow\u3002Node \u5904\u7406\u5355\u4e2a\u4efb\u52a1\uff0cFlow \u7f16\u6392\u591a\u4e2a\u8282\u70b9\u3002\u64cd\u4f5c\u6b65\u9aa4\uff1a<\/p>\n<ul>\n<li><strong>\u5b9a\u4e49\u8282\u70b9<\/strong>\u00a0\uff1a\u521b\u5efa\u4e00\u4e2a\u7ee7\u627f\u00a0<code>Node<\/code>\u00a0\u7684\u7c7b\uff0c\u5305\u542b\u00a0<code>prep<\/code>\uff08\u51c6\u5907\u6570\u636e\uff09\u3001<code>exec<\/code>\uff08\u6267\u884c\u903b\u8f91\uff09\u548c\u00a0<code>post<\/code>\uff08\u5b58\u50a8\u7ed3\u679c\uff09\u65b9\u6cd5\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ul>\n<pre><code>import { Node, Flow } from '@u0z\/zero-graph';\r\nclass GreetingNode extends Node {\r\nprep(shared: any): string {\r\nreturn shared.name || 'World';\r\n}\r\nexec(name: string): string {\r\nreturn `Hello, ${name}!`;\r\n}\r\npost(shared: any, prepRes: string, execRes: string): void {\r\nshared.greeting = execRes;\r\n}\r\n}\r\n<\/code><\/pre>\n<ul>\n<li><strong>\u521b\u5efa\u6d41<\/strong>\u00a0\uff1a\u7528 Flow \u8fde\u63a5\u8282\u70b9\u5e76\u8fd0\u884c\uff1a<\/li>\n<\/ul>\n<pre><code>const flow = new Flow(new GreetingNode());\r\nconst shared = { name: 'TypeScript' };\r\nflow.run(shared);\r\nconsole.log(shared.greeting); \/\/ \u8f93\u51fa: Hello, TypeScript!\r\n<\/code><\/pre>\n<h4>2. \u6279\u5904\u7406\uff08Batch Processing\uff09<\/h4>\n<p>BatchNode \u9002\u5408\u5904\u7406\u591a\u6761\u6570\u636e\u3002\u64cd\u4f5c\u6b65\u9aa4\uff1a<\/p>\n<ul>\n<li><strong>\u5b9a\u4e49\u6279\u5904\u7406\u8282\u70b9<\/strong>\u00a0\uff1a<\/li>\n<\/ul>\n<pre><code>class BatchProcessor extends BatchNode {\r\nexec(item: any): any {\r\nreturn `Processed: ${item}`;\r\n}\r\n}\r\n<\/code><\/pre>\n<ul>\n<li><strong>\u8fd0\u884c\u6279\u5904\u7406\u6d41<\/strong>\u00a0\uff1a<\/li>\n<\/ul>\n<pre><code>const batchFlow = new BatchFlow(new BatchProcessor());\r\nconst items = ['item1', 'item2', 'item3'];\r\nbatchFlow.run(items).then(results =&gt; console.log(results));\r\n<\/code><\/pre>\n<h4>3. \u5f02\u6b65\u64cd\u4f5c\uff08Async Support\uff09<\/h4>\n<p>AsyncNode \u652f\u6301\u5f02\u6b65\u4efb\u52a1\uff0c\u5982 API \u8c03\u7528\u3002\u64cd\u4f5c\u6b65\u9aa4\uff1a<\/p>\n<ul>\n<li><strong>\u5b9a\u4e49\u5f02\u6b65\u8282\u70b9<\/strong>\u00a0\uff1a<\/li>\n<\/ul>\n<pre><code>class AsyncProcessor extends AsyncNode {\r\nasync execAsync(input: any): Promise&lt;any&gt; {\r\nreturn new Promise(resolve =&gt; setTimeout(() =&gt; resolve(`Processed: ${input}`), 1000));\r\n}\r\n}\r\n<\/code><\/pre>\n<ul>\n<li><strong>\u8fd0\u884c\u5f02\u6b65\u6d41<\/strong>\u00a0\uff1a<\/li>\n<\/ul>\n<pre><code>const asyncFlow = new AsyncFlow(new AsyncProcessor());\r\nconst shared = { input: 'test' };\r\nasyncFlow.runAsync(shared).then(() =&gt; console.log(shared.result));\r\n<\/code><\/pre>\n<h4>4. \u591a\u4ee3\u7406\u534f\u4f5c<\/h4>\n<p>ZeroGraph \u652f\u6301\u591a\u4ee3\u7406\u5de5\u4f5c\u6d41\u3002\u64cd\u4f5c\u6b65\u9aa4\uff1a<\/p>\n<ul>\n<li><strong>\u5b9a\u4e49\u591a\u4e2a\u8282\u70b9<\/strong>\u00a0\uff1a\u521b\u5efa\u591a\u4e2a Node \u7c7b\uff0c\u5206\u522b\u5904\u7406\u4e0d\u540c\u4efb\u52a1\u3002<\/li>\n<li><strong>\u8fde\u63a5\u8282\u70b9<\/strong>\u00a0\uff1a\u901a\u8fc7\u00a0<code>next<\/code>\u00a0\u65b9\u6cd5\u6307\u5b9a\u8282\u70b9\u95f4\u7684\u8df3\u8f6c\u903b\u8f91\uff1a<\/li>\n<\/ul>\n<pre><code>class NodeA extends Node {\r\nexec(input: any): string {\r\nreturn input ? 'success' : 'error';\r\n}\r\n}\r\nclass NodeB extends Node {\r\nexec(input: any): string {\r\nreturn 'Task B done';\r\n}\r\n}\r\nconst nodeA = new NodeA();\r\nconst nodeB = new NodeB();\r\nnodeA.next(nodeB, 'success');\r\nconst flow = new Flow(nodeA);\r\nflow.run({ input: true });\r\n<\/code><\/pre>\n<h4>5. \u793a\u4f8b\u4ee3\u7801\u4f7f\u7528<\/h4>\n<p>ZeroGraph \u63d0\u4f9b\u4e30\u5bcc\u793a\u4f8b\uff0c\u4f4d\u4e8e\u00a0<code>examples\/<\/code>\u00a0\u76ee\u5f55\u3002\u64cd\u4f5c\u6b65\u9aa4\uff1a<\/p>\n<ul>\n<li><strong>\u514b\u9686\u4ed3\u5e93<\/strong>\u00a0\uff1a<\/li>\n<\/ul>\n<pre><code>git clone https:\/\/github.com\/u-0-z\/zero-graph.git\r\ncd zero-graph\r\n<\/code><\/pre>\n<ul>\n<li><strong>\u8fd0\u884c\u793a\u4f8b<\/strong>\u00a0\uff1a\u8fdb\u5165\u00a0<code>examples\/<\/code>\u00a0\u76ee\u5f55\uff0c\u8fd0\u884c\u7279\u5b9a\u793a\u4f8b\uff1a<\/li>\n<\/ul>\n<pre><code>cd examples\/hello-world\r\nnpm install\r\nts-node index.ts\r\n<\/code><\/pre>\n<ul>\n<li>\u793a\u4f8b\u5305\u62ec\u57fa\u7840\u95ee\u5019\uff08hello-world\uff09\u3001\u641c\u7d22\u4ee3\u7406\uff08agent\uff09\u3001\u5185\u5bb9\u751f\u6210\uff08workflow\uff09\u3001\u6279\u5904\u7406\uff08batch\uff09\u3001\u5f02\u6b65\u64cd\u4f5c\uff08async\uff09\u3001\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff08rag\uff09\u548c\u591a\u4ee3\u7406\u534f\u4f5c\uff08multi-agent\uff09\u3002<\/li>\n<\/ul>\n<h3>\u6ce8\u610f\u4e8b\u9879<\/h3>\n<ul>\n<li><strong>TypeScript \u914d\u7f6e<\/strong>\u00a0\uff1a\u786e\u4fdd\u9879\u76ee\u5305\u542b\u00a0<code>tsconfig.json<\/code>\uff0c\u63a8\u8350\u8bbe\u7f6e\uff1a<\/li>\n<\/ul>\n<pre><code>{\r\n\"compilerOptions\": {\r\n\"target\": \"ES6\",\r\n\"module\": \"commonjs\",\r\n\"strict\": true\r\n}\r\n}\r\n<\/code><\/pre>\n<ul>\n<li><strong>\u6587\u6863\u67e5\u9605<\/strong>\u00a0\uff1a\u5b8c\u6574\u6587\u6863\u4f4d\u4e8e\u00a0<code>docs\/<\/code>\u00a0\u76ee\u5f55\uff0c\u6db5\u76d6\u6838\u5fc3\u6982\u5ff5\u3001\u8bbe\u8ba1\u6a21\u5f0f\u548c API \u53c2\u8003\u3002<\/li>\n<li><strong>\u793e\u533a\u652f\u6301<\/strong>\u00a0\uff1a\u9047\u5230\u95ee\u9898\u53ef\u67e5\u770b GitHub Issues \u6216\u63d0\u4ea4\u65b0\u95ee\u9898\u3002<\/li>\n<\/ul>\n<h2>\u5e94\u7528\u573a\u666f<\/h2>\n<ol>\n<li><strong>AI \u4ee3\u7406\u5feb\u901f\u539f\u578b\u5f00\u53d1<\/strong><br \/>\nZeroGraph \u7684\u8f7b\u91cf\u8bbe\u8ba1\u9002\u5408\u5feb\u901f\u6784\u5efa AI \u4ee3\u7406\u539f\u578b\u3002\u4f8b\u5982\uff0c\u5f00\u53d1\u8005\u53ef\u521b\u5efa\u4e00\u4e2a\u641c\u7d22\u4ee3\u7406\uff0c\u7ed3\u5408\u7f51\u7edc API \u5b9e\u73b0\u5b9e\u65f6\u4fe1\u606f\u68c0\u7d22\u3002<\/li>\n<li><strong>\u81ea\u52a8\u5316\u5de5\u4f5c\u6d41<\/strong><br \/>\n\u5728\u5185\u5bb9\u751f\u6210\u6216\u6570\u636e\u5904\u7406\u573a\u666f\u4e2d\uff0cZeroGraph \u53ef\u7f16\u6392\u591a\u8282\u70b9\u5de5\u4f5c\u6d41\uff0c\u5982\u81ea\u52a8\u751f\u6210\u6587\u7ae0\u6216\u5904\u7406\u6279\u91cf\u6570\u636e\u3002<\/li>\n<li><strong>\u6559\u80b2\u4e0e\u7814\u7a76<\/strong><br \/>\n\u5b66\u751f\u548c\u7814\u7a76\u8005\u53ef\u901a\u8fc7 ZeroGraph \u5b66\u4e60 TypeScript \u548c AI \u4ee3\u7406\u7f16\u7a0b\uff0c\u793a\u4f8b\u4ee3\u7801\u9002\u5408\u6559\u5b66\u548c\u5b9e\u9a8c\u3002<\/li>\n<\/ol>\n<h2>QA<\/h2>\n<ol>\n<li><strong>ZeroGraph \u548c LangChain \u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/strong><br \/>\nZeroGraph \u4ec5 300 \u884c\u4ee3\u7801\uff0c\u4e13\u6ce8\u4e8e\u8f7b\u91cf\u7ea7 AI \u4ee3\u7406\u7f16\u7a0b\uff0c\u65e0\u4f9d\u8d56\u4e14 TypeScript \u539f\u751f\u3002LangChain \u529f\u80fd\u66f4\u590d\u6742\uff0c\u4ee3\u7801\u91cf\u5927\uff08405K \u884c\uff09\uff0c\u9002\u5408\u5927\u578b\u9879\u76ee\u4f46\u6709\u6027\u80fd\u5f00\u9500\u3002<\/li>\n<li><strong>\u9700\u8981 TypeScript \u7ecf\u9a8c\u5417\uff1f<\/strong><br \/>\n\u57fa\u672c JavaScript \u77e5\u8bc6\u5373\u53ef\u4e0a\u624b\uff0cTypeScript \u7684\u7c7b\u578b\u5b89\u5168\u7279\u6027\u901a\u8fc7 IDE \u81ea\u52a8\u63d0\u793a\uff0c\u964d\u4f4e\u5b66\u4e60\u66f2\u7ebf\u3002<\/li>\n<li><strong>\u5982\u4f55\u8c03\u8bd5\u4ee3\u7801\uff1f<\/strong><br \/>\n\u4f7f\u7528 VS Code \u7b49 IDE\uff0c\u7ed3\u5408 TypeScript \u8c03\u8bd5\u5de5\u5177\u3002\u8fd0\u884c\u00a0<code>ts-node<\/code>\u00a0\u6267\u884c\u4ee3\u7801\uff0c\u67e5\u770b\u63a7\u5236\u53f0\u8f93\u51fa\u6216\u65e5\u5fd7\u3002<\/li>\n<li><strong>\u652f\u6301\u54ea\u4e9b\u590d\u6742\u4efb\u52a1\uff1f<\/strong><br \/>\n\u652f\u6301\u591a\u4ee3\u7406\u534f\u4f5c\u3001\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff08RAG\uff09\u548c\u5f02\u6b65\u5de5\u4f5c\u6d41\uff0c\u9002\u5408\u641c\u7d22\u3001\u5185\u5bb9\u751f\u6210\u7b49\u573a\u666f\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u7efc\u5408\u4ecb\u7ecd ZeroGraph \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u5f00\u6e90\u6846\u67b6\uff0c\u4e13\u4e3a AI \u4ee3\u7406\u7f16\u7a0b\u8bbe\u8ba1\uff0c\u4f7f\u7528 TypeScript \u5f00\u53d1\uff0c\u4ee3\u7801\u4ec5 300 \u884c\uff08\u7ea6 10KB\uff09\uff0c\u65e0\u4efb\u4f55\u4f9d\u8d56\u3002\u5b83\u57fa\u4e8e\u8282\u70b9\uff08Node\uff09\u548c\u6d41\uff08Flow\uff09\u67b6\u6784\uff0c\u652f\u6301\u5feb\u901f\u6784\u5efa\u9ad8\u6548\u7684 AI \u4ee3\u7406\u5de5\u4f5c\u6d41&#8230;<\/p>\n","protected":false},"author":1,"featured_media":32782,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[425,20,476],"tags":[230,201],"class_list":["post-33022","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai-professional","category-tool","category-agent-development","tag-aikaiyuanxiangmu","tag-aizhinengti"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/posts\/33022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/comments?post=33022"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/posts\/33022\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/media\/32782"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/media?parent=33022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/categories?post=33022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/tags?post=33022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}