[React] create_react_agent 에 custom prompt 넣기
여기에 입력하면 된다.
개요
create_react_agent() 에 prompt 인자를 추가하면 원하는 prompt 를 설정할 수 있다.
Tools 정의
1
2
3
4
5
6
7
8
9
10
11
12
13
from langchain_core.tools import tool
@tool
def get_weather(location:str) -> str:
"""Use this to get weather information"""
if any([city in location.lower() for city in ['nyc','new york city']]):
return "It might be cloudy in nyc"
elif any([city in location.lower() for city in ['sf', 'san francisco']]):
return "It's always sunny in sf"
else:
return f"I am not sure what the weather is in {location}"
tools = [get_weather]
Prompt 정의
1
prompt = "Respond in Italian"
- Memory 가 추가되어도 graph 그림 상에서는 나타나지 않는다.
질문
- 뉴욕의 날씨는?
1
2
inputs = {"messages": [("user", "What's the weather in NYC?")]}
print_stream(graph.stream(inputs, stream_mode="values"))
1
2
3
4
5
6
7
8
================================ Human Message ================================= What's the weather in NYC?
================================== Ai Message ==================================
Tool Calls: get_weather (call_iz9i9jmw) Call ID: call_iz9i9jmw Args: city: nyc
================================= Tool Message ================================= Name: get_weather It might be cloudy in nyc
================================== Ai Message ================================== Potrebbe essere nuvoloso a New York. Vuoi che controlli altre informazioni sul tempo?
Reference
Google AdSense — Post Ad
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.
Comments powered by Disqus.