맞춤형 도구와 쿼리 통합하기
이제 지붕 길이를 계산하는 맞춤형 수학 도구가 준비되어 있습니다. 사용자 자연어 질문을 문자열로 받는 query 변수를 만들어 에이전틱 워크플로에 통합해 보세요. 도구는 이미 hypotenuse_length로, 그리고 model도 로드되어 있습니다.
이 연습은 강의의 일부입니다
LangChain으로 에이전트형 시스템 설계하기
연습 안내
tools라는 리스트 변수를 만들고 그 안에 도구hypotenuse_length를 포함하세요.- 자연어 문자열로 질문을 받는
query변수를 만드세요. create_react_agent()함수를 사용해 에이전트를 생성하고,model과tools를 전달하세요.- 에이전트
app을 호출할 때"human"으로 라벨링한query를 전달한 뒤, 에이전트의response를 저장하고 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create a list variable and pass in your tool
____ = [____]
# Create a query using natural language
____ = "What is the hypotenuse length of a triangle with side lengths of 10 and 12?"
# Pass in the hypotenuse length tool and create the agent
app = ____(____, ____)
# Invoke the agent and print the response
response = ____.____({"messages": [("____", ____)]})
print(____['messages'][-1].content)