Docs: Fix deprecated initialize agent in ainetwork (#30355)

## Description
- Replaced `initialize_agent`, `AgentType` usage in ainetwork
integration
- Updated usage example to `create_react_agent` in langgraph

## Issue
- #29277

## Dependencies
- N/A

## Twitter handler
- I don't use Twitter
This commit is contained in:
Yeonseolee 2025-03-20 04:20:21 +09:00 committed by GitHub
parent 73c04f4707
commit 65b16d3200
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -130,16 +130,11 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from langchain.agents import AgentType, initialize_agent\n",
"from langchain_openai import ChatOpenAI\n", "from langchain_openai import ChatOpenAI\n",
"from langgraph.prebuilt import create_react_agent\n",
"\n", "\n",
"llm = ChatOpenAI(temperature=0)\n", "llm = ChatOpenAI(temperature=0)\n",
"agent = initialize_agent(\n", "agent = create_react_agent(model=llm, tools=tools)"
" tools=tools,\n",
" llm=llm,\n",
" verbose=True,\n",
" agent=AgentType.OPENAI_FUNCTIONS,\n",
")"
] ]
}, },
{ {
@ -199,8 +194,10 @@
], ],
"source": [ "source": [
"print(\n", "print(\n",
" agent.run(\n", " agent.invoke(\n",
" f\"Create an app in the AINetwork Blockchain database with the name {appName}\"\n", " {\n",
" \"messages\": f\"Create an app in the AINetwork Blockchain database with the name {appName}\"\n",
" }\n",
" )\n", " )\n",
")" ")"
] ]