LangGraph Supervisor: 감독 지능을 사용하여 다중 지능 협업을 관리하기 위한 도구

최신 AI 리소스6개월 전 업데이트 AI 공유 서클
2K 00

일반 소개

LangGraph Supervisor는 다중 지능형 바디 시스템을 생성하고 관리하기 위해 설계된 LangGraph 프레임워크에 기반한 Python 라이브러리입니다. 이 라이브러리는 중앙 감독 에이전트를 통해 여러 전문 에이전트의 작업을 조정하여 통신 흐름과 작업 할당을 효율적으로 관리하며, 라우터 및 코디네이터 모드를 모두 지원하고 계측화된 에이전트 핸드오버 메커니즘과 유연한 메시지 이력 관리를 제공하며 스트리밍 처리, 단기 및 장기 메모리, 휴먼 인 더 루프 분야의 애플리케이션 시나리오에 적합합니다.

LangGraph Supervisor:利用监督智能体来管理多智能体协作的工具

 

기능 목록

  • 여러 전문 상담원을 조정할 수 있는 감독 상담원 만들기
  • 라우터 및 코디네이터 모드 지원
  • 도구화된 프록시 핸드오버 메커니즘
  • 유연한 메시지 기록 관리
  • 스트리밍 처리, 단기 및 장기 메모리 지원
  • 휴먼 인 더 루프 애플리케이션 시나리오 지원

 

도움말 사용

설치 프로세스

  1. Python 환경이 설치되어 있는지 확인합니다.
  2. pip를 사용하여 LangGraph Supervisor 라이브러리를 설치합니다:
   pip install langgraph-supervisor
  1. LangChain 및 OpenAI 라이브러리를 설치합니다:
   pip install langchain-openai
  1. OpenAI API 키를 설정합니다:
   export OPENAI_API_KEY=<your_api_key>

사용 예

다음은 LangGraph 슈퍼바이저를 사용하여 두 명의 전문 상담원을 관리하는 방법을 보여주는 간단한 예시입니다:

  1. 필요한 라이브러리 및 모듈을 가져옵니다:
   from langchain_openai import ChatOpenAI
from langgraph_supervisor import create_supervisor
from langgraph.prebuilt import create_react_agent
  1. 전문 상담원을 만듭니다:
   def add(a: float, b: float) -> float:
"""Add two numbers."""
return a + b
def multiply(a: float, b: float) -> float:
"""Multiply two numbers."""
return a * b
def web_search(query: str) -> str:
"""Search the web for information."""
return "Here are the headcounts for each of the FAANG companies in 2024:..."
model = ChatOpenAI(model="gpt-4o")
math_agent = create_react_agent(model=model, tools=[add, multiply], name="math_expert", prompt="You are a math expert. Always use one tool at a time.")
research_agent = create_react_agent(model=model, tools=[web_search], name="research_expert", prompt="You are a world class researcher with access to web search. Do not do any math.")
  1. 감독 에이전트를 만들고 컴파일하여 실행합니다:
   workflow = create_supervisor([research_agent, math_agent], model=model, prompt="You are a team supervisor managing a research expert and a math expert.")
app = workflow.compile()
result = app.invoke({
"messages": [
{"role": "user", "content": "what's the combined headcount of the FAANG companies in 2024?"}
]
})

세부 기능 작동 흐름

  1. 감독 에이전트 만들기통해create_supervisor함수는 여러 전문 에이전트의 작업을 조정할 책임이 있는 감독 에이전트를 만듭니다.
  2. 전문 에이전트 정의사용create_react_agent함수는 수학 컴퓨팅 에이전트, 웹 검색 에이전트 등 다양한 기능에 특화된 에이전트를 정의합니다.
  3. 워크플로 컴파일 및 실행통해workflow.compile()워크플로우를 컴파일하고app.invoke()사용자 입력을 처리하고 결과를 반환하는 워크플로를 실행합니다.

랭그래프 슈퍼바이저는 다양하고 복잡한 작업을 자동화하고 조정할 수 있는 유연한 멀티 인텔리전스 시스템 관리 솔루션을 제공합니다.

© 저작권 정책

관련 문서

댓글 없음

댓글에 참여하려면 로그인해야 합니다!
지금 로그인
없음
댓글 없음...