mirror of
https://github.com/hwchase17/langchain
synced 2024-10-31 15:20:26 +00:00
6116cbf0de
Minor doc fix to awslambda tool notebook. Add missing import for initialize_agent to awslambda agent example Co-authored-by: Josh Hart <josharj@amazon.com>
122 lines
3.4 KiB
Plaintext
122 lines
3.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# AWS Lambda API"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"This notebook goes over how to use the AWS Lambda Tool component.\n",
|
|
"\n",
|
|
"AWS Lambda is a serverless computing service provided by Amazon Web Services (AWS), designed to allow developers to build and run applications and services without the need for provisioning or managing servers. This serverless architecture enables you to focus on writing and deploying code, while AWS automatically takes care of scaling, patching, and managing the infrastructure required to run your applications.\n",
|
|
"\n",
|
|
"By including a `awslambda` in the list of tools provided to an Agent, you can grant your Agent the ability to invoke code running in your AWS Cloud for whatever purposes you need.\n",
|
|
"\n",
|
|
"When an Agent uses the awslambda tool, it will provide an argument of type string which will in turn be passed into the Lambda function via the event parameter.\n",
|
|
"\n",
|
|
"First, you need to install `boto3` python package."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"vscode": {
|
|
"languageId": "shellscript"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"!pip install boto3 > /dev/null"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"In order for an agent to use the tool, you must provide it with the name and description that match the functionality of you lambda function's logic. \n",
|
|
"\n",
|
|
"You must also provide the name of your function. "
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Note that because this tool is effectively just a wrapper around the boto3 library, you will need to run `aws configure` in order to make use of the tool. For more detail, see [here](https://docs.aws.amazon.com/cli/index.html)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"vscode": {
|
|
"languageId": "shellscript"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from langchain import OpenAI\n",
|
|
"from langchain.agents import load_tools, initialize_agent, AgentType\n",
|
|
"\n",
|
|
"llm = OpenAI(temperature=0)\n",
|
|
"\n",
|
|
"tools = load_tools(\n",
|
|
" [\"awslambda\"],\n",
|
|
" awslambda_tool_name=\"email-sender\",\n",
|
|
" awslambda_tool_description=\"sends an email with the specified content to test@testing123.com\",\n",
|
|
" function_name=\"testFunction1\",\n",
|
|
")\n",
|
|
"\n",
|
|
"agent = initialize_agent(\n",
|
|
" tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True\n",
|
|
")\n",
|
|
"\n",
|
|
"agent.run(\"Send an email to test@testing123.com saying hello world.\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"vscode": {
|
|
"languageId": "shellscript"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": ".venv",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.11.2"
|
|
},
|
|
"orig_nbformat": 4
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|