[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-pguso--ai-agents-from-scratch":3,"tool-pguso--ai-agents-from-scratch":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":78,"owner_location":78,"owner_email":79,"owner_twitter":80,"owner_website":78,"owner_url":81,"languages":82,"stars":87,"forks":88,"last_commit_at":89,"license":90,"difficulty_score":10,"env_os":91,"env_gpu":91,"env_ram":92,"env_deps":93,"category_tags":97,"github_topics":98,"view_count":10,"oss_zip_url":78,"oss_zip_packed_at":78,"status":16,"created_at":106,"updated_at":107,"faqs":108,"releases":139},560,"pguso\u002Fai-agents-from-scratch","ai-agents-from-scratch","Demystify AI agents by building them yourself. Local LLMs, no black boxes, real understanding of function calling, memory, and ReAct patterns.","ai-agents-from-scratch 是一个致力于揭开 AI 智能体神秘面纱的开源项目。它主张通过从零构建来学习，让开发者在本地环境中使用 LLM 亲手搭建智能体，而非直接套用复杂的现成框架。这有效解决了许多人在使用 AI 技术时面临的“黑盒”困境——即不清楚函数调用、记忆机制及 ReAct 模式背后的真实逻辑。\n\n它特别适合希望夯实基础的开发者、AI 研究者以及关注本地化部署的技术人员。借助 Node.js 和 node-llama-cpp，用户可以直观地看到模型加载、上下文管理及推理流程的每一个细节。其独特亮点在于“由建而学”的理念，不仅提供代码示例，还配有详细的原理解析和可视化图表。项目后续甚至计划用原生代码复现 LangChain 等框架的核心概念，帮助用户真正理解框架的设计哲学，从而更明智地使用现有工具。如果你想摆脱对封装层的依赖，深入掌握 AI 技术的本质，这里是非常好的起点。","> **Read the full interactive version:**  \n> This repository is part of **AI Agents From Scratch** - a hands-on learning series where we build AI agents *step by step*, explain every design decision, and visualize what’s happening under the hood.  \n>  \n> 👉 **https:\u002F\u002Fagentsfromscratch.com**  \n>  \n> If you prefer **long-form explanations, diagrams, and conceptual deep dives**, start there - then come back here to explore the code.\n\n\n# AI Agents From Scratch\n\nLearn to build AI agents locally without frameworks. Understand what happens under the hood before using production frameworks.\n\n## Purpose\n\nThis repository teaches you to build AI agents from first principles using **local LLMs** and **node-llama-cpp**. By working through these examples, you'll understand:\n\n- How LLMs work at a fundamental level\n- What agents really are (LLM + tools + patterns)\n- How different agent architectures function\n- Why frameworks make certain design choices\n\n**Philosophy**: Learn by building. Understand deeply, then use frameworks wisely.\n\n## Related Projects\n\n### [AI Product from Scratch](https:\u002F\u002Fgithub.com\u002Fpguso\u002Fai-product-from-scratch)\n\n[![TypeScript](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTypeScript-007ACC?logo=typescript&logoColor=white)](https:\u002F\u002Fwww.typescriptlang.org\u002F)\n[![React](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FReact-20232A?logo=react&logoColor=61DAFB)](https:\u002F\u002Freactjs.org\u002F)\n[![Node.js](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FNode.js-339933?logo=node.js&logoColor=white)](https:\u002F\u002Fnodejs.org\u002F)\n\nLearn AI product development fundamentals with local LLMs. Covers prompt engineering, structured output, multi-step reasoning, API design, and frontend integration through 10 comprehensive lessons with visual diagrams.\n\n### [AI Agents from Scratch in Python](https:\u002F\u002Fgithub.com\u002Fpguso\u002Fagents-from-scratch) \n\n![Python](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython-3776AB?logo=python&logoColor=white)\n\n## Next Phase: Build LangChain & LangGraph Concepts From Scratch\n\n> After mastering the fundamentals, the next stage of this project walks you through **re-implementing the core parts of LangChain and LangGraph** in plain JavaScript using local models.\n> This is **not** about building a new framework, it’s about understanding *how frameworks work*.  \n\n## Phase 1: Agent Fundamentals - From LLMs to ReAct\n\n### Prerequisites\n- Node.js 18+\n- At least 8GB RAM (16GB recommended)\n- Download models and place in `.\u002Fmodels\u002F` folder, details in [DOWNLOAD.md](DOWNLOAD.md)\n\n### Installation\n```bash\nnpm install\n```\n\n### Run Examples\n```bash\nnode intro\u002Fintro.js\nnode simple-agent\u002Fsimple-agent.js\nnode react-agent\u002Freact-agent.js\n```\n\n## Learning Path\n\nFollow these examples in order to build understanding progressively:\n\n### 1. **Introduction** - Basic LLM Interaction\n`intro\u002F` | [Code](examples\u002F01_intro\u002Fintro.js) | [Code Explanation](examples\u002F01_intro\u002FCODE.md) | [Concepts](examples\u002F01_intro\u002FCONCEPT.md)\n\n**What you'll learn:**\n- Loading and running a local LLM\n- Basic prompt\u002Fresponse cycle\n\n**Key concepts**: Model loading, context, inference pipeline, token generation\n\n---\n\n### 2. (Optional) **OpenAI Intro** - Using Proprietary Models\n`openai-intro\u002F` | [Code](examples\u002F02_openai-intro\u002Fopenai-intro.js) | [Code Explanation](examples\u002F02_openai-intro\u002FCODE.md) | [Concepts](examples\u002F02_openai-intro\u002FCONCEPT.md)\n\n**What you'll learn:**\n- How to call hosted LLMs (like GPT-4)\n- Temperature Control\n- Token Usage\n\n**Key concepts**: Inference endpoints, network latency, cost vs control, data privacy, vendor dependence\n\n---\n\n### 3. **Translation** - System Prompts & Specialization\n`translation\u002F` | [Code](examples\u002F03_translation\u002Ftranslation.js) | [Code Explanation](examples\u002F03_translation\u002FCODE.md) | [Concepts](examples\u002F03_translation\u002FCONCEPT.md)\n\n**What you'll learn:**\n- Using system prompts to specialize agents\n- Output format control\n- Role-based behavior\n- Chat wrappers for different models\n\n**Key concepts**: System prompts, agent specialization, behavioral constraints, prompt engineering\n\n---\n\n### 4. **Think** - Reasoning & Problem Solving\n`think\u002F` | [Code](examples\u002F04_think\u002Fthink.js) | [Code Explanation](examples\u002F04_think\u002FCODE.md) | [Concepts](examples\u002F04_think\u002FCONCEPT.md)\n\n**What you'll learn:**\n- Configuring LLMs for logical reasoning\n- Complex quantitative problems\n- Limitations of pure LLM reasoning\n- When to use external tools\n\n**Key concepts**: Reasoning agents, problem decomposition, cognitive tasks, reasoning limitations\n\n---\n\n### 5. **Batch** - Parallel Processing\n`batch\u002F` | [Code](examples\u002F05_batch\u002Fbatch.js) | [Code Explanation](examples\u002F05_batch\u002FCODE.md) | [Concepts](examples\u002F05_batch\u002FCONCEPT.md)\n\n**What you'll learn:**\n- Processing multiple requests concurrently\n- Context sequences for parallelism\n- GPU batch processing\n- Performance optimization\n\n**Key concepts**: Parallel execution, sequences, batch size, throughput optimization\n\n---\n\n### 6. **Coding** - Streaming & Response Control\n`coding\u002F` | [Code](examples\u002F06_coding\u002Fcoding.js) | [Code Explanation](examples\u002F06_coding\u002FCODE.md) | [Concepts](examples\u002F06_coding\u002FCONCEPT.md)\n\n**What you'll learn:**\n- Real-time streaming responses\n- Token limits and budget management\n- Progressive output display\n- User experience optimization\n\n**Key concepts**: Streaming, token-by-token generation, response control, real-time feedback\n\n---\n\n### 7. **Simple Agent** - Function Calling (Tools)\n`simple-agent\u002F` | [Code](examples\u002F07_simple-agent\u002Fsimple-agent.js) | [Code Explanation](examples\u002F07_simple-agent\u002FCODE.md) | [Concepts](examples\u002F07_simple-agent\u002FCONCEPT.md)\n\n**What you'll learn:**\n- Function calling \u002F tool use fundamentals\n- Defining tools the LLM can use\n- JSON Schema for parameters\n- How LLMs decide when to use tools\n\n**Key concepts**: Function calling, tool definitions, agent decision making, action-taking\n\n**This is where text generation becomes agency!**\n\n---\n\n### 8. **Simple Agent with Memory** - Persistent State\n`simple-agent-with-memory\u002F` | [Code](examples\u002F08_simple-agent-with-memory\u002Fsimple-agent-with-memory.js) | [Code Explanation](examples\u002F08_simple-agent-with-memory\u002FCODE.md) | [Concepts](examples\u002F08_simple-agent-with-memory\u002FCONCEPT.md)\n\n**What you'll learn:**\n- Persisting information across sessions\n- Long-term memory management\n- Facts and preferences storage\n- Memory retrieval strategies\n\n**Key concepts**: Persistent memory, state management, memory systems, context augmentation\n\n---\n\n### 9. **ReAct Agent** - Reasoning + Acting\n`react-agent\u002F` | [Code](examples\u002F09_react-agent\u002Freact-agent.js) | [Code Explanation](examples\u002F09_react-agent\u002FCODE.md) | [Concepts](examples\u002F09_react-agent\u002FCONCEPT.md)\n\n**What you'll learn:**\n- ReAct pattern (Reason → Act → Observe)\n- Iterative problem solving\n- Step-by-step tool use\n- Self-correction loops\n\n**Key concepts**: ReAct pattern, iterative reasoning, observation-action cycles, multi-step agents\n\n**This is the foundation of modern agent frameworks!**\n\n---\n\n### 10. **AoT Agent** - Atom of Thought Planning\n`aot-agent\u002F` | [Code](examples\u002F10_aot-agent\u002Faot-agent.js) | [Code Explanation](examples\u002F10_aot-agent\u002FCODE.md) | [Concepts](examples\u002F10_aot-agent\u002FCONCEPT.md)\n\n**What you'll learn:**\n- Atom of Thought methodology\n- Atomic planning for multi-step computations\n- Dependency management between operations\n- Structured JSON output for reasoning plans\n- Deterministic execution of plans\n\n**Key concepts**: AoT planning, atomic operations, dependency resolution, plan validation, structured reasoning\n\n---\n\n## Documentation Structure\n\nEach example folder contains:\n\n- **`\u003Cname>.js`** - The working code example\n- **`CODE.md`** - Step-by-step code explanation\n- Line-by-line breakdowns\n- What each part does\n- How it works\n- **`CONCEPT.md`** - High-level concepts\n- Why it matters for agents\n- Architectural patterns\n- Real-world applications\n- Simple diagrams\n\n## Core Concepts\n\n### What is an AI Agent?\n\n```\nAI Agent = LLM + System Prompt + Tools + Memory + Reasoning Pattern\n           ─┬─   ──────┬──────   ──┬──   ──┬───   ────────┬────────\n            │          │           │       │              │\n         Brain      Identity    Hands   State         Strategy\n```\n\n### Evolution of Capabilities\n\n```\n1. intro          → Basic LLM usage\n2. translation    → Specialized behavior (system prompts)\n3. think          → Reasoning ability\n4. batch          → Parallel processing\n5. coding         → Streaming & control\n6. simple-agent   → Tool use (function calling)\n7. memory-agent   → Persistent state\n8. react-agent    → Strategic reasoning + tool use\n```\n\n### Architecture Patterns\n\n**Simple Agent (Steps 1-5)**\n```\nUser → LLM → Response\n```\n\n**Tool-Using Agent (Step 6)**\n```\nUser → LLM ⟷ Tools → Response\n```\n\n**Memory Agent (Step 7)**\n```\nUser → LLM ⟷ Tools → Response\n       ↕\n     Memory\n```\n\n**ReAct Agent (Step 8)**\n```\nUser → LLM → Think → Act → Observe\n       ↑      ↓      ↓      ↓\n       └──────┴──────┴──────┘\n           Iterate until solved\n```\n\n## ️ Helper Utilities\n\n### PromptDebugger\n`helper\u002Fprompt-debugger.js`\n\nUtility for debugging prompts sent to the LLM. Shows exactly what the model sees, including:\n- System prompts\n- Function definitions\n- Conversation history\n- Context state\n\nUsage example in `simple-agent\u002Fsimple-agent.js`\n\n## ️ Project Structure - Fundamentals\n\n```\nai-agents\u002F\n├── README.md                          ← You are here\n├─ examples\u002F\n├── 01_intro\u002F\n│   ├── intro.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 02_openai-intro\u002F\n│   ├── openai-intro.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 03_translation\u002F\n│   ├── translation.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 04_think\u002F\n│   ├── think.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 05_batch\u002F\n│   ├── batch.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 06_coding\u002F\n│   ├── coding.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 07_simple-agent\u002F\n│   ├── simple-agent.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 08_simple-agent-with-memory\u002F\n│   ├── simple-agent-with-memory.js\n│   ├── memory-manager.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 09_react-agent\u002F\n│   ├── react-agent.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── helper\u002F\n│   └── prompt-debugger.js\n├── models\u002F                             ← Place your GGUF models here\n└── logs\u002F                               ← Debug outputs\n```\n\n## Phase 2: Building a Production Framework (Tutorial)\n\nAfter mastering the fundamentals above, **Phase 2** takes you from scratch examples to production-grade framework design. You'll rebuild core concepts from **LangChain** and **LangGraph** to understand how real frameworks work internally.\n\n### What You'll Build\n\nA lightweight but complete agent framework with:\n- **Runnable Interface**, The composability pattern that powers everything\n- **Message System**, Typed conversation structures (Human, AI, System, Tool)\n- **Chains**, Composing multiple operations into pipelines\n- **Memory**, Persistent state across conversations\n- **Tools**, Function calling and external integrations\n- **Agents**, Decision-making loops (ReAct, Tool-calling)\n- **Graphs**, State machines for complex workflows (LangGraph concepts)\n\n### Learning Approach\n\n**Tutorial-first**: Step-by-step lessons with exercises  \n**Implementation-driven**: Build each component yourself  \n**Framework-compatible**: Learn patterns used in LangChain.js\n\n### Structure Overview\n\n```\ntutorial\u002F\n├── 01-foundation\u002F              # 1. Core Abstractions\n│   ├── 01-runnable\u002F\n│   │   ├── lesson.md           # Why Runnable matters\n│   │   ├── exercises\u002F          # Hands-on practice\n│   │   └── solutions\u002F          # Reference implementations\n│   ├── 02-messages\u002F            # Structuring conversations\n│   ├── 03-llm-wrapper\u002F         # Wrapping node-llama-cpp\n│   └── 04-context\u002F             # Configuration & callbacks\n│\n├── 02-composition\u002F             # 2. Building Chains\n│   ├── 01-prompts\u002F             # Template system\n│   ├── 02-parsers\u002F             # Structured outputs\n│   ├── 03-llm-chain\u002F           # Your first chain\n│   ├── 04-piping\u002F              # Composition patterns\n│   └── 05-memory\u002F              # Conversation state\n│\n├── 03-agency\u002F                  # 3. Tools & Agents\n│   ├── 01-tools\u002F               # Function definitions\n│   ├── 02-tool-executor\u002F       # Safe execution\n│   ├── 03-simple-agent\u002F        # Basic agent loop\n│   ├── 04-react-agent\u002F         # Reasoning + Acting\n│   └── 05-structured-agent\u002F    # JSON mode\n│\n└── 04-graphs\u002F                  # 4. State Machines\n    ├── 01-state-basics\u002F        # Nodes & edges\n    ├── 02-channels\u002F            # State management\n    ├── 03-conditional-edges\u002F   # Dynamic routing\n    ├── 04-executor\u002F            # Running workflows\n    ├── 05-checkpointing\u002F       # Persistence\n    └── 06-agent-graph\u002F         # Agents as graphs\n\nsrc\u002F\n├── core\u002F                       # Runnable, Messages, Context\n├── llm\u002F                        # LlamaCppLLM wrapper\n├── prompts\u002F                    # Template system\n├── chains\u002F                     # LLMChain, SequentialChain\n├── tools\u002F                      # BaseTool, built-in tools\n├── agents\u002F                     # AgentExecutor, ReActAgent\n├── memory\u002F                     # BufferMemory, WindowMemory\n└── graph\u002F                      # StateGraph, CompiledGraph\n```\n\n### Why This Matters\n\n**Understanding beats using**: When you know how frameworks work internally, you can:\n- Debug issues faster\n- Customize behavior confidently\n- Make architectural decisions wisely\n- Build your own extensions\n- Read framework source code fluently\n\n**Learn once, use everywhere**: The patterns you'll learn (Runnable, composition, state machines) apply to:\n- LangChain.js - You'll understand their abstractions\n- LangGraph.js - You'll grasp state management\n- Any agent framework - Same core concepts\n- Your own projects - Build custom solutions\n\n### Getting Started with Phase 2\n\nAfter completing the fundamentals (intro → react-agent), start the tutorial:\n\n[Overview](tutorial\u002FREADME.md)\n\n```bash\n# Start with the foundation\ncd tutorial\u002F01-foundation\u002F01-runnable\nlesson.md                    # Read the lesson\nnode exercises\u002F01-*.js           # Complete exercises\nnode solutions\u002F01-*-solution.js  # Check your work\n```\n\nEach lesson includes:\n- **Conceptual explanation**, Why it matters\n- **Code walkthrough**, How to build it\n- **Exercises**, Practice implementing\n- **Solutions**, Reference code\n- **Real-world examples**, Practical usage\n\n**Time commitment**: ~8 weeks, 3-5 hours\u002Fweek\n\n### What You'll Achieve\n\nBy the end, you'll have:\n1. Built a working agent framework from scratch\n2. Understood how LangChain\u002FLangGraph work internally\n3. Mastered composability patterns\n4. Created reusable components (tools, chains, agents)\n5. Implemented state machines for complex workflows\n6. Gained confidence to use or extend any framework\n\n**Then**: Use LangChain.js in production, knowing exactly what happens under the hood.\n\n---\n\n## Key Takeaways\n\n### After Phase 1 (Fundamentals), you'll understand:\n\n1. **LLMs are stateless**: Context must be managed explicitly\n2. **System prompts shape behavior**: Same model, different roles\n3. **Function calling enables agency**: Tools transform text generators into agents\n4. **Memory is essential**: Agents need to remember across sessions\n5. **Reasoning patterns matter**: ReAct > simple prompting for complex tasks\n6. **Performance matters**: Parallel processing, streaming, token limits\n7. **Debugging is crucial**: See exactly what the model receives\n\n### After Phase 2 (Framework Tutorial), you'll master:\n\n1. **The Runnable pattern**: Why everything in frameworks uses one interface\n2. **Composition over configuration**: Building complex systems from simple parts\n3. **Message-driven architecture**: How frameworks structure conversations\n4. **Chain abstraction**: Connecting prompts, LLMs, and parsers seamlessly\n5. **Tool orchestration**: Safe execution with timeouts and error handling\n6. **Agent execution loops**: The mechanics of decision-making agents\n7. **State machines**: Managing complex workflows with graphs\n8. **Production patterns**: Error handling, retries, streaming, and debugging\n\n### What frameworks give you:\n\nNow that you understand the fundamentals, frameworks like LangChain, CrewAI, or AutoGPT provide:\n- Pre-built reasoning patterns and agent templates\n- Extensive tool libraries and integrations\n- Production-ready error handling and retries\n- Multi-agent orchestration\n- Observability and monitoring\n- Community extensions and plugins\n\n**You'll use them better because you know what they're doing under the hood.**\n\n## Additional Resources\n\n- **node-llama-cpp**: [GitHub](https:\u002F\u002Fgithub.com\u002Fwithcatai\u002Fnode-llama-cpp)\n- **Model Hub**: [Hugging Face](https:\u002F\u002Fhuggingface.co\u002Fmodels?library=gguf)\n- **GGUF Format**: Quantized models for local inference\n\n## Contributing\n\nThis is a learning resource. Feel free to:\n- Suggest improvements to documentation\n- Add more example patterns\n- Fix bugs or unclear explanations\n- Share what you built!\n\n## License\n\nEducational resource - use and modify as needed for learning.\n\n---\n\n**Built with ❤️ for people who want to truly understand AI agents**\n\nStart with `intro\u002F` and work your way through. Each example builds on the previous one. Read both CODE.md and CONCEPT.md for full understanding.\n\nHappy learning! \n","> **阅读完整的交互式版本：**  \n> 本仓库是 **AI Agents From Scratch**（从零开始构建 AI 智能体）的一部分——这是一个动手学习系列，我们*逐步*构建 AI 智能体，解释每一个设计决策，并可视化底层发生了什么。  \n>  \n> 👉 **https:\u002F\u002Fagentsfromscratch.com**  \n>  \n> 如果你更喜欢**长篇解释、图表和概念深入探讨**，请从那里开始——然后回到这里探索代码。\n\n\n# 从零开始构建 AI 智能体 (AI Agents From Scratch)\n\n无需框架即可在本地构建 AI 智能体。在使用生产级框架之前，先理解其底层机制。\n\n## 目标\n\n本仓库教你使用 **本地大语言模型 (LLMs)** 和 **node-llama-cpp** 基于第一性原理构建 AI 智能体。通过完成这些示例，你将理解：\n\n- LLM 的基本工作原理\n- 智能体的本质（LLM + 工具 + 模式）\n- 不同智能体架构的运作方式\n- 框架为何做出某些设计选择\n\n**理念**：通过构建来学习。深入理解，然后明智地使用框架。\n\n## 相关项目\n\n### [从零开始构建 AI 产品](https:\u002F\u002Fgithub.com\u002Fpguso\u002Fai-product-from-scratch)\n\n[![TypeScript](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTypeScript-007ACC?logo=typescript&logoColor=white)](https:\u002F\u002Fwww.typescriptlang.org\u002F)\n[![React](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FReact-20232A?logo=react&logoColor=61DAFB)](https:\u002F\u002Freactjs.org\u002F)\n[![Node.js](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FNode.js-339933?logo=node.js&logoColor=white)](https:\u002F\u002Fnodejs.org\u002F)\n\n使用本地 LLM 学习 AI 产品开发基础。涵盖提示工程、结构化输出、多步推理、API 设计和前端集成，通过 10 个带有视觉图表的综合课程进行讲解。\n\n### [Python 版从零开始构建 AI 智能体](https:\u002F\u002Fgithub.com\u002Fpguso\u002Fagents-from-scratch) \n\n![Python](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython-3776AB?logo=python&logoColor=white)\n\n## 下一阶段：从零开始构建 LangChain 与 LangGraph 概念\n\n> 掌握基础后，本项目的下一阶段将带你使用原生 JavaScript 和本地模型**重新实现 LangChain 和 LangGraph 的核心部分**。\n> 这**不是**为了构建新框架，而是为了理解*框架是如何工作的*。  \n\n## 第一阶段：智能体基础 - 从 LLM 到 ReAct\n\n### 前置要求\n- Node.js 18+\n- 至少 8GB 内存（推荐 16GB）\n- 下载模型并放入 `.\u002Fmodels\u002F` 文件夹，详情见 [DOWNLOAD.md](DOWNLOAD.md)\n\n### 安装\n```bash\nnpm install\n```\n\n### 运行示例\n```bash\nnode intro\u002Fintro.js\nnode simple-agent\u002Fsimple-agent.js\nnode react-agent\u002Freact-agent.js\n```\n\n## 学习路径\n\n按顺序跟随这些示例以逐步建立理解：\n\n### 1. **入门** - 基础 LLM 交互\n`intro\u002F` | [代码](examples\u002F01_intro\u002Fintro.js) | [代码解释](examples\u002F01_intro\u002FCODE.md) | [概念](examples\u002F01_intro\u002FCONCEPT.md)\n\n**你将学到：**\n- 加载和运行本地 LLM\n- 基本的提示\u002F响应循环\n\n**关键概念**：模型加载、上下文、推理流水线、Token 生成\n\n---\n\n### 2. (可选) **OpenAI 入门** - 使用专有模型\n`openai-intro\u002F` | [代码](examples\u002F02_openai-intro\u002Fopenai-intro.js) | [代码解释](examples\u002F02_openai-intro\u002FCODE.md) | [概念](examples\u002F02_openai-intro\u002FCONCEPT.md)\n\n**你将学到：**\n- 如何调用托管 LLM（如 GPT-4）\n- 温度控制\n- Token 使用情况\n\n**关键概念**：推理端点、网络延迟、成本与控制、数据隐私、供应商依赖\n\n---\n\n### 3. **翻译** - 系统提示与专业化\n`translation\u002F` | [代码](examples\u002F03_translation\u002Ftranslation.js) | [代码解释](examples\u002F03_translation\u002FCODE.md) | [概念](examples\u002F03_translation\u002FCONCEPT.md)\n\n**你将学到：**\n- 使用系统提示对智能体进行专业化\n- 输出格式控制\n- 基于角色的行为\n- 针对不同模型的聊天封装器\n\n**关键概念**：系统提示、智能体专业化、行为约束、提示工程\n\n---\n\n### 4. **思考** - 推理与问题解决\n`think\u002F` | [代码](examples\u002F04_think\u002Fthink.js) | [代码解释](examples\u002F04_think\u002FCODE.md) | [概念](examples\u002F04_think\u002FCONCEPT.md)\n\n**你将学到：**\n- 配置 LLM 进行逻辑推理\n- 复杂定量问题\n- 纯 LLM 推理的局限性\n- 何时使用外部工具\n\n**关键概念**：推理智能体、问题分解、认知任务、推理局限性\n\n---\n\n### 5. **批处理** - 并行处理\n`batch\u002F` | [代码](examples\u002F05_batch\u002Fbatch.js) | [代码解释](examples\u002F05_batch\u002FCODE.md) | [概念](examples\u002F05_batch\u002FCONCEPT.md)\n\n**你将学到：**\n- 并发处理多个请求\n- 用于并行的上下文序列\n- GPU 批处理\n- 性能优化\n\n**关键概念**：并行执行、序列、批量大小、吞吐量优化\n\n---\n\n### 6. **编码** - 流式传输与响应控制\n`coding\u002F` | [代码](examples\u002F06_coding\u002Fcoding.js) | [代码解释](examples\u002F06_coding\u002FCODE.md) | [概念](examples\u002F06_coding\u002FCONCEPT.md)\n\n**你将学到：**\n- 实时流式响应\n- Token 限制与预算管理\n- 渐进式输出显示\n- 用户体验优化\n\n**关键概念**：流式传输、逐 Token 生成、响应控制、实时反馈\n\n---\n\n### 7. **简单智能体** - 函数调用（工具）\n`simple-agent\u002F` | [代码](examples\u002F07_simple-agent\u002Fsimple-agent.js) | [代码解释](examples\u002F07_simple-agent\u002FCODE.md) | [概念](examples\u002F07_simple-agent\u002FCONCEPT.md)\n\n**你将学到：**\n- 函数调用\u002F工具使用基础\n- 定义 LLM 可使用的工具\n- 参数的 JSON Schema\n- LLM 如何决定何时使用工具\n\n**关键概念**：函数调用、工具定义、智能体决策、行动执行\n\n**这就是文本生成转变为智能性的地方！**\n\n---\n\n### 8. **带记忆的简单智能体** - 持久化状态\n`simple-agent-with-memory\u002F` | [代码](examples\u002F08_simple-agent-with-memory\u002Fsimple-agent-with-memory.js) | [代码解释](examples\u002F08_simple-agent-with-memory\u002FCODE.md) | [概念](examples\u002F08_simple-agent-with-memory\u002FCONCEPT.md)\n\n**你将学到：**\n- 跨会话持久化信息\n- 长期记忆管理\n- 事实与偏好存储\n- 记忆检索策略\n\n**关键概念**：持久化记忆、状态管理、记忆系统、上下文增强\n\n---\n\n### 9. **ReAct 智能体** - 推理 + 行动\n`react-agent\u002F` | [代码](examples\u002F09_react-agent\u002Freact-agent.js) | [代码解释](examples\u002F09_react-agent\u002FCODE.md) | [概念](examples\u002F09_react-agent\u002FCONCEPT.md)\n\n**你将学到：**\n- ReAct 模式（推理 → 行动 → 观察）\n- 迭代问题解决\n- 逐步工具使用\n- 自我修正循环\n\n**关键概念**：ReAct 模式、迭代推理、观察 - 行动循环、多步智能体\n\n**这是现代智能体框架的基础！**\n\n### 10. **AoT Agent** - 思维原子规划\n`aot-agent\u002F` | [代码](examples\u002F10_aot-agent\u002Faot-agent.js) | [代码解释](examples\u002F10_aot-agent\u002FCODE.md) | [概念](examples\u002F10_aot-agent\u002FCONCEPT.md)\n\n**你将学到：**\n- 思维原子方法论\n- 多步计算的原子化规划\n- 操作间的依赖管理\n- 用于推理计划的 JSON 结构化输出\n- 计划的确定性执行\n\n**关键概念**: AoT 规划，原子操作，依赖解析，计划验证，结构化推理\n\n---\n\n## 文档结构\n\n每个示例文件夹包含：\n\n- **`\u003Cname>.js`** - 可运行的代码示例\n- **`CODE.md`** - 逐步代码解释\n- 逐行分解\n- 各部分功能说明\n- 工作原理\n- **`CONCEPT.md`** - 高层概念\n- 对智能体为何重要\n- 架构模式\n- 实际应用\n- 简单图表\n\n## 核心概念\n\n### 什么是 AI 智能体？\n\n```\nAI Agent = LLM + System Prompt + Tools + Memory + Reasoning Pattern\n           ─┬─   ──────┬──────   ──┬──   ──┬───   ────────┬────────\n            │          │           │       │              │\n         Brain      Identity    Hands   State         Strategy\n```\n\n### 能力演进\n\n```\n1. intro          → Basic LLM usage\n2. translation    → Specialized behavior (system prompts)\n3. think          → Reasoning ability\n4. batch          → Parallel processing\n5. coding         → Streaming & control\n6. simple-agent   → Tool use (function calling)\n7. memory-agent   → Persistent state\n8. react-agent    → Strategic reasoning + tool use\n```\n\n### 架构模式\n\n**简单智能体 (步骤 1-5)**\n```\nUser → LLM → Response\n```\n\n**工具使用智能体 (步骤 6)**\n```\nUser → LLM ⟷ Tools → Response\n```\n\n**记忆智能体 (步骤 7)**\n```\nUser → LLM ⟷ Tools → Response\n       ↕\n     Memory\n```\n\n**ReAct 智能体 (步骤 8)**\n```\nUser → LLM → Think → Act → Observe\n       ↑      ↓      ↓      ↓\n       └──────┴──────┴──────┘\n           Iterate until solved\n```\n\n## 🛠️ 辅助工具\n\n### PromptDebugger\n`helper\u002Fprompt-debugger.js`\n\n用于调试发送给 LLM (大型语言模型) 的提示词的工具。显示模型确切看到的内容，包括：\n- 系统提示词 (System prompts)\n- 函数定义 (Function definitions)\n- 对话历史 (Conversation history)\n- 上下文状态 (Context state)\n\n在 `simple-agent\u002Fsimple-agent.js` 中的使用示例\n\n## 📂 项目结构 - 基础篇\n\n```\nai-agents\u002F\n├── README.md                          ← You are here\n├─ examples\u002F\n├── 01_intro\u002F\n│   ├── intro.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 02_openai-intro\u002F\n│   ├── openai-intro.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 03_translation\u002F\n│   ├── translation.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 04_think\u002F\n│   ├── think.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 05_batch\u002F\n│   ├── batch.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 06_coding\u002F\n│   ├── coding.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 07_simple-agent\u002F\n│   ├── simple-agent.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 08_simple-agent-with-memory\u002F\n│   ├── simple-agent-with-memory.js\n│   ├── memory-manager.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── 09_react-agent\u002F\n│   ├── react-agent.js\n│   ├── CODE.md\n│   └── CONCEPT.md\n├── helper\u002F\n│   └── prompt-debugger.js\n├── models\u002F                             ← Place your GGUF models here\n└── logs\u002F                               ← Debug outputs\n```\n\n## 第二阶段：构建生产级框架 (教程)\n\n掌握上述基础后，**第二阶段**将带你从入门示例过渡到生产级框架设计。你将重新构建 **LangChain** 和 **LangGraph** 的核心概念，以理解真实框架的内部运作机制。\n\n### 你将构建什么\n\n一个轻量但完整的智能体框架，包含：\n- **可运行接口 (Runnable Interface)**，驱动一切的可组合模式\n- **消息系统 (Message System)**，类型化的对话结构 (人类、AI、系统、工具)\n- **链 (Chains)**，将多个操作组合成流水线\n- **记忆 (Memory)**，跨对话的持久状态\n- **工具 (Tools)**，函数调用与外部集成\n- **智能体 (Agents)**，决策循环 (ReAct, 工具调用)\n- **图 (Graphs)**，复杂工作流的状态机 (LangGraph 概念)\n\n### 学习方法\n\n**以教程为先导**：带有练习的分步课程  \n**以实现为导向**：亲手构建每个组件  \n**与框架兼容**：学习 LangChain.js 中使用的模式\n\n### 结构概览\n\n```\ntutorial\u002F\n├── 01-foundation\u002F              # 1. Core Abstractions\n│   ├── 01-runnable\u002F\n│   │   ├── lesson.md           # Why Runnable matters\n│   │   ├── exercises\u002F          # Hands-on practice\n│   │   └── solutions\u002F          # Reference implementations\n│   ├── 02-messages\u002F            # Structuring conversations\n│   ├── 03-llm-wrapper\u002F         # Wrapping node-llama-cpp\n│   └── 04-context\u002F             # Configuration & callbacks\n│\n├── 02-composition\u002F             # 2. Building Chains\n│   ├── 01-prompts\u002F             # Template system\n│   ├── 02-parsers\u002F             # Structured outputs\n│   ├── 03-llm-chain\u002F           # Your first chain\n│   ├── 04-piping\u002F              # Composition patterns\n│   └── 05-memory\u002F              # Conversation state\n│\n├── 03-agency\u002F                  # 3. Tools & Agents\n│   ├── 01-tools\u002F               # Function definitions\n│   ├── 02-tool-executor\u002F       # Safe execution\n│   ├── 03-simple-agent\u002F        # Basic agent loop\n│   ├── 04-react-agent\u002F         # Reasoning + Acting\n│   └── 05-structured-agent\u002F    # JSON mode\n│\n└── 04-graphs\u002F                  # 4. State Machines\n    ├── 01-state-basics\u002F        # Nodes & edges\n    ├── 02-channels\u002F            # State management\n    ├── 03-conditional-edges\u002F   # Dynamic routing\n    ├── 04-executor\u002F            # Running workflows\n    ├── 05-checkpointing\u002F       # Persistence\n    └── 06-agent-graph\u002F         # Agents as graphs\n\nsrc\u002F\n├── core\u002F                       # Runnable, Messages, Context\n├── llm\u002F                        # LlamaCppLLM wrapper\n├── prompts\u002F                    # Template system\n├── chains\u002F                     # LLMChain, SequentialChain\n├── tools\u002F                      # BaseTool, built-in tools\n├── agents\u002F                     # AgentExecutor, ReActAgent\n├── memory\u002F                     # BufferMemory, WindowMemory\n└── graph\u002F                      # StateGraph, CompiledGraph\n```\n\n### 为什么这很重要\n\n**理解胜过使用**：当你了解框架内部如何工作时，你可以：\n- 更快地调试问题\n- 自信地定制行为\n- 明智地做出架构决策\n- 构建你自己的扩展\n- 流畅地阅读框架源代码\n\n**学一次，处处用**：你将学到的模式 (Runnable, 组合，状态机) 适用于：\n- LangChain.js - 你将理解它们的抽象\n- LangGraph.js - 你将掌握状态管理\n- 任何智能体框架 - 相同的核心理念\n- 你自己的项目 - 构建自定义解决方案\n\n### 开始第二阶段\n\n完成基础部分 (intro → react-agent) 后，开始教程：\n\n[概览](tutorial\u002FREADME.md)\n\n```bash\n\n# 从基础开始\ncd tutorial\u002F01-foundation\u002F01-runnable\nlesson.md                    # 阅读课程\nnode exercises\u002F01-*.js           # 完成练习\nnode solutions\u002F01-*-solution.js  # 检查你的工作\n\n每节课包括：\n- **概念解释**，为什么这很重要\n- **代码演示**，如何构建它\n- **练习**，实践实现\n- **解决方案**，参考代码\n- **现实世界示例**，实际用法\n\n**时间投入**：约 8 周，每周 3-5 小时\n\n### 你将获得什么\n\n结束时，你将拥有：\n1. 从零构建一个可用的 Agent（智能体）框架\n2. 理解 LangChain\u002FLangGraph 的内部工作原理\n3. 掌握组合模式\n4. 创建可复用组件（Tools、Chains、Agents）\n5. 为复杂工作流实现状态机\n6. 获得使用或扩展任何框架的信心\n\n**接下来**：在生产环境中使用 LangChain.js，确切了解其底层运作。\n\n---\n\n## 关键要点\n\n### 第一阶段（基础）结束后，你将理解：\n\n1. **LLM（大型语言模型）是无状态的**：上下文必须显式管理\n2. **系统提示塑造行为**：同一模型，不同角色\n3. **函数调用赋予能动性**：工具将文本生成器转变为智能体\n4. **记忆至关重要**：智能体需要在跨会话中记住信息\n5. **推理模式很重要**：对于复杂任务，ReAct > 简单提示\n6. **性能很重要**：并行处理、流式传输、Token 限制\n7. **调试至关重要**：确切查看模型接收到的内容\n\n### 第二阶段（框架教程）结束后，你将掌握：\n\n1. **Runnable 模式（可运行接口）**：为什么框架中的所有内容都使用一个接口\n2. **组合优于配置**：用简单部分构建复杂系统\n3. **消息驱动架构**：框架如何组织对话\n4. **链抽象**：无缝连接提示词、LLM 和解析器\n5. **工具编排**：带超时和错误处理的执行\n6. **智能体执行循环**：决策型智能体的机制\n7. **状态机**：用图管理复杂工作流\n8. **生产环境模式**：错误处理、重试、流式传输和调试\n\n### 框架为你提供：\n\n既然你已经理解了基础，像 LangChain、CrewAI 或 AutoGPT 这样的框架提供：\n- 预构建的推理模式和智能体模板\n- 丰富的工具库和集成\n- 生产就绪的错误处理和重试\n- 多智能体编排\n- 可观测性和监控\n- 社区扩展和插件\n\n**你会更好地使用它们，因为你了解其底层运作。**\n\n## 额外资源\n\n- **node-llama-cpp**: [GitHub](https:\u002F\u002Fgithub.com\u002Fwithcatai\u002Fnode-llama-cpp)\n- **模型中心**: [Hugging Face](https:\u002F\u002Fhuggingface.co\u002Fmodels?library=gguf)\n- **GGUF 格式**：用于本地推理的量化模型\n\n## 贡献\n\n这是一个学习资源。欢迎：\n- 建议改进文档\n- 添加更多示例模式\n- 修复 Bug 或不清晰的解释\n- 分享你构建的内容！\n\n## 许可\n\n教育资源 - 根据需要自由使用和修改以进行学习。\n\n---\n\n**用心 ❤️ 打造，献给想要真正理解 AI 智能体的人**\n\n从 `intro\u002F` 开始并逐步进行。每个示例都建立在之前的示例之上。阅读 `CODE.md` 和 `CONCEPT.md` 以获得完整理解。\n\n快乐学习！","# ai-agents-from-scratch 快速上手指南\n\n本工具是 **AI Agents From Scratch** 系列的一部分，旨在通过从零开始构建 AI Agent，帮助你深入理解大语言模型（LLM）的工作原理及 Agent 架构设计。无需依赖生产级框架，直接在本地使用 LLM 进行实践。\n\n## 环境准备\n\n在开始之前，请确保满足以下系统要求：\n\n- **Node.js**: 版本需为 18 或更高。\n- **内存**: 至少 8GB RAM（推荐 16GB）。\n- **模型文件**: 下载支持 `node-llama-cpp` 的本地 LLM 模型（GGUF 格式），并将其放置于项目根目录下的 `.\u002Fmodels\u002F` 文件夹中。\n  - 具体模型下载与配置详情，请参阅项目内的 **[DOWNLOAD.md](DOWNLOAD.md)**。\n\n## 安装步骤\n\n1. 将项目代码克隆至本地。\n2. 在项目根目录下打开终端，执行以下命令安装依赖：\n```bash\nnpm install\n```\n\n## 基本使用\n\n安装完成后，即可运行内置示例来体验从基础交互到复杂 Agent 的构建过程。\n\n### 运行基础示例\n这是最简单的入门示例，展示如何加载并运行本地 LLM：\n```bash\nnode intro\u002Fintro.js\n```\n\n### 进阶示例\n随着学习的深入，你可以依次运行以下示例：\n```bash\n# 简单 Agent（工具调用）\nnode simple-agent\u002Fsimple-agent.js\n\n# ReAct Agent（推理 + 行动）\nnode react-agent\u002Freact-agent.js\n```\n\n> **学习建议**：每个示例文件夹内都包含 `CODE.md`（代码逐行解释）和 `CONCEPT.md`（核心概念解析），建议结合阅读以掌握底层原理。","某金融科技公司内部数据团队计划构建一个私有化部署的智能分析助手，用于处理敏感的财务日志查询与报告生成。\n\n### 没有 ai-agents-from-scratch 时\n- 过度依赖成熟框架的黑盒封装，当 Agent 出现逻辑死循环时无法定位底层原因。\n- 主流方案多强制调用云端 API，导致敏感财务数据面临泄露风险，不符合合规要求。\n- 对 Function Calling 和记忆机制理解模糊，难以根据业务需求定制工具响应格式。\n- 调试过程缺乏可视化支持，排查 ReAct 推理路径中的错误耗时极长。\n\n### 使用 ai-agents-from-scratch 后\n- 基于本地 LLM 构建流程，所有数据处理均在本地完成，彻底消除数据外泄隐患。\n- 亲手实现 ReAct 模式核心逻辑，能精准控制工具调用时机，显著提升任务成功率。\n- 深入理解内存管理机制，灵活设计上下文窗口，有效解决长对话中的信息遗忘问题。\n- 结合源码逐步调试，直观看到 Token 消耗与决策过程，大幅缩短故障排查时间。\n\n通过从零构建，开发者不仅能掌握 Agent 核心原理，更能打造安全、透明且高度可定制的本地智能应用。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fpguso_ai-agents-from-scratch_e0ea920b.png","pguso","Patric Gutersohn","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fpguso_8b600741.jpg",null,"patric.gutersohn@gmx.de","GutersohnPatric","https:\u002F\u002Fgithub.com\u002Fpguso",[83],{"name":84,"color":85,"percentage":86},"JavaScript","#f1e05a",100,3356,507,"2026-04-05T11:02:01","MIT","未说明","至少 8GB (推荐 16GB)",{"notes":94,"python":91,"dependencies":95},"项目基于 Node.js 18+ 和 TypeScript 构建，非 Python 项目。运行前需执行 npm install 安装依赖，并根据 DOWNLOAD.md 指引下载本地 LLM 模型文件存入 .\u002Fmodels 目录。",[96],"node-llama-cpp",[26,13,15],[99,100,101,102,103,96,104,105],"ai-agents","educational","function-calling","llm","llm-agent","react-agent","tutorial","2026-03-27T02:49:30.150509","2026-04-06T07:10:08.380313",[109,114,119,124,129,134],{"id":110,"question_zh":111,"answer_zh":112,"source_url":113},2275,"代码示例中的资源清理顺序在文档中描述正确吗？","不正确，原文档描述的顺序与实际代码执行相反。维护者已修复了相关示例和代码中的文档说明，请参照最新版本的 README。","https:\u002F\u002Fgithub.com\u002Fpguso\u002Fai-agents-from-scratch\u002Fissues\u002F16",{"id":115,"question_zh":116,"answer_zh":117,"source_url":118},2276,"什么是 Harmony 格式？翻译脚本为何选择 Apertus 模型？","Harmony 是一种用于多角色聊天的结构化消息格式，定义了 system、user、assistant 等角色及内部推理通道。翻译脚本选择了 Apertus-8B，因为它是一个专门训练的多语言大模型。维护者已更新文档以澄清这些细节。","https:\u002F\u002Fgithub.com\u002Fpguso\u002Fai-agents-from-scratch\u002Fissues\u002F14",{"id":120,"question_zh":121,"answer_zh":122,"source_url":123},2277,"simple-agent-with-memory.js 的内存文件保存位置和格式有什么问题？","早期版本可能将内存写入根目录而非子目录，且保存的事实缺乏上下文（如仅存名字）。维护者已更新代码以修正路径并增加上下文信息，建议重新拉取最新代码。","https:\u002F\u002Fgithub.com\u002Fpguso\u002Fai-agents-from-scratch\u002Fissues\u002F13",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},2278,"运行 simple-agent.js 时提示缺少目录怎么办？","这是因为缺少 logs 目录。维护者已在仓库中包含了该目录，请确保从最新代码库拉取或手动创建 logs 文件夹以避免运行失败。","https:\u002F\u002Fgithub.com\u002Fpguso\u002Fai-agents-from-scratch\u002Fissues\u002F12",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},2279,"intro.js 教程需要下载哪些模型？","需要 Qwen3-1.7B 模型。维护者已在 DOWNLOAD.md 中补充了下载命令：`npx --no node-llama-cpp pull --dir .\u002Fmodels --filename=Qwen3-1.7B-Q8_0.gguf hf:Qwen\u002FQwen3-1.7B-GGUF:Q8_0`。","https:\u002F\u002Fgithub.com\u002Fpguso\u002Fai-agents-from-scratch\u002Fissues\u002F9",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},2280,"不同脚本对模型文件名是否有特殊要求？","是的，部分模型文件名可能与默认下载名不一致。例如 batch.js 需要特定的 DeepSeek 模型文件名，建议使用 --filename 参数明确指定，避免混淆。","https:\u002F\u002Fgithub.com\u002Fpguso\u002Fai-agents-from-scratch\u002Fissues\u002F11",[]]