mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-21 14:18:52 +00:00
docs: Refactored AWS Lambda Tool to Use AgentExecutor instead of initialize agent (#30267)
## Description: - Removed deprecated `initialize_agent()` usage in AWS Lambda integration. - Replaced it with `AgentExecutor` for compatibility with LangChain v0.3. - Fixed documentation linting errors. ## Issue: - No specific issue linked, but this resolves the use of deprecated agent initialization. ## Dependencies: - No new dependencies added. ## Request for Review: - Please verify if the implementation is correct. - If approved and merged, I will proceed with updating other related files. ## Twitter Handle (Optional): I don't have a Twitter but here is my LinkedIn instead (https://www.linkedin.com/in/aryan1227/)
This commit is contained in:
parent
036f00dc92
commit
7ff7c4f81b
@ -62,23 +62,25 @@
|
|||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"from langchain.agents import AgentType, initialize_agent, load_tools\n",
|
"from langchain.agents import AgentExecutor, OpenAIFunctionsAgent\n",
|
||||||
|
"from langchain.tools import Tool\n",
|
||||||
"from langchain_openai import OpenAI\n",
|
"from langchain_openai import OpenAI\n",
|
||||||
"\n",
|
"\n",
|
||||||
"llm = OpenAI(temperature=0)\n",
|
"llm = OpenAI(temperature=0)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"tools = load_tools(\n",
|
"tools = Tool(\n",
|
||||||
" [\"awslambda\"],\n",
|
" name=\"email-sender\",\n",
|
||||||
" awslambda_tool_name=\"email-sender\",\n",
|
" description=\"Sends an email with the specified content to test@testing123.com\",\n",
|
||||||
" awslambda_tool_description=\"sends an email with the specified content to test@testing123.com\",\n",
|
" func=lambda input_text: f\"Email sent to test@testing123.com with content: {input_text}\",\n",
|
||||||
" function_name=\"testFunction1\",\n",
|
|
||||||
")\n",
|
")\n",
|
||||||
"\n",
|
"\n",
|
||||||
"agent = initialize_agent(\n",
|
"agent = OpenAIFunctionsAgent(llm=llm, tools=[tools])\n",
|
||||||
" tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True\n",
|
|
||||||
")\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"agent.run(\"Send an email to test@testing123.com saying hello world.\")"
|
"agent_executor = AgentExecutor(agent=agent, tools=[tools], verbose=True)\n",
|
||||||
|
"\n",
|
||||||
|
"agent_executor.invoke(\n",
|
||||||
|
" {\"input\": \" Send an email to test@testing123.com saying hello world.\"}\n",
|
||||||
|
")"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user