📖 docs: integrations/agent_toolkits (#9333)

Note: There are no changes in the file names!

- The group name on the main navbar changed: `Agent toolkits` -> `Agents
& Toolkits`. Examples here are the mix of the Agent and Toolkit examples
because Agents and Toolkits in examples are always used together.
- Titles changed: removed "Agent" and "Toolkit" suffixes. The reason is
the same.
- Formatting: mostly cleaning the header structure, so it could be
better on the right-side navbar.

Main navbar is looking much cleaner now.
This commit is contained in:
Leonid Ganeline 2023-08-23 23:17:47 -07:00 committed by GitHub
parent c19888c12c
commit b048236c1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 248 additions and 267 deletions

View File

@ -1,13 +1,12 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Amadeus Toolkit\n",
"# Amadeus\n",
"\n",
"This notebook walks you through connecting LangChain to the Amadeus travel information API\n",
"This notebook walks you through connecting LangChain to the `Amadeus` travel information API\n",
"\n",
"To use this toolkit, you will need to set up your credentials explained in the [Amadeus for developers getting started overview](https://developers.amadeus.com/get-started/get-started-with-self-service-apis-335). Once you've received a AMADEUS_CLIENT_ID and AMADEUS_CLIENT_SECRET, you can input them as environmental variables below."
]
@ -22,7 +21,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
@ -46,7 +44,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
@ -234,7 +231,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -4,9 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Azure Cognitive Services Toolkit\n",
"# Azure Cognitive Services\n",
"\n",
"This toolkit is used to interact with the Azure Cognitive Services API to achieve some multimodal capabilities.\n",
"This toolkit is used to interact with the `Azure Cognitive Services API` to achieve some multimodal capabilities.\n",
"\n",
"Currently There are four tools bundled in this toolkit:\n",
"- AzureCogsImageAnalysisTool: used to extract caption, objects, tags, and text from images. (Note: this tool is not available on Mac OS yet, due to the dependency on `azure-ai-vision` package, which is only supported on Windows and Linux currently.)\n",
@ -264,9 +264,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

View File

@ -5,24 +5,14 @@
"id": "7094e328",
"metadata": {},
"source": [
"# CSV Agent\n",
"# CSV\n",
"\n",
"This notebook shows how to use agents to interact with a csv. It is mostly optimized for question answering.\n",
"This notebook shows how to use agents to interact with data in `CSV` format. It is mostly optimized for question answering.\n",
"\n",
"**NOTE: this agent calls the Pandas DataFrame agent under the hood, which in turn calls the Python agent, which executes LLM generated Python code - this can be bad if the LLM generated Python code is harmful. Use cautiously.**\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "827982c7",
"metadata": {},
"outputs": [],
"source": [
"from langchain.agents import create_csv_agent"
]
},
{
"cell_type": "code",
"execution_count": 2,
@ -32,7 +22,9 @@
"source": [
"from langchain.llms import OpenAI\n",
"from langchain.chat_models import ChatOpenAI\n",
"from langchain.agents.agent_types import AgentType"
"from langchain.agents.agent_types import AgentType\n",
"\n",
"from langchain.agents import create_csv_agent"
]
},
{
@ -40,9 +32,9 @@
"id": "bd806175",
"metadata": {},
"source": [
"## Using ZERO_SHOT_REACT_DESCRIPTION\n",
"## Using `ZERO_SHOT_REACT_DESCRIPTION`\n",
"\n",
"This shows how to initialize the agent using the ZERO_SHOT_REACT_DESCRIPTION agent type. Note that this is an alternative to the above."
"This shows how to initialize the agent using the `ZERO_SHOT_REACT_DESCRIPTION` agent type. Note that this is an alternative to the above."
]
},
{
@ -130,9 +122,7 @@
"cell_type": "code",
"execution_count": 5,
"id": "a96309be",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"name": "stderr",
@ -305,7 +295,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.10.12"
}
},
"nbformat": 4,

File diff suppressed because one or more lines are too long

View File

@ -4,9 +4,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Github Toolkit\n",
"# Github\n",
"\n",
"The Github toolkit contains tools that enable an LLM agent to interact with a github repository. The tools are a wrapper for the [PyGitHub](https://github.com/PyGithub/PyGithub) library. \n",
"The `Github` toolkit contains tools that enable an LLM agent to interact with a github repository. \n",
"The tool is a wrapper for the [PyGitHub](https://github.com/PyGithub/PyGithub) library. \n",
"\n",
"## Quickstart\n",
"1. Install the pygithub library\n",
@ -38,7 +39,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Install the pygithub library"
"## Setup"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1. Install the `pygithub` library "
]
},
{
@ -58,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Create a Github App\n",
"### 2. Create a Github App\n",
"\n",
"[Follow the instructions here](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app) to create and register a Github app. Make sure your app has the following [repository permissions:](https://docs.github.com/en/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28)\n",
"* Commit statuses (read only)\n",
@ -71,7 +79,7 @@
"\n",
"Once the app has been registered, add it to the repository you wish the bot to act upon.\n",
"\n",
"## 3. Set Environmental Variables\n",
"### 3. Set Environmental Variables\n",
"\n",
"Before initializing your agent, the following environmental variables need to be set:\n",
"\n",
@ -86,7 +94,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example Usage- Simple Agent"
"## Example: Simple Agent"
]
},
{
@ -212,7 +220,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example Usage- Advanced Agent\n",
"## Example: Advanced Agent\n",
"\n",
"If your agent does not need to use all 8 tools, you can build tools individually to use. For this example, we'll make an agent that does not use the create_file, delete_file or create_pull_request tools, but can also use duckduckgo-search."
]
@ -375,9 +383,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.16"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

View File

@ -4,9 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Gmail Toolkit\n",
"# Gmail\n",
"\n",
"This notebook walks through connecting a LangChain email to the Gmail API.\n",
"This notebook walks through connecting a LangChain email to the `Gmail API`.\n",
"\n",
"To use this toolkit, you will need to set up your credentials explained in the [Gmail API docs](https://developers.google.com/gmail/api/quickstart/python#authorize_credentials_for_a_desktop_application). Once you've downloaded the `credentials.json` file, you can start using the Gmail API. Once this is done, we'll install the required libraries."
]
@ -226,7 +226,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -2,7 +2,10 @@
sidebar_position: 0
---
# Agent toolkits
# Agents & Toolkits
Agents and Toolkits are placed in the same directory because they are always used together.
import DocCardList from "@theme/DocCardList";

View File

@ -1,15 +1,15 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "245a954a",
"metadata": {},
"source": [
"# Jira\n",
"\n",
"This notebook goes over how to use the Jira tool.\n",
"The Jira tool allows agents to interact with a given Jira instance, performing actions such as searching for issues and creating issues, the tool wraps the atlassian-python-api library, for more see: https://atlassian-python-api.readthedocs.io/jira.html\n",
"This notebook goes over how to use the `Jira` toolkit.\n",
"\n",
"The `Jira` toolkit allows agents to interact with a given Jira instance, performing actions such as searching for issues and creating issues, the tool wraps the atlassian-python-api library, for more see: https://atlassian-python-api.readthedocs.io/jira.html\n",
"\n",
"To use this tool, you must first set as environment variables:\n",
" JIRA_API_TOKEN\n",
@ -22,12 +22,12 @@
"execution_count": null,
"id": "961b3689",
"metadata": {
"ExecuteTime": {
"end_time": "2023-04-17T10:21:20.168639Z",
"start_time": "2023-04-17T10:21:18.698672Z"
},
"vscode": {
"languageId": "shellscript"
},
"ExecuteTime": {
"start_time": "2023-04-17T10:21:18.698672Z",
"end_time": "2023-04-17T10:21:20.168639Z"
}
},
"outputs": [],
@ -41,8 +41,8 @@
"id": "34bb5968",
"metadata": {
"ExecuteTime": {
"start_time": "2023-04-17T10:21:22.911233Z",
"end_time": "2023-04-17T10:21:23.730922Z"
"end_time": "2023-04-17T10:21:23.730922Z",
"start_time": "2023-04-17T10:21:22.911233Z"
}
},
"outputs": [],
@ -58,21 +58,24 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "b3050b55",
"metadata": {
"ExecuteTime": {
"end_time": "2023-04-17T10:22:42.505412Z",
"start_time": "2023-04-17T10:22:42.499447Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"os.environ[\"JIRA_API_TOKEN\"] = \"abc\"\n",
"os.environ[\"JIRA_USERNAME\"] = \"123\"\n",
"os.environ[\"JIRA_INSTANCE_URL\"] = \"https://jira.atlassian.com\"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"xyz\""
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2023-04-17T10:22:42.499447Z",
"end_time": "2023-04-17T10:22:42.505412Z"
}
},
"id": "b3050b55"
]
},
{
"cell_type": "code",
@ -80,8 +83,8 @@
"id": "ac4910f8",
"metadata": {
"ExecuteTime": {
"start_time": "2023-04-17T10:22:44.664481Z",
"end_time": "2023-04-17T10:22:44.720538Z"
"end_time": "2023-04-17T10:22:44.720538Z",
"start_time": "2023-04-17T10:22:44.664481Z"
}
},
"outputs": [],
@ -97,6 +100,17 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "d5461370",
"metadata": {
"ExecuteTime": {
"end_time": "2023-04-17T10:23:38.121883Z",
"start_time": "2023-04-17T10:23:33.662454Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"name": "stdout",
@ -117,7 +131,9 @@
},
{
"data": {
"text/plain": "'A new issue has been created in project PW with the summary \"Make more fried rice\" and description \"Reminder to make more fried rice\".'"
"text/plain": [
"'A new issue has been created in project PW with the summary \"Make more fried rice\" and description \"Reminder to make more fried rice\".'"
]
},
"execution_count": 9,
"metadata": {},
@ -126,20 +142,12 @@
],
"source": [
"agent.run(\"make a new issue in project PW to remind me to make more fried rice\")"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2023-04-17T10:23:33.662454Z",
"end_time": "2023-04-17T10:23:38.121883Z"
}
},
"id": "d5461370"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@ -153,7 +161,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.10.12"
},
"vscode": {
"interpreter": {
@ -163,4 +171,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}

View File

@ -5,9 +5,10 @@
"id": "85fb2c03-ab88-4c8c-97e3-a7f2954555ab",
"metadata": {},
"source": [
"# JSON Agent\n",
"# JSON\n",
"\n",
"This notebook showcases an agent designed to interact with large JSON/dict objects. This is useful when you want to answer questions about a JSON blob that's too large to fit in the context window of an LLM. The agent is able to iteratively explore the blob to find what it needs to answer the user's question.\n",
"This notebook showcases an agent interacting with large `JSON/dict` objects. \n",
"This is useful when you want to answer questions about a JSON blob that's too large to fit in the context window of an LLM. The agent is able to iteratively explore the blob to find what it needs to answer the user's question.\n",
"\n",
"In the below example, we are using the OpenAPI spec for the OpenAI API, which you can find [here](https://github.com/openai/openai-openapi/blob/master/openapi.yaml).\n",
"\n",
@ -179,7 +180,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -1,15 +1,14 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# MultiOn Toolkit\n",
"# MultiOn\n",
"\n",
"This notebook walks you through connecting LangChain to the MultiOn Client in your browser\n",
"This notebook walks you through connecting LangChain to the `MultiOn` Client in your browser\n",
"\n",
"To use this toolkit, you will need to add MultiOn Extension to your browser as explained in the [MultiOn for Chrome](https://multion.notion.site/Download-MultiOn-ddddcfe719f94ab182107ca2612c07a5)."
"To use this toolkit, you will need to add `MultiOn Extension` to your browser as explained in the [MultiOn for Chrome](https://multion.notion.site/Download-MultiOn-ddddcfe719f94ab182107ca2612c07a5)."
]
},
{
@ -47,7 +46,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
@ -127,7 +125,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -1,13 +1,12 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Office365 Toolkit\n",
"# Office365\n",
"\n",
"This notebook walks through connecting LangChain to Office365 email and calendar.\n",
"This notebook walks through connecting LangChain to `Office365` email and calendar.\n",
"\n",
"To use this toolkit, you will need to set up your credentials explained in the [Microsoft Graph authentication and authorization overview](https://learn.microsoft.com/en-us/graph/auth/). Once you've received a CLIENT_ID and CLIENT_SECRET, you can input them as environmental variables below."
]
@ -23,7 +22,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
@ -42,7 +40,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
@ -238,7 +235,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -5,9 +5,9 @@
"id": "85fb2c03-ab88-4c8c-97e3-a7f2954555ab",
"metadata": {},
"source": [
"# OpenAPI agents\n",
"# OpenAPI\n",
"\n",
"We can construct agents to consume arbitrary APIs, here APIs conformant to the OpenAPI/Swagger specification."
"We can construct agents to consume arbitrary APIs, here APIs conformant to the `OpenAPI`/`Swagger` specification."
]
},
{
@ -271,9 +271,7 @@
"cell_type": "code",
"execution_count": 9,
"id": "38762cc0",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -449,9 +447,7 @@
"cell_type": "code",
"execution_count": 28,
"id": "3a9cc939",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -773,7 +769,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -7,7 +7,9 @@
"source": [
"# Natural Language APIs\n",
"\n",
"Natural Language API Toolkits (NLAToolkits) permit LangChain Agents to efficiently plan and combine calls across endpoints. This notebook demonstrates a sample composition of the Speak, Klarna, and Spoonacluar APIs.\n",
"`Natural Language API` Toolkits (`NLAToolkits`) permit LangChain Agents to efficiently plan and combine calls across endpoints. \n",
"\n",
"This notebook demonstrates a sample composition of the `Speak`, `Klarna`, and `Spoonacluar` APIs.\n",
"\n",
"For a detailed walkthrough of the OpenAPI chains wrapped within the NLAToolkit, see the [OpenAPI Operation Chain](/docs/use_cases/apis/openapi.html) notebook.\n",
"\n",
@ -182,7 +184,7 @@
"id": "c61d92a8",
"metadata": {},
"source": [
"### Using Auth + Adding more Endpoints\n",
"### Use Auth and add more Endpoints\n",
"\n",
"Some endpoints may require user authentication via things like access tokens. Here we show how to pass in the authentication information via the `Requests` wrapper object.\n",
"\n",
@ -420,7 +422,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -5,11 +5,11 @@
"id": "c81da886",
"metadata": {},
"source": [
"# Pandas Dataframe Agent\n",
"# Pandas Dataframe\n",
"\n",
"This notebook shows how to use agents to interact with a pandas dataframe. It is mostly optimized for question answering.\n",
"This notebook shows how to use agents to interact with a `Pandas DataFrame`. It is mostly optimized for question answering.\n",
"\n",
"**NOTE: this agent calls the Python agent under the hood, which executes LLM generated Python code - this can be bad if the LLM generated Python code is harmful. Use cautiously.**"
"**NOTE: this agent calls the `Python` agent under the hood, which executes LLM generated Python code - this can be bad if the LLM generated Python code is harmful. Use cautiously.**"
]
},
{
@ -42,9 +42,9 @@
"id": "a62858e2",
"metadata": {},
"source": [
"## Using ZERO_SHOT_REACT_DESCRIPTION\n",
"## Using `ZERO_SHOT_REACT_DESCRIPTION`\n",
"\n",
"This shows how to initialize the agent using the ZERO_SHOT_REACT_DESCRIPTION agent type. Note that this is an alternative to the above."
"This shows how to initialize the agent using the `ZERO_SHOT_REACT_DESCRIPTION` agent type. Note that this is an alternative to the above."
]
},
{
@ -212,7 +212,7 @@
"id": "c4bc0584",
"metadata": {},
"source": [
"### Multi DataFrame Example\n",
"## Multi DataFrame Example\n",
"\n",
"This next part shows how the agent can interact with multiple dataframes passed in as a list."
]
@ -292,7 +292,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -4,17 +4,19 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# PlayWright Browser Toolkit\n",
"# PlayWright Browser\n",
"\n",
"This toolkit is used to interact with the browser. While other tools (like the Requests tools) are fine for static sites, Browser toolkits let your agent navigate the web and interact with dynamically rendered sites. Some tools bundled within the Browser toolkit include:\n",
"This toolkit is used to interact with the browser. While other tools (like the `Requests` tools) are fine for static sites, `PlayWright Browser` toolkits let your agent navigate the web and interact with dynamically rendered sites. \n",
"\n",
"- NavigateTool (navigate_browser) - navigate to a URL\n",
"- NavigateBackTool (previous_page) - wait for an element to appear\n",
"- ClickTool (click_element) - click on an element (specified by selector)\n",
"- ExtractTextTool (extract_text) - use beautiful soup to extract text from the current web page\n",
"- ExtractHyperlinksTool (extract_hyperlinks) - use beautiful soup to extract hyperlinks from the current web page\n",
"- GetElementsTool (get_elements) - select elements by CSS selector\n",
"- CurrentPageTool (current_page) - get the current page URL\n"
"Some tools bundled within the `PlayWright Browser` toolkit include:\n",
"\n",
"- `NavigateTool` (navigate_browser) - navigate to a URL\n",
"- `NavigateBackTool` (previous_page) - wait for an element to appear\n",
"- `ClickTool` (click_element) - click on an element (specified by selector)\n",
"- `ExtractTextTool` (extract_text) - use beautiful soup to extract text from the current web page\n",
"- `ExtractHyperlinksTool` (extract_hyperlinks) - use beautiful soup to extract hyperlinks from the current web page\n",
"- `GetElementsTool` (get_elements) - select elements by CSS selector\n",
"- `CurrentPageTool` (current_page) - get the current page URL\n"
]
},
{
@ -327,7 +329,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -2,36 +2,40 @@
"cells": [
{
"cell_type": "markdown",
"id": "9363398d",
"metadata": {},
"source": [
"# PowerBI Dataset Agent\n",
"# PowerBI Dataset\n",
"\n",
"This notebook showcases an agent designed to interact with a Power BI Dataset. The agent is designed to answer more general questions about a dataset, as well as recover from errors.\n",
"This notebook showcases an agent interacting with a `Power BI Dataset`. The agent is answering more general questions about a dataset, as well as recover from errors.\n",
"\n",
"Note that, as this agent is in active development, all answers might not be correct. It runs against the [executequery endpoint](https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/execute-queries), which does not allow deletes.\n",
"\n",
"### Some notes\n",
"### Notes:\n",
"- It relies on authentication with the azure.identity package, which can be installed with `pip install azure-identity`. Alternatively you can create the powerbi dataset with a token as a string without supplying the credentials.\n",
"- You can also supply a username to impersonate for use with datasets that have RLS enabled. \n",
"- The toolkit uses a LLM to create the query from the question, the agent uses the LLM for the overall execution.\n",
"- Testing was done mostly with a `text-davinci-003` model, codex models did not seem to perform ver well."
],
"metadata": {},
"attachments": {},
"id": "9363398d"
]
},
{
"cell_type": "markdown",
"source": [
"## Initialization"
],
"id": "0725445e",
"metadata": {
"tags": []
},
"id": "0725445e"
"source": [
"## Initialization"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c82f33e9",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from langchain.agents.agent_toolkits import create_pbi_agent\n",
"from langchain.agents.agent_toolkits import PowerBIToolkit\n",
@ -39,16 +43,16 @@
"from langchain.chat_models import ChatOpenAI\n",
"from langchain.agents import AgentExecutor\n",
"from azure.identity import DefaultAzureCredential"
],
"outputs": [],
"metadata": {
"tags": []
},
"id": "c82f33e9"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0b2c5853",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"fast_llm = ChatOpenAI(\n",
" temperature=0.5, max_tokens=1000, model_name=\"gpt-3.5-turbo\", verbose=True\n",
@ -69,99 +73,95 @@
" toolkit=toolkit,\n",
" verbose=True,\n",
")"
],
"outputs": [],
"metadata": {
"tags": []
},
"id": "0b2c5853"
]
},
{
"cell_type": "markdown",
"id": "80c92be3",
"metadata": {},
"source": [
"## Example: describing a table"
],
"metadata": {},
"id": "80c92be3"
]
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"agent_executor.run(\"Describe table1\")"
],
"outputs": [],
"id": "90f236cb",
"metadata": {
"tags": []
},
"id": "90f236cb"
"outputs": [],
"source": [
"agent_executor.run(\"Describe table1\")"
]
},
{
"cell_type": "markdown",
"id": "b464930f",
"metadata": {},
"source": [
"## Example: simple query on a table\n",
"In this example, the agent actually figures out the correct query to get a row count of the table."
],
"metadata": {},
"attachments": {},
"id": "b464930f"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b668c907",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"agent_executor.run(\"How many records are in table1?\")"
],
"outputs": [],
"metadata": {
"tags": []
},
"id": "b668c907"
]
},
{
"cell_type": "markdown",
"id": "f2229a2f",
"metadata": {},
"source": [
"## Example: running queries"
],
"metadata": {},
"id": "f2229a2f"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "865a420f",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"agent_executor.run(\"How many records are there by dimension1 in table2?\")"
],
"outputs": [],
"metadata": {
"tags": []
},
"id": "865a420f"
]
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"agent_executor.run(\"What unique values are there for dimensions2 in table2\")"
],
"outputs": [],
"id": "120cd49a",
"metadata": {
"tags": []
},
"id": "120cd49a"
"outputs": [],
"source": [
"agent_executor.run(\"What unique values are there for dimensions2 in table2\")"
]
},
{
"cell_type": "markdown",
"id": "ac584fb2",
"metadata": {},
"source": [
"## Example: add your own few-shot prompts"
],
"metadata": {},
"attachments": {},
"id": "ac584fb2"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ffa66827",
"metadata": {},
"outputs": [],
"source": [
"# fictional example\n",
"few_shots = \"\"\"\n",
@ -189,26 +189,27 @@
" toolkit=toolkit,\n",
" verbose=True,\n",
")"
],
"outputs": [],
"metadata": {},
"id": "ffa66827"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3be44685",
"metadata": {},
"outputs": [],
"source": [
"agent_executor.run(\"What was the maximum of value in revenue in dollars in 2022?\")"
],
"outputs": [],
"metadata": {},
"id": "3be44685"
]
}
],
"metadata": {
"interpreter": {
"hash": "397704579725e15f5c7cb49fe5f0341eb7531c82d19f2c29d197e8b64ab5776b"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3.9.16 64-bit"
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
@ -220,12 +221,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
},
"interpreter": {
"hash": "397704579725e15f5c7cb49fe5f0341eb7531c82d19f2c29d197e8b64ab5776b"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}

View File

@ -5,9 +5,9 @@
"id": "82a4c2cc-20ea-4b20-a565-63e905dee8ff",
"metadata": {},
"source": [
"# Python Agent\n",
"# Python\n",
"\n",
"This notebook showcases an agent designed to write and execute python code to answer a question."
"This notebook showcases an agent designed to write and execute `Python` code to answer a question."
]
},
{
@ -32,7 +32,7 @@
"id": "ca30d64c",
"metadata": {},
"source": [
"## Using ZERO_SHOT_REACT_DESCRIPTION\n",
"## Using `ZERO_SHOT_REACT_DESCRIPTION`\n",
"\n",
"This shows how to initialize the agent using the ZERO_SHOT_REACT_DESCRIPTION agent type."
]
@ -149,9 +149,7 @@
"cell_type": "code",
"execution_count": 5,
"id": "4b9f60e7-eb6a-4f14-8604-498d863d4482",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -271,7 +269,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -1,13 +1,12 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Spark Dataframe Agent\n",
"# Spark Dataframe\n",
"\n",
"This notebook shows how to use agents to interact with a Spark dataframe and Spark Connect. It is mostly optimized for question answering.\n",
"This notebook shows how to use agents to interact with a `Spark DataFrame` and `Spark Connect`. It is mostly optimized for question answering.\n",
"\n",
"**NOTE: this agent calls the Python agent under the hood, which executes LLM generated Python code - this can be bad if the LLM generated Python code is harmful. Use cautiously.**"
]
@ -23,6 +22,13 @@
"os.environ[\"OPENAI_API_KEY\"] = \"...input your openai api key here...\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## `Spark DataFrame` example"
]
},
{
"cell_type": "code",
"execution_count": 2,
@ -225,11 +231,10 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Spark Connect Example"
"## `Spark Connect` example"
]
},
{
@ -405,9 +410,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

View File

@ -4,9 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Spark SQL Agent\n",
"# Spark SQL\n",
"\n",
"This notebook shows how to use agents to interact with a Spark SQL. Similar to [SQL Database Agent](https://python.langchain.com/docs/integrations/toolkits/sql_database), it is designed to address general inquiries about Spark SQL and facilitate error recovery.\n",
"This notebook shows how to use agents to interact with `Spark SQL`. Similar to [SQL Database Agent](https://python.langchain.com/docs/integrations/toolkits/sql_database), it is designed to address general inquiries about `Spark SQL` and facilitate error recovery.\n",
"\n",
"**NOTE: Note that, as this agent is in active development, all answers might not be correct. Additionally, it is not guaranteed that the agent won't perform DML statements on your Spark cluster given certain questions. Be careful running it on sensitive data!**"
]
@ -163,7 +163,9 @@
},
{
"data": {
"text/plain": "'The titanic table has the following columns: PassengerId (INT), Survived (INT), Pclass (INT), Name (STRING), Sex (STRING), Age (DOUBLE), SibSp (INT), Parch (INT), Ticket (STRING), Fare (DOUBLE), Cabin (STRING), and Embarked (STRING). Here are some sample rows from the table: \\n\\n1. PassengerId: 1, Survived: 0, Pclass: 3, Name: Braund, Mr. Owen Harris, Sex: male, Age: 22.0, SibSp: 1, Parch: 0, Ticket: A/5 21171, Fare: 7.25, Cabin: None, Embarked: S\\n2. PassengerId: 2, Survived: 1, Pclass: 1, Name: Cumings, Mrs. John Bradley (Florence Briggs Thayer), Sex: female, Age: 38.0, SibSp: 1, Parch: 0, Ticket: PC 17599, Fare: 71.2833, Cabin: C85, Embarked: C\\n3. PassengerId: 3, Survived: 1, Pclass: 3, Name: Heikkinen, Miss. Laina, Sex: female, Age: 26.0, SibSp: 0, Parch: 0, Ticket: STON/O2. 3101282, Fare: 7.925, Cabin: None, Embarked: S'"
"text/plain": [
"'The titanic table has the following columns: PassengerId (INT), Survived (INT), Pclass (INT), Name (STRING), Sex (STRING), Age (DOUBLE), SibSp (INT), Parch (INT), Ticket (STRING), Fare (DOUBLE), Cabin (STRING), and Embarked (STRING). Here are some sample rows from the table: \\n\\n1. PassengerId: 1, Survived: 0, Pclass: 3, Name: Braund, Mr. Owen Harris, Sex: male, Age: 22.0, SibSp: 1, Parch: 0, Ticket: A/5 21171, Fare: 7.25, Cabin: None, Embarked: S\\n2. PassengerId: 2, Survived: 1, Pclass: 1, Name: Cumings, Mrs. John Bradley (Florence Briggs Thayer), Sex: female, Age: 38.0, SibSp: 1, Parch: 0, Ticket: PC 17599, Fare: 71.2833, Cabin: C85, Embarked: C\\n3. PassengerId: 3, Survived: 1, Pclass: 3, Name: Heikkinen, Miss. Laina, Sex: female, Age: 26.0, SibSp: 0, Parch: 0, Ticket: STON/O2. 3101282, Fare: 7.925, Cabin: None, Embarked: S'"
]
},
"execution_count": 4,
"metadata": {},
@ -239,7 +241,9 @@
},
{
"data": {
"text/plain": "'The square root of the average age is approximately 5.45.'"
"text/plain": [
"'The square root of the average age is approximately 5.45.'"
]
},
"execution_count": 5,
"metadata": {},
@ -253,6 +257,12 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"name": "stdout",
@ -305,7 +315,9 @@
},
{
"data": {
"text/plain": "'The oldest survived passenger is Barkworth, Mr. Algernon Henry Wilson, who was 80 years old.'"
"text/plain": [
"'The oldest survived passenger is Barkworth, Mr. Algernon Henry Wilson, who was 80 years old.'"
]
},
"execution_count": 6,
"metadata": {},
@ -314,10 +326,7 @@
],
"source": [
"agent_executor.run(\"What's the name of the oldest survived passenger?\")"
],
"metadata": {
"collapsed": false
}
]
}
],
"metadata": {
@ -336,9 +345,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

View File

@ -1,22 +1,21 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "0e499e90-7a6d-4fab-8aab-31a4df417601",
"metadata": {},
"source": [
"# SQL Database Agent\n",
"# SQL Database\n",
"\n",
"This notebook showcases an agent designed to interact with a sql databases. The agent builds off of [SQLDatabaseChain](https://python.langchain.com/docs/use_cases/tabular/sqlite) and is designed to answer more general questions about a database, as well as recover from errors.\n",
"This notebook showcases an agent designed to interact with a `SQL` databases. \n",
"The agent builds off of [SQLDatabaseChain](https://python.langchain.com/docs/use_cases/tabular/sqlite) and is designed to answer more general questions about a database, as well as recover from errors.\n",
"\n",
"Note that, as this agent is in active development, all answers might not be correct. Additionally, it is not guaranteed that the agent won't perform DML statements on your database given certain questions. Be careful running it on sensitive data!\n",
"\n",
"This uses the example Chinook database. To set it up follow the instructions on https://database.guide/2-sample-databases-sqlite/, placing the .db file in a notebooks folder at the root of this repository."
"This uses the example `Chinook` database. To set it up follow the instructions on https://database.guide/2-sample-databases-sqlite/, placing the .db file in a notebooks folder at the root of this repository."
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "ec927ac6-9b2a-4e8a-9a6e-3e429191875c",
"metadata": {
@ -56,12 +55,11 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f74d1792",
"metadata": {},
"source": [
"## Using ZERO_SHOT_REACT_DESCRIPTION\n",
"## Using `ZERO_SHOT_REACT_DESCRIPTION`\n",
"\n",
"This shows how to initialize the agent using the ZERO_SHOT_REACT_DESCRIPTION agent type."
]
@ -84,7 +82,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "971cc455",
"metadata": {},
@ -110,7 +107,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "54c01168",
"metadata": {},
@ -136,7 +132,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "5a4a9455",
"metadata": {},
@ -147,7 +142,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "36ae48c7-cb08-4fef-977e-c7d4b96a464b",
"metadata": {},
@ -237,7 +231,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "9abcfe8e-1868-42a4-8345-ad2d9b44c681",
"metadata": {},
@ -312,7 +305,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "6fbc26af-97e4-4a21-82aa-48bdc992da26",
"metadata": {},
@ -495,7 +487,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "7c7503b5-d9d9-4faa-b064-29fcdb5ff213",
"metadata": {},
@ -639,7 +630,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -1,23 +1,21 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "18ada398-dce6-4049-9b56-fc0ede63da9c",
"metadata": {},
"source": [
"# Vectorstore Agent\n",
"# Vectorstore\n",
"\n",
"This notebook showcases an agent designed to retrieve information from one or more vectorstores, either with or without sources."
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "eecb683b-3a46-4b9d-81a3-7caefbfec1a1",
"metadata": {},
"source": [
"## Create the Vectorstores"
"## Create Vectorstores"
]
},
{
@ -95,7 +93,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f4814175-964d-42f1-aa9d-22801ce1e912",
"metadata": {},
@ -128,7 +125,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "8a38ad10",
"metadata": {},
@ -217,7 +213,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "7ca07707",
"metadata": {},
@ -263,7 +258,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "71680984-edaf-4a63-90f5-94edbd263550",
"metadata": {},
@ -422,7 +416,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.10.12"
}
},
"nbformat": 4,

View File

@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Xorbits Agent"
"# Xorbits"
]
},
{
@ -13,7 +13,7 @@
"source": [
"This notebook shows how to use agents to interact with [Xorbits Pandas](https://doc.xorbits.io/en/latest/reference/pandas/index.html) dataframe and [Xorbits Numpy](https://doc.xorbits.io/en/latest/reference/numpy/index.html) ndarray. It is mostly optimized for question answering.\n",
"\n",
"**NOTE: this agent calls the Python agent under the hood, which executes LLM generated Python code - this can be bad if the LLM generated Python code is harmful. Use cautiously.**"
"**NOTE: this agent calls the `Python` agent under the hood, which executes LLM generated Python code - this can be bad if the LLM generated Python code is harmful. Use cautiously.**"
]
},
{
@ -734,9 +734,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}