Skip to content

Module 11LangGraph �6y'� ��

�"�("0"}(" �� LangGraph �اfh�


,���

(Mb���- ��f� LangGraph ��@(��I����������\AF���c**��**� AI Agent �� ��������6y'

,�&`�e LangGraph �ا�w�

���������������������������������������������������������������������
                    Module 11 ��0�                                
���������������������������������������������������������������������$
                                                                      
   11.1 ��!          11.2 Mermaid ��                         
   ��������������      ��������������                            
    ��c��           �s�                                 
    �w(��         5 �8�!                             
   ������,�������      ������,�������                            
                                                                    
          ����������,����������                                     
                                                                     
                     �                                                
          ������������������                                        
            11.3 MCP �                                           
           ��ws�s(                                         
          ��������,���������                                        
                                                                     
          �������4�������                                          
          �               �                                          
   �������������� ��������������                                 
    11.4 -��    11.5 Command                                  
    �h+ѧ      ��^h                                    
   �������������� ��������������                                 
                                                                      
���������������������������������������������������������������������

:�H��ٛ�6y'

�@(��㳄��6y'�㳄�
�U��'A
B����/
K�@ �ws�s(���wMCP
�����h�8�װU,�6Middleware
>�I@ ���1z�SbCommand
�s�c�����Mermaid

�����

11.1 LangGraph ��!

**8��**:�H ���/"�Z" ���/"�pn"

`f:$�,( ���!

!�x�:o
��c��"MZ� ��Z"��\�9
�w(��":*P� ��� "API (RAG �"

��*:+ /��� LangGraph ���s.


11.2 ( Mermaid ���\A

**8��**H;� ���

Mermaid / LangGraph �"����",�� *5 �H� Y`( Mermaid �� Agent ��

  1. **�'A **A � B � C
  2. **a�/**if ... then ... else ...
  3. ��ӄwhile ... do ...
  4. vLgL� ��L
  5. **-.�**Supervisor !

�� Mermaid `1�(��KMH����Z


11.3 LangGraph  MCP �

**8���**� AI (���w

MCPModel Context Protocol / Anthropic ����>O� ��: AI L�"USB ��",���

  • MCP � �!STDIOSSEStreamable HTTP
  • **LangGraph ���**( langchain-mcp-adapters
  • MCP vs Skills�H�(�*
  • **�Y �**MCP �@P'L�

11.4 Middleware -��

8�Ի�`� AI Agent � "���"

-���`�( Agent gL���e�e�I;�

�P�:x�(
before_modelLLM (M���8CP��
after_modelLLM (��n�����
modify_model_request��BM��w�o�)

,����� 13+ ͅn-�� ΐ�ݤ0,�6 ���h


11.5 Command��^h

**8���**( �*�-��� + �6A 

� LangGraph - ��# �#�1Command S4��*LP

python
#  ߹�� + a��
def my_node(state):
    return {"result": "..."}

def route(state):
    if state["result"] == "A":
        return "node_a"
    return "node_b"

graph.add_conditional_edges("my_node", route)

# Command ��e0M
def my_node(state) -> Command[Literal["node_a", "node_b"]]:
    if should_go_a(state):
        return Command(update={"result": "..."}, goto="node_a")
    return Command(update={"result": "..."}, goto="node_b")

Command /��**z�SbHandoffs **�Supervisor !�8��w


f`���

��`/ LangGraph f
    � ��	z�f` 11.1 � 11.2 � 11.3 � 11.4 � 11.5

��`����z�S��
    � Hf` 11.5 Command � 11.1 ��!

��`s�����h
    � Hf` 11.4 Middleware � 11.3 MCP

��`��������
    � Hf` 11.2 Mermaid ��

,�f`�

�,�f �

  • [ ] :��c����w(�� �cn�!
  • [ ] ( Mermaid ����� LangGraph �\A
  • [ ] � MCP O� � Agent (��w
  • [ ] ( Middleware ���h�8,�6I*s�
  • [ ] ( Command �����z�Sb��

Mn��

,�G�`�ό�

  • LangGraph �@��I���a��
  • Python {���TypedDictLiteralAnnotated
  • e �@async/await�����

���ٛ�� �� ��H�~Mb���


=� �}� ��Ϊ�!�� �e LangGraph �اL

基于 MIT 许可证发布。内容版权归作者所有。