mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
53 KiB
53 KiB
In [1]:
from langchain_openai import ChatOpenAI
from langchain_community.tools.tavily_search import TavilySearchResults
from langgraph.prebuilt import chat_agent_executor
from langchain_core.messages import HumanMessageIn [2]:
tools = [TavilySearchResults(max_results=1)]
model = ChatOpenAI()In [3]:
app = chat_agent_executor.create_function_calling_executor(model, tools)In [4]:
app.get_graph().print_ascii() +-----------+
| __start__ |
+-----------+
*
*
*
+-------+
| agent |
*+-------+*
** ***
** **
** **
+-----------------------+ **
| agent_should_continue | *
+-----------------------+ *
* ***** *
* **** *
* *** *
+---------+ +--------+
| __end__ | | action |
+---------+ +--------+
In [ ]:
# !pip install pygraphviz In [6]:
from IPython.display import ImageIn [7]:
Image(app.get_graph().draw_png())Out [7]:
In [ ]: