Post

Agent in LangChain

Agent in LangChain

Agent 的核心概念

PPA(Perception,Planning,Action)

区别 Agent 与常规 LLM 直观表现在:

  • Agent 面向任务,循环执行
  • LLM 面向问题,单词执行

Agent prompt format: ReAct

循环的 Prompt:CoT,目前主流使用的 Prompt 格式:ReAct

1
2
3
4
5
6
7
8
Input: Question
Step 1: Question -> Thought1 + Action1
Step 2: Action1 -> Observation 1
Step 3: Question + Thought1 + Action1 + Observation1 -> Thought 2 + Action 2
Step 4: Action 2 -> Observation 2
Step 5: Question + sum(Thoungt) + sum(Action) + sum(Observation) -> Next Thought + Next Action
...
Output

LangChain Agent

1
agent = llm | tools |prompt
This post is licensed under CC BY 4.0 by the author.