出于中国政治宣传的需要,作为美国同伙之一的以色列总是以一副欺凌巴勒斯坦的面目出现。
但是《耶路撒冷三千年》,却给我们展现了犹太人三千年来备受磨难、颠沛流离、居无定所的历史。
因为耶稣受难的缘故,犹太人成了基督教徒、伊斯兰教徒的冲突对象,而耶路撒冷的神圣性又使犹太人的应许之地,成了各大帝国的必争之地,罗马帝国、波斯帝国、拜占庭帝国、奥斯曼帝国的铁骑都曾从耶路撒冷踏过,希特勒的“最终解决方案”,更是使犹太人面临灭族的危险。
当你回顾起中国的百年屈辱史,更能感同身受到犹太人对于民族生存、安全的关注,也就自然了解以色列一系列看似强势的行事方式,当然,巴勒斯坦的人民也是如此。
但是,作为三大宗教的圣地耶路撒冷,冲突只是唯一的选择吗?

在hexo github 的issue里找到了解决办法,解决Hexo置顶问题,只需两步:

  1. 用文章中的js代码替换node_modules/hexo-generator-index/lib/generator.js (见下文代码段)
  2. 在需要置顶的文章的front-matter中添加top值,值越大越置顶。
1
2
3
4
5
title: 某某文章
date:
tags:
categories:
top: 1000
阅读全文 »

更新了 NexT主题之后,发表文章那里显示了两次时间(之前的版本是只有一个时间的):
NexT Informations
Master: 5.1.0
NexT Scheme:
Pisces

其實是對的, Posted on 2016-11-04 | 2016-11-04 第一個日期, 是你create, 第二個日期是你有沒有modify 過你的文章。

如何屏蔽modify的选项:
在主题NexT下面的目录:layout/_macro 裏面的post.swig,
去掉如下一段:

1
2
3
<time title="{{ __('post.modified') }}" itemprop="dateModified" datetime="{{ moment(post.updated).format() }}">  
{{ date(post.updated, config.date_format) }}
</time>

还有上面的这个竖:

1
&nbsp;|&nbsp;

MathJax是一款运行在浏览器中的开源的数学符号渲染引擎,使用MathJax可以方便的在浏览器中显示数学公式,不需要使用图片。目前,MathJax可以解析Latex(wiki百科使用的)、MathML和ASCIIMathML的标记语言。 MathJax项目于2009年开始,发起人有American Mathematical Society, Design Science等,还有众多的支持者,个人感觉MathJax会成为今后数学符号渲染引擎中的主流,也许现在已经是了。
注:wiki拷贝过来的公式需要做一定的修改,才能正确显示。具体的差异可以通过一下网站生成一个公式的LaTeX代码比较一下!《黄金分割》这篇博客是第一次用MathJax书写数学公式。

一、Math的使用及安装

1、在线手写数学工具生成器

推荐一个在线手写公式转Tex格式的利器:Web Equation
通过手写公式,即可得到公式所对应的Tex格式,非常好用。

阅读全文 »

四、2024年2月更换新mac airbook 安装的记录

新版本的一些改变,需求修改的部分

  1. # - 之前必须有空行(不是很确定)
  2. img 不能有空的 “ ”,需要替换。
  3. - 换行不起作用 需要在前面加Tab;(不是很 确定)。
  4. 文章中yaml部分的Title 和文件名必须一致。
  5. > 符号前面和后面要空行。
  6. 代码块的前后标签都需要单独一行。
  7. 行内公式的用法,之前和独行公式混了,需要重新修改。
  8. ` 必须用\ 转义
  9. 多个-之间不要有空行,否则显示出来就是每个-之间都空一行。

换行的问题

参考: hexo 回车换行无效?

markdown的换行规范:

段落与换行

  1. 段落的前后必须是空行:
    空行指的是行内什么都没有,或者只有空白符(空格或制表符)
    相邻两行文本,如果中间没有空行 会显示在一行中(换行符被转换为空格).
  2. 如果需要在段落内加入换行(<br>):
    可以在前一行的末尾加入至少两个空格.
    然后换行写其它的文字.
  3. Markdown 中的多数区块都需要在两个空行之间。

markdown的规范是软回车,键盘上的回车键是硬回车。一般回车是代表换段。在markdown中,要创建段落,请使用空白行将一行或多行文本进行分隔。

问题:

mac上,之前使用hexo(19年配置的)+next皮肤,回车键就是换行符号了,用起来很丝滑。
最近hexo频繁报错,我就重新装了个最新版本,必须要加,极为难用,而且之前的也要一个一个改正,把 ,十分痛苦。
问问各位大佬,如何改为之前那种使用。

回答:

终于弄好了,尝试更改了marked,marked-i,pand.....等渲染,mathjax数学公式,捣鼓一天,全都不work,有冲突。最后将以前的package.json中的所有依赖重新安装,就和以前一样了。主要是 mathjax 的锅,加了mathjax:true后就没法自动换行了。所以建议大家图省事的话也是找一个没问题的package.json,全部无脑照着安装就行。

个人搞了好久,使用原先的kramed渲染器,回车换行倒是可以了,但数学公式很多地方显示不正常。并且kramed已经停止更新好多年了,所以决定不再用。
markdown-it支持KaTex,但对MathJax的支持不好,所以也没用。
后来还是保留了pandoc的渲染器。即使需要批量修改原先的md文件,特别是段内换行的问题比较突出。

发现在pakage.json中,renderer部分就保留了:

"hexo-renderer-ejs": "^2.0.0",
"hexo-renderer-pandoc": "^0.4.0",
"hexo-renderer-stylus": "^3.0.1",

其实就是使用了next的mathjax引擎,然后安装hexo的pandoc渲染器。

pandoc语法的几个常见注意事项:

  • 换行前加两个空格。
  • 图片使用绝对路径。
  • 标题前两个回车。
  • 把本地图片地址变为绝对路径。

使用 pandoc 渲染器 切换 hexo-renderer-pandoc 后,公式倒是能正常显示,但是图片,文本格式需要按 pandoc 的 markdown 格式修改,因此,做了批量调整:

pandoc导致历史md文件格式问题在sublime text中调整方法:

有时,我们可能需要将文件中的换行符替换为其他字符,比如英文逗号、分号等。
Sublime Text 使用正则表达式来替换文本内容非常方便。
举例,一个回车键替换成 空格+空格+回车,以实现段内换行的效果。
你可以通过以下步骤来替换:
1. 打开 Sublime Text 编辑器
2. 打开要替换的文件
3. 按下快捷键「Ctrl + H」(「Cmd + Shift + H」在 Mac 上)
4. 在「Find What」输入框中输入需要替换的字符串:\n
5. 在「Replace With」输入框中输入替换后的字符串:空格+空格+\n
6. 选择「Regular Expression」复选框 (sublime 里面的 .* 那个按钮)
7. 点击「Replace」或「Replace All」按钮进行替换
如果你需要使用正则表达式语法,例如匹配数字、单词等,请参考其它资源了解正则表达式语法。
注意事项,替换的时候因为yaml部分也增加了两个空格,导致出错,需要把yaml那些多出来的空格删除。

软件升级最大的问题,规范变了,导致历史的文章需要根据新的规范做修改。

安装完成后执行 hexo clean. 命令来清空以前生成的 HTML 文件,然后重新 hexo g -d 发布。

关于markdown换行的一篇好文章。 markdown段内换行的说明

渲染器的问题

Hexo 作为一个优秀的 Markdown 博客框架,自然也诞生了很多适用的 Markdown 渲染器,这里对比分析一下 Hexo 下几种常用的 Markdown 渲染器: hexo-renderer-marked , hexo-renderer-kramed , hexo-renderer-pandoc , hexo-renderer-markdown-it , hexo-renderer-markdown-it-plus 。

Next 提供了两个渲染引擎来显示数学方程: MathJax 和 KaTeX。要使用这个特性,您只需要选择一个渲染引擎并打开它的 enable(位于home config file)。 然后你需要安装相应的 Hexo 渲染器来完全支持数学方程式的显示。

ssh key的问题

git config --global user.name “hongyitong”
git config --global user.email “hogyuanjiao@hotmail.com”
ssh-keygen -t rsa -b 4096 -C “hogyuanjiao@hotmail.com”

  1. 查看本地是否存在SSH密钥
    命令:ls -al ~/.ssh
    如果在输出的文件列表中发现id_rsa和id_rsa.pub的存在,证明本地已经存在SSH密钥,请执行第3步

  2. 查看SSH公钥
    命令:cat /Users/电脑用户名/.ssh/id_rsa.pub
    复制打印出来的信息,在GitLab或者GitHub的SSH Keys中进行相应设置即可

  3. 警告的信息
    > You've successfully authenticated, but GitHub does not provide shell access.
    这句话其实一直存在,它只是想告诉你,github 不允许 shell 交互。仅此而已。

mac技巧

Mac用户注意了,要使用管理员权限,首先:“sudo -s”,回车,输入密码,再回车,然后:“npm install -g hexo-cli”,回车,等待下载安装即可!

参考的资料

Mac OS环境下使用Hexo搭建个人博客

三、多机搭建(更换电脑搭建)

其实简单说,就是四个部分:
1、备份
备份source文件夹(所有的MD文件都在这里);备份站点的_config.yml,主题的的_config.yml;
如果担心,可以把整个hexo目录备份下来;
2、安装
按照指引安装(其实可以按照第一次的安装来处理),只是涉及github 仓库那一部分是不需要了;
3、恢复
1)把source目录恢复覆盖;
2)两个_config.yml的内容,比较,然后把需要的部分copy到新装的文件里面替换对应内容。注意,这里不要用整个文件覆盖的模式,因为可能对应的软件的版本不一致了。
4、安装相关的插件
包括支持数学公式、置顶、搜索等等;

因为之前上传到百度网盘的MD源文件,下载之后的创建日期都变成下载那天的时间,导致之前很多没有定义date时间的都默认成下载的日期了。
花了好长时间把MD文件的date属性都加上了发布的时间。

多机部署参考:
多机更新 Hexo 博客
上文中提到的:先在电脑中的某一位置建立好 your_name.github.io 文件夹,比如 D:_name.github.io;
因为之前习惯取了hexo的名字,其实 hexo目录就是这里所谓的 youre_name.githubo.io文件夹。

一、第一次搭建过程资料

经过几天的努力,终于把个人的博客搭建得差不多了。个人的博客现在存在Github和Coding两个地方,地址分别是:
Github版
Coding版     !Coding版本因为有100M的空间限制,无法发布了!

Coding用不了之后,使用了码云Oschina,具体的设置如下(不过Oschina还有有点不稳定和刷新速度比较慢。):
Oschina版
Oschina免费版限制空间了,因为博客容量太大,无法再从github中pull过来了
码云
搭建个人免费博客:利用Hexo在码云上部署博客

在搭建过程当中,参考了以下的文档,特此记录!
如何利用GitHub Pages和Hexo快速搭建个人博客     (这个博客不知道什么原因,访问不了:()
参考一下以下几个吧:
知行合一 用 Hexo 搭建博客
Hexo+nexT主题搭建个人博客
手把手教你使用Hexo + Github Pages搭建个人独立博客

hexo同时托管到coding.net与github
如何将Hexo Blog同时发布到GitHub跟Coding上
|Hexo优化|如何向google提交sitemap(详细)

设置 Google站点管理工具 的验证字符串,用于提交 sitemap

获取 google site verification code
登录 Google Webmaster Tools,导航到验证方法,并选择 HTML Tag。将会获取到一段代码:

1
<meta name="google-site-verification" content="XXXXXXXXXXXXXXXXXXXXXXX" />

将 content 里面的 XXXXXXXXXXXXXXXXXXXXXXX 复制出来。
设置主题。编辑 站点配置,新增字段 google_site_verification。
google_site_verification: XXXXXXXXXXXXXXXXXXXXXXX

在google加了github的收录,但是在增加百度收录的时候,一直生成不了baidusitemap.xml文件。暂时放弃。(后来重启电脑就自动有了:-()
hexo干货系列:(六)hexo提交搜索引擎(百度+谷歌)

本地预览没问题,deploy后主页显示大面积空白

二、优化过程及问题

!!!!!如果本地预览没问题,部署到github有问题的话,先 hexo clean掉在重新 hexo d -g

1、搜索

因为Swiftype收费了,转向了微搜索:
NexT主题下的两种搜索服务的问题

后来简单点,直接使用了Next主题的本地搜索了,具体见下文!
Hexo博客添加站内搜索
补充一点,还需要修改主题下的_config.yml文件,把enable:false改成true

1
2
3
# Local search
local_search:
enable: true

2、数学公式

如何在Hexo中使用MathJax

3、文章发表时间显示了两遍

文章发表时间显示了两遍

4、Hexo文章置顶

Hexo文章置顶

5、如何链接站内文章

A:next或者hexo,链接站内文章的方法?
B:关于引用站内文章的链接,可以使用以下语法:

1
{% post_link markdown-learning-by-maxiang 点击这里查看这篇文章 %}

markdown-learning-by-maxiang是你的文章名称。如果文章不存在,这段代码将会被直接忽略。
点击这里查看这篇文章是该链接的标题。如果置空,则自动提取文章的标题。
ps:这个功能跟主题无关。

6、git远程库与本地联系报错:fatal: Not a git repository (or any of the parent directories): .git

在github上新建了一个仓库,然后相与本地的仓库联系起来
$ Git remote add origin https://github.com/liona329/learngit.git fatal: Not a git repository (or any of the parent directories): .git
总是报这个错
解决方法:git init
成功

7、github build出错信息会发到注册的邮箱

1
2
3
4
5
6
7
8
9
10
11
12
[hongyitong/hongyitong.github.io] Page build failure
G
GitHub <support@github.com>
今天, 16:12

The page build failed for the `master` branch with the following error:

The tag `fancybox` on line 77 in `themes/landscape/README.md` is not a recognized Liquid tag. For more information, see https://help.github.com/articles/page-build-failed-unknown-tag-error/.

For information on troubleshooting Jekyll see:

https://help.github.com/articles/troubleshooting-jekyll-builds

8、Error: Cannot find module 'hexo-util'

升级NexT主题以后,执行hexo clean,出错:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
✗ hexo clean         
ERROR Script load failed: themes/next/scripts/tags/exturl.js
Error: Cannot find module 'hexo-util'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/lib/hexo/index.js:213:21)
at /Users/lisanlai/lisanlai.github.io/themes/next/scripts/tags/exturl.js:8:12
at /Users/lisanlai/lisanlai.github.io/node_modules/hexo/lib/hexo/index.js:229:12
at tryCatcher (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:502:31)
at Promise._settlePromise (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:559:18)
at Promise._settlePromise0 (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:604:10)
at Promise._settlePromises (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:683:18)
at Promise._fulfill (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:628:18)
at Promise._resolveCallback (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:423:57)
at Promise._settlePromiseFromHandler (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:514:17)
at Promise._settlePromise (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:559:18)
at Promise._settlePromise0 (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:604:10)
at Promise._settlePromises (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:683:18)
at Promise._fulfill (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:628:18)
at /Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/nodeback.js:42:21
at /Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/hexo-fs/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
INFO Deleted database.

解决办法:重新安装hexo-util模块

1
npm install -- save-dev hexo-util

9、HEXO-NexT的Local Search转圈圈的问题

可以在浏览器中输入 博客网址:

1
http://localhost:4000/search.xml 

其中 search.xml是搜索的内容文档,在hexo 对应的pubic目录下。

如果有错,浏览器会报出具体的错误。

可以找到引起错误的md文件,然后在search.xml文档中找到对应的段落,可以使用https://www.xmlvalidation.com/ 来验证对应段落的具体错误原因。
具体的文档可以见:https://guahsu.io/2017/12/Hexo-Next-LocalSearch-cant-work/

10、本地预览没问题deploy后主页显示大面积空白

本地预览没问题,deploy后主页显示大面积空白

11、Hexo 博客无法搜索的终极解决方法

http://www.sqlsec.com/2017/12/hexosearch.html

12、文章添加阅读次数,访问量等

Hexo+Next主题 文章添加阅读次数,访问量等:
https://blog.csdn.net/xr469786706/article/details/78166227
hexo博客解决不蒜子统计无法显示问题:
https://www.jianshu.com/p/fd3accaa2ae0

13、解决MacOS升级后出现xcrun: error: invalid active developer path, missing xcrun的问题

今天升级macOS High Sierra,终端里使用git的时候,弹出一行莫名其妙的错误:

1
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun 

解决方法,重装xcode command line:

1
xcode-select --install 

如果没有解决问题,执行以下命令

1
sudo xcode-select -switch / 

Appendix C - Quick overview of Agentic Frameworks | 附录C: 智能体框架快速概览

LangChain

LangChain is a framework for developing applications powered by LLMs. Its core strength lies in its LangChain Expression Language (LCEL), which allows you to "pipe" components together into a chain. This creates a clear, linear sequence where the output of one step becomes the input for the next. It's built for workflows that are Directed Acyclic Graphs (DAGs), meaning the process flows in one direction without loops.

LangChain是用于开发基于大语言模型(LLM)的应用程序框架。它的核心优势在于其LangChain表达式语言(LCEL),该语言允许您将组件“串联”成链。这创建了清晰的线性序列,其中上一步的输出成为下一步的输入。它专为有向无环图(DAG)工作流而设计,这意味着流程沿一个方向流动,没有循环。

Use it for: 用途:

● Simple RAG: Retrieve a document, create a prompt, get an answer from an LLM.

简单 RAG:检索文档,创建提示,从LLM获取答案。

● Summarization: Take user text, feed it to a summarization prompt, and return the output.

摘要:获取用户文本,将其输入摘要提示,并返回输出结果。

● Extraction: Extract structured data (like JSON) from a block of text.

提取:从文本块中提取结构化数据(例如JSON)。

Python

1
2
3
# A simple LCEL chain conceptually
# (This is not runnable code, just illustrates the flow)
chain = prompt | model | output_parse

LangGraph

LangGraph is a library built on top of LangChain to handle more advanced agentic systems. It allows you to define your workflow as a graph with nodes (functions or LCEL chains) and edges (conditional logic). Its main advantage is the ability to create cycles, allowing the application to loop, retry, or call tools in a flexible order until a task is complete. It explicitly manages the application state, which is passed between nodes and updated throughout the process.

LangGraph是基于LangChain构建的库,用于处理更高级的智能体系统。它允许您将工作流定义为图,该图由节点(函数或LCEL链)和边(条件逻辑)组成。其主要优势在于能够创建循环,从而允许应用程序以灵活的顺序循环、重试或调用工具,直到任务完成。它显式地管理应用程序状态,该状态在节点之间传递并在整个过程中更新。

Use it for: 用途:

● Multi-agent Systems: A supervisor agent routes tasks to specialized worker agents, potentially looping until the goal is met.

多智能体系统:主管智能体将任务分配给专门的工作智能体,可能会循环执行,直到达到目标。

● Plan-and-Execute Agents: An agent creates a plan, executes a step, and then loops back to update the plan based on the result.

计划执行智能体:智能体创建计划,执行步骤,然后循环返回并根据结果更新计划。

● Human-in-the-Loop: The graph can wait for human input before deciding which node to go to next.

人机交互:该图可以等待人工输入,然后再决定下一步要访问哪个节点。

Feature LangChain LangGraph
Core Abstraction Chain (using LCEL) Graph of Nodes
Workflow Type Linear (Directed Acyclic Graph) Cyclical (Graphs with loops)
State Management Generally stateless per run Explicit and persistent state object
Primary Use Simple, predictable sequences Complex, dynamic, stateful agents

Which One Should You Use? 你应该使用哪一个?

● Choose LangChain when your application has a clear, predictable, and linear flow of steps. If you can define the process from A to B to C without needing to loop back, LangChain with LCEL is the perfect tool.

如果您的应用流程清晰、可预测且呈线性发展,那么LangChain是您的理想之选。如果您可以定义从A到B、再到C的完整流程而无需循环,那么LangChain与LCEL结合使用将是您的完美选择。

● Choose LangGraph when you need your application to reason, plan, or operate in a loop. If your agent needs to use tools, reflect on the results, and potentially try again with a different approach, you need the cyclical and stateful nature of LangGraph.

当您的应用程序需要进行推理、规划或循环操作时,请选择LangGraph。如果您的智能体需要使用工具、反思结果,并可能尝试不同的方法,那么您就需要LangGraph的循环性和有状态特性。

Python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Graph state
class State(TypedDict):
topic: str
joke: str
story: str
poem: str
combined_output: str

# Nodes
def call_llm_1(state: State):
"""First LLM call to generate initial joke"""

msg = llm.invoke(f"Write a joke about {state['topic']}")
return {"joke": msg.content}

def call_llm_2(state: State):
"""Second LLM call to generate story"""

msg = llm.invoke(f"Write a story about {state['topic']}")
return {"story": msg.content}

def call_llm_3(state: State):
"""Third LLM call to generate poem"""

msg = llm.invoke(f"Write a poem about {state['topic']}")
return {"poem": msg.content}

def aggregator(state: State):
"""Combine the joke and story into a single output"""

combined = f"Here's a story, joke, and poem about {state['topic']}!\n\n"
combined += f"STORY:\n{state['story']}\n\n"
combined += f"JOKE:\n{state['joke']}\n\n"
combined += f"POEM:\n{state['poem']}"
return {"combined_output": combined}

# Build workflow
parallel_builder = StateGraph(State)

# Add nodes
parallel_builder.add_node("call_llm_1", call_llm_1)
parallel_builder.add_node("call_llm_2", call_llm_2)
parallel_builder.add_node("call_llm_3", call_llm_3)
parallel_builder.add_node("aggregator", aggregator)

# Add edges to connect nodes
parallel_builder.add_edge(START, "call_llm_1")
parallel_builder.add_edge(START, "call_llm_2")
parallel_builder.add_edge(START, "call_llm_3")
parallel_builder.add_edge("call_llm_1", "aggregator")
parallel_builder.add_edge("call_llm_2", "aggregator")
parallel_builder.add_edge("call_llm_3", "aggregator")
parallel_builder.add_edge("aggregator", END)
parallel_workflow = parallel_builder.compile()

# Show workflow
display(Image(parallel_workflow.get_graph().draw_mermaid_png()))

# Invoke
state = parallel_workflow.invoke({"topic": "cats"})
print(state["combined_output"])

Google's ADK

Google's Agent Development Kit, or ADK, provides a high-level, structured framework for building and deploying applications composed of multiple, interacting AI agents. It contrasts with LangChain and LangGraph by offering a more opinionated and production-oriented system for orchestrating agent collaboration, rather than providing the fundamental building blocks for an agent's internal logic.

谷歌智能体开发工具包(ADK)提供了高级的结构化框架,用于构建和部署由多个交互AI智能体组成的应用程序。与LangChain和LangGraph不同,ADK提供了更具规范性和面向生产环境的系统来协调智能体之间的协作,而不是提供智能体内部逻辑的基本构建模块。

LangChain operates at the most foundational level, offering the components and standardized interfaces to create sequences of operations, such as calling a model and parsing its output. LangGraph extends this by introducing a more flexible and powerful control flow; it treats an agent's workflow as a stateful graph. Using LangGraph, a developer explicitly defines nodes, which are functions or tools, and edges, which dictate the path of execution. This graph structure allows for complex, cyclical reasoning where the system can loop, retry tasks, and make decisions based on an explicitly managed state object that is passed between nodes. It gives the developer fine-grained control over a single agent's thought process or the ability to construct a multi-agent system from first principles.

LangChain在最基础的层面上运行,提供创建操作序列所需的组件和标准化接口,例如调用模型并解析其输出。LangGraph在此基础上扩展了功能,引入了更灵活、更强大的控制流;它将智能体的工作流程视为有状态图。使用LangGraph,开发者可以显式地定义节点(即函数或工具)和边(即执行路径)。这种图结构支持复杂的循环推理,系统可以循环执行、重试任务,并基于在节点之间传递的显式管理的状态对象做出决策。它使开发者能够对单个智能体的思维过程进行细粒度控制,或者从零开始构建多智能体系统。

Google's ADK abstracts away much of this low-level graph construction. Instead of asking the developer to define every node and edge, it provides pre-built architectural patterns for multi-agent interaction. For instance, ADK has built-in agent types like SequentialAgent or ParallelAgent, which manage the flow of control between different agents automatically. It is architected around the concept of a "team" of agents, often with a primary agent delegating tasks to specialized sub-agents. State and session management are handled more implicitly by the framework, providing a more cohesive but less granular approach than LangGraph's explicit state passing. Therefore, while LangGraph gives you the detailed tools to design the intricate wiring of a single robot or a team, Google's ADK gives you a factory assembly line designed to build and manage a fleet of robots that already know how to work together.

Google ADK抽象化了许多底层图构建工作。它无需开发者定义每个节点和边,而是提供了预构建的多智能体交互架构模式。例如,ADK内置了SequentialAgent或ParallelAgent等智能体类型,可以自动管理不同智能体之间的控制流。它的架构围绕着智能体“团队”的概念展开,通常由一个主智能体将任务委派给专门的子智能体。框架以更隐式的方式处理状态和会话管理,提供了一种比LangGraph的显式状态传递更统一但粒度更低的方法。因此,LangGraph提供了设计单个机器人或团队复杂线路的详细工具,而Google ADK 则提供了一条工厂装配线,用于构建和管理一支已经知道如何协同工作的机器人集群。

Python

1
2
3
4
5
6
7
8
9
10
from google.adk.agents import LlmAgent
from google.adk.tools import google_Search

dice_agent = LlmAgent(
model="gemini-2.0-flash-exp",
name="question_answer_agent",
description="A helpful assistant agent that can answer questions.",
instruction="""Respond to the query using google search""",
tools=[google_search],
)
This code creates a search-augmented agent. When this agent receives a question, it will not just rely on its pre-existing knowledge. Instead, following its instructions, it will use the Google Search tool to find relevant, real-time information from the web and then use that information to construct its answer.

这段代码创建了搜索增强型智能体。当该智能体接收到问题时,它不会仅仅依赖其已有的知识。相反,它会按照指令,使用谷歌搜索工具从网络上查找相关的实时信息,然后利用这些信息构建答案。

Crew.AI

CrewAI offers an orchestration framework for building multi-agent systems by focusing on collaborative roles and structured processes. It operates at a higher level of abstraction than foundational toolkits, providing a conceptual model that mirrors a human team. Instead of defining the granular flow of logic as a graph, the developer defines the actors and their assignments, and CrewAI manages their interaction.

CrewAI 提供了编排框架用于构建多智能体系统,其核心在于协作角色和结构化流程。与基础工具包相比,CrewAI 的抽象层次更高,提供了一个类似于人类团队的概念模型。开发者无需将细粒度的逻辑流程定义为图,只需定义参与者及其任务,CrewAI便会负责管理它们之间的交互。

The core components of this framework are Agents, Tasks, and the Crew. An Agent is defined not just by its function but by a persona, including a specific role, a goal, and a backstory, which guides its behavior and communication style. A Task is a discrete unit of work with a clear description and expected output, assigned to a specific Agent. The Crew is the cohesive unit that contains the Agents and the list of Tasks, and it executes a predefined Process. This process dictates the workflow, which is typically either sequential, where the output of one task becomes the input for the next in line, or hierarchical, where a manager-like agent delegates tasks and coordinates the workflow among other agents.

该框架的核心组成部分包括智能体(Agent)、任务(Task)和团队(Crew)。智能体的定义不仅取决于其功能,还取决于其角色,包括具体角色、目标和背景故事,这些因素共同指导其行为和沟通方式。任务是一个独立的工作单元,具有清晰的描述和预期输出,并分配给特定的智能体。团队是一个包含所有智能体和任务列表的凝聚单元,它执行预定义的流程。该流程决定了工作流程,通常分为顺序式和层级式两种。顺序式工作流程中,一个任务的输出成为下一个任务的输入;层级式工作流程中,一个类似经理的智能体负责分配任务并协调其他智能体之间的工作流程。

When compared to other frameworks, CrewAI occupies a distinct position. It moves away from the low-level, explicit state management and control flow of LangGraph, where a developer wires together every node and conditional edge. Instead of building a state machine, the developer designs a team charter. While Googlés ADK provides a comprehensive, production-oriented platform for the entire agent lifecycle, CrewAI concentrates specifically on the logic of agent collaboration and for simulating a team of specialists.

与其他框架相比,CrewAI占据着独特的地位。它摒弃了LangGraph那种底层、显式的状态管理和控制流;在LangGraph中,开发者需要将每个节点和条件边连接起来。CrewAI的开发者无需构建状态机,而是设计团队章程。虽然Google ADK 为整个智能体生命周期提供了一个全面、面向生产的平台,但CrewAI则专注于智能体协作逻辑以及专家团队的模拟。

Python

1
2
3
4
5
6
7
8
9
@crew
def crew(self) -> Crew:
"""Creates the research crew"""
return Crew(
agents=self.agents,
tasks=self.tasks,
process=Process.sequential,
verbose=True,
)

This code sets up a sequential workflow for a team of AI agents, where they tackle a list of tasks in a specific order, with detailed logging enabled to monitor their progress.

这段代码为一组AI智能体设置了顺序工作流程,它们按特定顺序处理一系列任务,并启用了详细的日志记录来监控它们的进度。

Other agent development framework | 其他智能体开发框架

Microsoft AutoGen: AutoGen is a framework centered on orchestrating multiple agents that solve tasks through conversation. Its architecture enables agents with distinct capabilities to interact, allowing for complex problem decomposition and collaborative resolution. The primary advantage of AutoGen is its flexible, conversation-driven approach that supports dynamic and complex multi-agent interactions. However, this conversational paradigm can lead to less predictable execution paths and may require sophisticated prompt engineering to ensure tasks converge efficiently.

Microsoft AutoGen:AutoGen是以协调多个智能体通过对话解决任务为核心的框架。其架构允许具有不同能力的智能体进行交互,从而实现复杂问题的分解和协作解决。AutoGen的主要优势在于其灵活的、对话驱动的方法,支持动态且复杂的多智能体交互。然而,这种对话模式可能会导致执行路径难以预测,并且可能需要复杂的提示工程来确保任务高效收敛。

LlamaIndex: LlamaIndex is fundamentally a data framework designed to connect large language models with external and private data sources. It excels at creating sophisticated data ingestion and retrieval pipelines, which are essential for building knowledgeable agents that can perform RAG. While its data indexing and querying capabilities are exceptionally powerful for creating context-aware agents, its native tools for complex agentic control flow and multi-agent orchestration are less developed compared to agent-first frameworks. LlamaIndex is optimal when the core technical challenge is data retrieval and synthesis.

LlamaIndex:LlamaIndex本质上是一个旨在连接大型语言模型与外部和私有数据源的数据框架。它擅长构建复杂的数据摄取和检索管道,这对于构建能够执行RAG(红、红、绿)任务的知识型智能体至关重要。虽然其数据索引和查询功能对于创建上下文感知智能体来说非常强大,但与以智能体为先导的框架相比,其用于复杂智能体控制流和多智能体编排的原生工具尚不完善。当核心技术挑战在于数据检索和合成时,LlamaIndex是最佳选择。

Haystack: Haystack is an open-source framework engineered for building scalable and production-ready search systems powered by language models. Its architecture is composed of modular, interoperable nodes that form pipelines for document retrieval, question answering, and summarization. The main strength of Haystack is its focus on performance and scalability for large-scale information retrieval tasks, making it suitable for enterprise-grade applications. A potential trade-off is that its design, optimized for search pipelines, can be more rigid for implementing highly dynamic and creative agentic behaviors.

Haystack:Haystack是专为构建可扩展且可用于生产环境的、基于语言模型的搜索系统而设计的开源框架。其架构由模块化、可互操作的节点组成,这些节点构成文档检索、问答和摘要的管道。Haystack的主要优势在于其专注于大规模信息检索任务的性能和可扩展性,使其适用于企业级应用。但其潜在的不足之处在于,其针对搜索管道优化的设计可能较为僵化,难以实现高度动态和创造性的智能体行为。

MetaGPT: MetaGPT implements a multi-agent system by assigning roles and tasks based on a predefined set of Standard Operating Procedures (SOPs). This framework structures agent collaboration to mimic a software development company, with agents taking on roles like product managers or engineers to complete complex tasks. This SOP-driven approach results in highly structured and coherent outputs, which is a significant advantage for specialized domains like code generation. The framework's primary limitation is its high degree of specialization, making it less adaptable for general-purpose agentic tasks outside of its core design.

MetaGPT:MetaGPT通过基于预定义标准操作程序 (SOP) 分配角色和任务来实现多智能体系统。该框架构建智能体协作机制,模拟软件开发公司,智能体扮演产品经理或工程师等角色来完成复杂任务。这种基于SOP的方法能够生成高度结构化且连贯的输出,这对于代码生成等专业领域而言是一项显著优势。该框架的主要局限在于其高度专业化,使其难以适应核心设计之外的通用智能体任务。

SuperAGI: SuperAGI is an open-source framework designed to provide a complete lifecycle management system for autonomous agents. It includes features for agent provisioning, monitoring, and a graphical interface, aiming to enhance the reliability of agent execution. The key benefit is its focus on production-readiness, with built-in mechanisms to handle common failure modes like looping and to provide observability into agent performance. A potential drawback is that its comprehensive platform approach can introduce more complexity and overhead than a more lightweight, library-based framework.

SuperAGI:SuperAGI是开源框架,旨在为自主智能体提供完整的生命周期管理系统。它包含智能体配置、监控和图形界面等功能,旨在提高智能体执行的可靠性。其主要优势在于专注于生产就绪性,内置机制可以处理常见的故障模式(例如循环),并提供智能体性能的可观测性。潜在的缺点是,与更轻量级的基于库的框架相比,其全面的平台方法可能会引入更多的复杂性和开销。

Semantic Kernel: Developed by Microsoft, Semantic Kernel is an SDK that integrates large language models with conventional programming code through a system of "plugins" and "planners." It allows an LLM to invoke native functions and orchestrate workflows, effectively treating the model as a reasoning engine within a larger software application. Its primary strength is its seamless integration with existing enterprise codebases, particularly in .NET and Python environments. The conceptual overhead of its plugin and planner architecture can present a steeper learning curve compared to more straightforward agent frameworks.

Semantic Kernel:由微软开发的语义内核是软件开发工具包 (SDK),它通过“插件”和“规划器”系统将大型语言模型与传统编程代码集成。它允许大型语言模型调用原生函数并协调工作流,从而有效地将模型视为大型软件应用程序中的推理引擎。其主要优势在于能够与现有企业代码库无缝集成,尤其是在 .NET 和 Python 环境中。与更直接的智能体框架相比,其插件和规划器架构的概念性开销可能导致更陡峭的学习曲线。

Strands Agents: An AWS lightweight and flexible SDK that uses a model-driven approach for building and running AI agents. It is designed to be simple and scalable, supporting everything from basic conversational assistants to complex multi-agent autonomous systems. The framework is model-agnostic, offering broad support for various LLM providers, and includes native integration with the MCP for easy access to external tools. Its core advantage is its simplicity and flexibility, with a customizable agent loop that is easy to get started with. A potential trade-off is that its lightweight design means developers may need to build out more of the surrounding operational infrastructure, such as advanced monitoring or lifecycle management systems, which more comprehensive frameworks might provide out-of-the-box.

Strands Agents:一款轻量级且灵活的 AWS SDK,采用模型驱动方法构建和运行 AI 智能体。它设计简洁且可扩展,支持从基础对话助手到复杂的多智能体自主系统等各种应用。该框架与模型无关,广泛支持各种大语言模型 (LLM) 提供商,并与 MCP 原生集成,方便访问外部工具。其核心优势在于简洁性和灵活性,可自定义的智能体循环易于上手。潜在的不足之处在于,其轻量级设计意味着开发人员可能需要构建更多周边运维基础设施,例如高级监控或生命周期管理系统,而更全面的框架可能提供这些开箱即用的功能。

Conclusion | 结语

The landscape of agentic frameworks offers a diverse spectrum of tools, from low-level libraries for defining agent logic to high-level platforms for orchestrating multi-agent collaboration. At the foundational level, LangChain enables simple, linear workflows, while LangGraph introduces stateful, cyclical graphs for more complex reasoning. Higher-level frameworks like CrewAI and Google's ADK shift the focus to orchestrating teams of agents with predefined roles, while others like LlamaIndex specialize in data-intensive applications. This variety presents developers with a core trade-off between the granular control of graph-based systems and the streamlined development of more opinionated platforms. Consequently, selecting the right framework hinges on whether the application requires a simple sequence, a dynamic reasoning loop, or a managed team of specialists. Ultimately, this evolving ecosystem empowers developers to build increasingly sophisticated AI systems by choosing the precise level of abstraction their project demands.

智能体框架领域提供了种类繁多的工具,从用于定义智能体逻辑的底层库到用于协调多智能体协作的高级平台,应有尽有。在基础层面,LangChain支持简单的线性工作流,而LangGraph则引入了有状态的循环图,用于更复杂的推理。像CrewAI和Google ADK高级框架则专注于协调具有预定义角色的智能体团队,而像LlamaIndex这样的框架则专注于数据密集型应用。这种多样性给开发者带来了一个核心的权衡:一方面是基于图的系统进行精细控制,另一方面是更规范的平台带来的简化开发体验。因此,选择合适的框架取决于应用程序需要的是简单的序列、动态的推理循环,还是一个由专家组成的团队。最终,这个不断发展的生态系统使开发者能够通过选择项目所需的精确抽象级别,构建日益复杂的AI系统。

References | 参考文献

  1. LangChain, https://www.langchain.com/
  2. LangGraph, https://www.langchain.com/langgraph
  3. Google's ADK, https://google.github.io/adk-docs/
  4. Crew.AI, https://docs.crewai.com/en/introduction
0%