Compare commits

...

2 Commits

Author SHA1 Message Date
isaac hershenson
91c2dd92b1 fmt 2024-08-09 10:29:13 -07:00
isaac hershenson
dfab23f931 wip 2024-08-09 10:25:20 -07:00
7 changed files with 310 additions and 720 deletions

View File

@@ -4,9 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# File System\n",
"# File Management Toolkit\n",
"\n",
"LangChain provides tools for interacting with a local file system out of the box. This notebook walks through some of them.\n",
"The `FileManagementToolkit` provides tools for interacting with a local file system out of the box. This notebook walks through some of them.\n",
"\n",
"**Note:** these tools are not recommended for use outside a sandboxed environment! "
]

View File

@@ -1,106 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "487607cd",
"metadata": {},
"source": [
"# Google Places\n",
"\n",
"This notebook goes through how to use Google Places API"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "8690845f",
"metadata": {},
"outputs": [],
"source": [
"%pip install --upgrade --quiet googlemaps langchain-community"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "fae31ef4",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ[\"GPLACES_API_KEY\"] = \"\""
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "abb502b3",
"metadata": {},
"outputs": [],
"source": [
"from langchain_community.tools import GooglePlacesTool"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "a83a02ac",
"metadata": {},
"outputs": [],
"source": [
"places = GooglePlacesTool()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "2b65a285",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"1. Delfina Restaurant\\nAddress: 3621 18th St, San Francisco, CA 94110, USA\\nPhone: (415) 552-4055\\nWebsite: https://www.delfinasf.com/\\n\\n\\n2. Piccolo Forno\\nAddress: 725 Columbus Ave, San Francisco, CA 94133, USA\\nPhone: (415) 757-0087\\nWebsite: https://piccolo-forno-sf.com/\\n\\n\\n3. L'Osteria del Forno\\nAddress: 519 Columbus Ave, San Francisco, CA 94133, USA\\nPhone: (415) 982-1124\\nWebsite: Unknown\\n\\n\\n4. Il Fornaio\\nAddress: 1265 Battery St, San Francisco, CA 94111, USA\\nPhone: (415) 986-0100\\nWebsite: https://www.ilfornaio.com/\\n\\n\""
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"places.run(\"al fornos\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "66d3da8a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -1,108 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Google Trends\n",
"\n",
"This notebook goes over how to use the Google Trends Tool to fetch trends information.\n",
"\n",
"First, you need to sign up for an `SerpApi key` key at: https://serpapi.com/users/sign_up.\n",
"\n",
"Then you must install `google-search-results` with the command:\n",
"\n",
"`pip install google-search-results`\n",
"\n",
"Then you will need to set the environment variable `SERPAPI_API_KEY` to your `SerpApi key`\n",
"\n",
"[Alternatively you can pass the key in as a argument to the wrapper `serp_api_key=\"your secret key\"`]\n",
"\n",
"## Use the Tool"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: google-search-results in c:\\python311\\lib\\site-packages (2.4.2)\n",
"Requirement already satisfied: requests in c:\\python311\\lib\\site-packages (from google-search-results) (2.31.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in c:\\python311\\lib\\site-packages (from requests->google-search-results) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in c:\\python311\\lib\\site-packages (from requests->google-search-results) (3.4)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\python311\\lib\\site-packages (from requests->google-search-results) (2.1.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in c:\\python311\\lib\\site-packages (from requests->google-search-results) (2023.7.22)\n"
]
}
],
"source": [
"%pip install --upgrade --quiet google-search-results langchain_community"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"from langchain_community.tools.google_trends import GoogleTrendsQueryRun\n",
"from langchain_community.utilities.google_trends import GoogleTrendsAPIWrapper\n",
"\n",
"os.environ[\"SERPAPI_API_KEY\"] = \"\"\n",
"tool = GoogleTrendsQueryRun(api_wrapper=GoogleTrendsAPIWrapper())"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Query: Water\\nDate From: Nov 20, 2022\\nDate To: Nov 11, 2023\\nMin Value: 72\\nMax Value: 100\\nAverage Value: 84.25490196078431\\nPrecent Change: 5.555555555555555%\\nTrend values: 72, 72, 74, 77, 86, 80, 82, 88, 79, 79, 85, 82, 81, 84, 83, 77, 80, 85, 82, 80, 88, 84, 82, 84, 83, 85, 92, 92, 100, 92, 100, 96, 94, 95, 94, 98, 96, 84, 86, 84, 85, 83, 83, 76, 81, 85, 78, 77, 81, 75, 76\\nRising Related Queries: avatar way of water, avatar the way of water, owala water bottle, air up water bottle, lake mead water level\\nTop Related Queries: water park, water bottle, water heater, water filter, water tank, water bill, water world, avatar way of water, avatar the way of water, coconut water, deep water, water cycle, water dispenser, water purifier, water pollution, distilled water, hot water heater, water cooler, sparkling water, american water, micellar water, density of water, tankless water heater, tonic water, water jug'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tool.run(\"Water\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.16 ('langchain')",
"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.4"
},
"vscode": {
"interpreter": {
"hash": "15e58ce194949b77a891bd4339ce3d86a9bd138e905926019517993f97db9e6c"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,200 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Oracle AI Vector Search: Generate Summary\n",
"\n",
"Oracle AI Vector Search is designed for Artificial Intelligence (AI) workloads that allows you to query data based on semantics, rather than keywords.\n",
"One of the biggest benefits of Oracle AI Vector Search is that semantic search on unstructured data can be combined with relational search on business data in one single system.\n",
"This is not only powerful but also significantly more effective because you don't need to add a specialized vector database, eliminating the pain of data fragmentation between multiple systems.\n",
"\n",
"In addition, your vectors can benefit from all of Oracle Databases most powerful features, like the following:\n",
"\n",
" * [Partitioning Support](https://www.oracle.com/database/technologies/partitioning.html)\n",
" * [Real Application Clusters scalability](https://www.oracle.com/database/real-application-clusters/)\n",
" * [Exadata smart scans](https://www.oracle.com/database/technologies/exadata/software/smartscan/)\n",
" * [Shard processing across geographically distributed databases](https://www.oracle.com/database/distributed-database/)\n",
" * [Transactions](https://docs.oracle.com/en/database/oracle/oracle-database/23/cncpt/transactions.html)\n",
" * [Parallel SQL](https://docs.oracle.com/en/database/oracle/oracle-database/21/vldbg/parallel-exec-intro.html#GUID-D28717E4-0F77-44F5-BB4E-234C31D4E4BA)\n",
" * [Disaster recovery](https://www.oracle.com/database/data-guard/)\n",
" * [Security](https://www.oracle.com/security/database-security/)\n",
" * [Oracle Machine Learning](https://www.oracle.com/artificial-intelligence/database-machine-learning/)\n",
" * [Oracle Graph Database](https://www.oracle.com/database/integrated-graph-database/)\n",
" * [Oracle Spatial and Graph](https://www.oracle.com/database/spatial/)\n",
" * [Oracle Blockchain](https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/dbms_blockchain_table.html#GUID-B469E277-978E-4378-A8C1-26D3FF96C9A6)\n",
" * [JSON](https://docs.oracle.com/en/database/oracle/oracle-database/23/adjsn/json-in-oracle-database.html)\n",
"\n",
"The guide demonstrates how to use Summary Capabilities within Oracle AI Vector Search to generate summary for your documents using OracleSummary."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you are just starting with Oracle Database, consider exploring the [free Oracle 23 AI](https://www.oracle.com/database/free/#resources) which provides a great introduction to setting up your database environment. While working with the database, it is often advisable to avoid using the system user by default; instead, you can create your own user for enhanced security and customization. For detailed steps on user creation, refer to our [end-to-end guide](https://github.com/langchain-ai/langchain/blob/master/cookbook/oracleai_demo.ipynb) which also shows how to set up a user in Oracle. Additionally, understanding user privileges is crucial for managing database security effectively. You can learn more about this topic in the official [Oracle guide](https://docs.oracle.com/en/database/oracle/oracle-database/19/admqs/administering-user-accounts-and-security.html#GUID-36B21D72-1BBB-46C9-A0C9-F0D2A8591B8D) on administering user accounts and security."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Prerequisites\n",
"\n",
"Please install Oracle Python Client driver to use Langchain with Oracle AI Vector Search. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# pip install oracledb"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Connect to Oracle Database\n",
"The following sample code will show how to connect to Oracle Database. By default, python-oracledb runs in a Thin mode which connects directly to Oracle Database. This mode does not need Oracle Client libraries. However, some additional functionality is available when python-oracledb uses them. Python-oracledb is said to be in Thick mode when Oracle Client libraries are used. Both modes have comprehensive functionality supporting the Python Database API v2.0 Specification. See the following [guide](https://python-oracledb.readthedocs.io/en/latest/user_guide/appendix_a.html#featuresummary) that talks about features supported in each mode. You might want to switch to thick-mode if you are unable to use thin-mode."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"\n",
"import oracledb\n",
"\n",
"# please update with your username, password, hostname and service_name\n",
"username = \"<username>\"\n",
"password = \"<password>\"\n",
"dsn = \"<hostname>/<service_name>\"\n",
"\n",
"try:\n",
" conn = oracledb.connect(user=username, password=password, dsn=dsn)\n",
" print(\"Connection successful!\")\n",
"except Exception as e:\n",
" print(\"Connection failed!\")\n",
" sys.exit(1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Generate Summary\n",
"The Oracle AI Vector Search Langchain library offers a suite of APIs designed for document summarization. It supports multiple summarization providers such as Database, OCIGENAI, HuggingFace, among others, allowing users to select the provider that best meets their needs. To utilize these capabilities, users must configure the summary parameters as specified. For detailed information on these parameters, please consult the [Oracle AI Vector Search Guide book](https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/dbms_vector_chain1.html#GUID-EC9DDB58-6A15-4B36-BA66-ECBA20D2CE57)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"***Note:*** The users may need to set proxy if they want to use some 3rd party summary generation providers other than Oracle's in-house and default provider: 'database'. If you don't have proxy, please remove the proxy parameter when you instantiate the OracleSummary."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# proxy to be used when we instantiate summary and embedder object\n",
"proxy = \"<proxy>\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The following sample code will show how to generate summary:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from langchain_community.utilities.oracleai import OracleSummary\n",
"from langchain_core.documents import Document\n",
"\n",
"\"\"\"\n",
"# using 'ocigenai' provider\n",
"summary_params = {\n",
" \"provider\": \"ocigenai\",\n",
" \"credential_name\": \"OCI_CRED\",\n",
" \"url\": \"https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/20231130/actions/summarizeText\",\n",
" \"model\": \"cohere.command\",\n",
"}\n",
"\n",
"# using 'huggingface' provider\n",
"summary_params = {\n",
" \"provider\": \"huggingface\",\n",
" \"credential_name\": \"HF_CRED\",\n",
" \"url\": \"https://api-inference.huggingface.co/models/\",\n",
" \"model\": \"facebook/bart-large-cnn\",\n",
" \"wait_for_model\": \"true\"\n",
"}\n",
"\"\"\"\n",
"\n",
"# using 'database' provider\n",
"summary_params = {\n",
" \"provider\": \"database\",\n",
" \"glevel\": \"S\",\n",
" \"numParagraphs\": 1,\n",
" \"language\": \"english\",\n",
"}\n",
"\n",
"# get the summary instance\n",
"# Remove proxy if not required\n",
"summ = OracleSummary(conn=conn, params=summary_params, proxy=proxy)\n",
"summary = summ.get_summary(\n",
" \"In the heart of the forest, \"\n",
" + \"a lone fox ventured out at dusk, seeking a lost treasure. \"\n",
" + \"With each step, memories flooded back, guiding its path. \"\n",
" + \"As the moon rose high, illuminating the night, the fox unearthed \"\n",
" + \"not gold, but a forgotten friendship, worth more than any riches.\"\n",
")\n",
"\n",
"print(f\"Summary generated by OracleSummary: {summary}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### End to End Demo\n",
"Please refer to our complete demo guide [Oracle AI Vector Search End-to-End Demo Guide](https://github.com/langchain-ai/langchain/tree/master/cookbook/oracleai_demo.ipynb) to build an end to end RAG pipeline with the help of Oracle AI Vector Search.\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

View File

@@ -1,302 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "c81da886",
"metadata": {},
"source": [
"# 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",
"\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.**"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "0cdd9bf5",
"metadata": {},
"outputs": [],
"source": [
"from langchain.agents.agent_types import AgentType\n",
"from langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent\n",
"from langchain_openai import ChatOpenAI"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "051ebe84",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from langchain_openai import OpenAI\n",
"\n",
"df = pd.read_csv(\n",
" \"https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv\"\n",
")"
]
},
{
"cell_type": "markdown",
"id": "a62858e2",
"metadata": {},
"source": [
"## Using `ZERO_SHOT_REACT_DESCRIPTION`\n",
"\n",
"This shows how to initialize the agent using the `ZERO_SHOT_REACT_DESCRIPTION` agent type."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "4185ff46",
"metadata": {},
"outputs": [],
"source": [
"agent = create_pandas_dataframe_agent(OpenAI(temperature=0), df, verbose=True)"
]
},
{
"cell_type": "markdown",
"id": "7233ab56",
"metadata": {},
"source": [
"## Using OpenAI Functions\n",
"\n",
"This shows how to initialize the agent using the OPENAI_FUNCTIONS agent type. Note that this is an alternative to the above."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "a8ea710e",
"metadata": {},
"outputs": [],
"source": [
"agent = create_pandas_dataframe_agent(\n",
" ChatOpenAI(temperature=0, model=\"gpt-3.5-turbo-0613\"),\n",
" df,\n",
" verbose=True,\n",
" agent_type=AgentType.OPENAI_FUNCTIONS,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a9207a2e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m> Entering new chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3m\n",
"Invoking: `python_repl_ast` with `df.shape[0]`\n",
"\n",
"\n",
"\u001b[0m\u001b[36;1m\u001b[1;3m891\u001b[0m\u001b[32;1m\u001b[1;3mThere are 891 rows in the dataframe.\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'There are 891 rows in the dataframe.'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"agent.invoke(\"how many rows are there?\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "bd43617c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mThought: I need to count the number of people with more than 3 siblings\n",
"Action: python_repl_ast\n",
"Action Input: df[df['SibSp'] > 3].shape[0]\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3m30\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3m I now know the final answer\n",
"Final Answer: 30 people have more than 3 siblings.\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'30 people have more than 3 siblings.'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"agent.invoke(\"how many people have more than 3 siblings\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "94e64b58",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mThought: I need to calculate the average age first\n",
"Action: python_repl_ast\n",
"Action Input: df['Age'].mean()\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3m29.69911764705882\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3m I now need to calculate the square root of the average age\n",
"Action: python_repl_ast\n",
"Action Input: math.sqrt(df['Age'].mean())\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3mNameError(\"name 'math' is not defined\")\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3m I need to import the math library\n",
"Action: python_repl_ast\n",
"Action Input: import math\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3m\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3m I now need to calculate the square root of the average age\n",
"Action: python_repl_ast\n",
"Action Input: math.sqrt(df['Age'].mean())\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3m5.449689683556195\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3m I now know the final answer\n",
"Final Answer: The square root of the average age is 5.449689683556195.\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'The square root of the average age is 5.449689683556195.'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"agent.invoke(\"whats the square root of the average age?\")"
]
},
{
"cell_type": "markdown",
"id": "c4bc0584",
"metadata": {},
"source": [
"## Multi DataFrame Example\n",
"\n",
"This next part shows how the agent can interact with multiple dataframes passed in as a list."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "42a15bd9",
"metadata": {},
"outputs": [],
"source": [
"df1 = df.copy()\n",
"df1[\"Age\"] = df1[\"Age\"].fillna(df1[\"Age\"].mean())"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "eba13b4d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mThought: I need to compare the age columns in both dataframes\n",
"Action: python_repl_ast\n",
"Action Input: len(df1[df1['Age'] != df2['Age']])\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3m177\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3m I now know the final answer\n",
"Final Answer: 177 rows in the age column are different.\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'177 rows in the age column are different.'"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"agent = create_pandas_dataframe_agent(OpenAI(temperature=0), [df, df1], verbose=True)\n",
"agent.invoke(\"how many rows in the age column are different?\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "60d08a56",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.1"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -62,6 +62,11 @@ SEARCH_TOOL_FEAT_TABLE = {
"available_data": "Answer",
"link": "/docs/integrations/tools/serpapi",
},
"Data for SEO": {
"pricing": "Not free, price depends on API used",
"available_data": "URL, Snippet, Title, Type",
"link": "/docs/integrations/tools/dataforseo",
},
}
CODE_INTERPRETER_TOOL_FEAT_TABLE = {
@@ -93,6 +98,20 @@ CODE_INTERPRETER_TOOL_FEAT_TABLE = {
"return_results": "Text, Images",
"link": "/docs/integrations/tools/azure_dynamic_sessions",
},
"Bash": {
"langauges": "Bash",
"sandbox_lifetime": "Resets on Execution",
"upload": True,
"return_results": "Bash execution results",
"link": "/docs/integrations/tools/bash",
},
"Databrick Unity Cataong": {
"langauges": "Python, SQL",
"sandbox_lifetime": "Resets on Execution",
"upload": False,
"return_results": "Text",
"link": "/docs/integrations/tools/databricks",
},
}
PRODUCTIVITY_TOOL_FEAT_TABLE = {
@@ -128,6 +147,46 @@ PRODUCTIVITY_TOOL_FEAT_TABLE = {
"link": "/docs/integrations/tools/infobip",
"pricing": "Free trial, with variable pricing after",
},
"AWS Toolkit": {
"link": "/docs/integrations/tools/aws",
"pricing": "Free tier, with variable pricing after",
},
"ClickUp": {
"link": "/docs/integrations/tools/clickup",
"pricing": "Free tier, with variable pricing after",
},
"Cogniswitch": {
"link": "/docs/integrations/tools/cogniswitch",
"pricing": "Free trial, with variable pricing after",
},
"Google Drive": {
"link": "/docs/integrations/tools/google_drive",
"pricing": "Free",
},
"IFTTT Webhooks": {
"link": "/docs/integrations/tools/ifttt",
"pricing": "Free tier, with variable pricing after",
},
"Lemon AI": {
"link": "/docs/integrations/tools/lemonai",
"pricing": "Depends on service used",
},
"Power BI": {
"link": "/docs/integrations/tools/power_bi",
"pricing": "Free tier, with variable pricing after",
},
"Wolfram Alpha": {
"link": "/docs/integrations/tools/wolfram_alpha",
"pricing": "Free up to 2000 calls/month",
},
"Zapier": {
"link": "/docs/integrations/tools/zapier",
"pricing": "Free up to 100 tasks/month",
},
"Zenguard AI": {
"link": "/docs/integrations/tools/zenguard",
"pricing": "Free up to 1000 requests/day",
},
}
WEBBROWSING_TOOL_FEAT_TABLE = {
@@ -161,6 +220,164 @@ DATABASE_TOOL_FEAT_TABLE = {
"link": "/docs/integrations/tools/cassandra_database",
"operations": "SELECT and schema introspection",
},
"GraphQL Toolkit": {
"link": "/docs/integrations/tools/graphql",
"operations": "GraphQL queries",
},
}
DOMAIN_SPECIFIC_SEARCH_TOOL_FEAT_TABLE = {
"Amadeus": {"link": "/docs/integration/tools/amadeus", "domain": "Travel"},
"Alpha Vantage": {
"link": "/docs/integration/tools/alpha_vantage",
"domain": "Finance",
},
"ArXiv": {"link": "/docs/integration/tools/arxiv", "domain": "Research"},
"AskNews": {"link": "/docs/integration/tools/asknews", "domain": "News"},
"Financial Datasets": {
"link": "/docs/integration/tools/financial_datasets",
"domain": "Finance",
},
"Google Finance": {
"link": "/docs/integration/tools/google_finance",
"domain": "Finance",
},
"Google Jobs": {"link": "/docs/integration/tools/google_jobs", "domain": "Jobs"},
"Google Scholar": {
"link": "/docs/integration/tools/google_scholar",
"domain": "Research",
},
"Ionic Shopping": {
"link": "/docs/integration/tools/ionic_shopping",
"domain": "Shopping",
},
"NASA": {"link": "/docs/integration/tools/nasa", "domain": "Space"},
"OpenWeatherMap": {
"link": "/docs/integrations/tools/openweathermap",
"domain": "Weather",
},
"Passio Nutrion": {
"link": "/docs/integrations/tools/passio_nutrition_ai",
"domain": "Nutrition",
},
"Polygon IO": {"link": "/docs/integrations/tools/polygon", "domain": "Finance"},
"PubMed": {"link": "/docs/integrations/tools/pubmed", "domain": "Medical Research"},
"Reddit Search": {
"link": "/docs/integrations/tools/reddit_search",
"domain": "Social Media",
},
"Semantic Scholar": {
"link": "/docs/integrations/tools/semanticscholar",
"domain": "Research",
},
"Stack Exchange": {
"link": "/docs/integrations/tools/stackexchange",
"domain": "StackOverflow",
},
"Steam Toolkit": {"link": "/docs/integrations/tools/steam", "domain": "Gaming"},
"Wikidata": {
"link": "/docs/integrations/tools/wikidata",
"domain": "General Knowledge",
},
"Wikipedia": {
"link": "/docs/integrations/tools/wikipedia",
"domain": "General Knowledge",
},
"Yahoo Finance": {
"link": "/docs/integrations/tools/yahoo_finance_news",
"domain": "Finance",
},
"YouTube": {"link": "/docs/integrations/tools/youtube", "domain": "YouTube"},
"Golden Query": {
"link": "/docs/integrations/tools/golden_query",
"domain": "General Knowledge",
},
}
MULTIMODAL_TOOL_FEAT_TABLE = {
"SceneXplain": {
"link": "/docs/integration/tools/sceneXplain",
"modalities": "Images",
},
"Nuclia Understanding": {
"link": "/docs/integration/tools/nuclia",
"modalities": "Images, Videos, Audio, Documents",
},
"NVIDIA Riva": {
"link": "/docs/integration/tools/nvidia_riva",
"modalities": "Audio",
},
"Azure AI Services": {
"link": "/docs/integration/tools/azure_ai_services",
"modalities": "Images, Videos, Audio, Documents",
},
"Azure Cognitive Services": {
"link": "/docs/integration/tools/azure_cognitive_services",
"modalities": "Images, Videos, Audio, Documents",
},
"Dall-E Image Generator": {
"link": "/docs/integrations/tools/dalle_image_generator",
"modalities": "Images",
},
"Eden AI": {
"link": "/docs/integrations/tools/edenai_tools",
"modalities": "Images, Audio, Invoices",
},
"Eleven Labs": {
"link": "/docs/integrations/tools/eleven_labs_tts",
"modalities": "Audio",
},
"Google Cloud Text-to-Speech": {
"link": "/docs/integrations/tools/google_cloud_texttospeech",
"modalities": "Audio",
},
"Google Imagen": {
"link": "/docs/integrations/tools/google_imagen",
"modalities": "Images",
},
"Google Lens": {
"link": "/docs/integrations/tools/google_lens",
"modalities": "Images",
},
}
MISCELLANEOUS_TOOL_FEAT_TABLE = {
"Dataherald": {
"link": "/docs/integrations/tools/dataherald",
"description": "Natural language to SQL API",
},
"File Management": {
"link": "/docs/integrations/tools/filesystem",
"description": "Manage your local file system",
},
"Gradio": {
"link": "/docs/integrations/tools/gradio",
"description": "Use Gradio ML apps in your agent",
},
"JSON Toolkit": {
"link": "/docs/integrations/tools/json",
"description": "Interact with large JSON blobs",
},
"OpenAPI": {
"link": "/docs/integrations/tools/openapi",
"description": "Consume arbitrary APIs conforming to the OpenAPI spec",
},
"Natural Language API": {
"link": "/docs/integrations/tools/openapi_nla",
"description": "Efficiently plan and combine calls across endpoints",
},
"Robocorp": {
"link": "/docs/integrations/tools/robocorp",
"description": "Integrate custom actions with your agents",
},
"Human as a tool": {
"link": "/docs/integrations/tools/human_tools",
"description": "Use human input as a tool",
},
"Memorize": {
"link": "/docs/integrations/tools/memorize",
"description": "Fine tune model to memorize data",
},
}
TOOLS_TEMPLATE = """\
@@ -210,6 +427,24 @@ The following table shows tools that can be used to automate tasks in databases:
{database_table}
## Domain Specific Search
The following table shows tools that can be used to search for specific types of data:
{domain_specific_search_table}
## Multimodal
The following table shows tools that can be used for dealing with multimodal data:
{multimodal_table}
## Miscellaneous
The following table shows tools that don't fit into the other categories:
{miscellaneous_table}
""" # noqa: E501
@@ -258,6 +493,56 @@ def get_webbrowsing_table() -> str:
return "\n".join(["|".join(row) for row in rows])
def get_miscellaneous_table() -> str:
"""Get the table of miscellaneous tools."""
header = ["tool", "description"]
title = ["Tool/Toolkit", "Description"]
rows = [title, [":-"] + [":-:"] * (len(title) - 1)]
for miscellaneous_tool, feats in sorted(MISCELLANEOUS_TOOL_FEAT_TABLE.items()):
# Fields are in the order of the header
row = [
f"[{miscellaneous_tool}]({feats['link']})",
]
for h in header[1:]:
row.append(feats.get(h))
rows.append(row)
return "\n".join(["|".join(row) for row in rows])
def get_domain_specific_search_table() -> str:
"""Get the table of domain specific tools."""
header = ["tool", "domain"]
title = ["Tool/Toolkit", "Domain"]
rows = [title, [":-"] + [":-:"] * (len(title) - 1)]
for domain_specific_tool, feats in sorted(
DOMAIN_SPECIFIC_SEARCH_TOOL_FEAT_TABLE.items()
):
# Fields are in the order of the header
row = [
f"[{domain_specific_tool}]({feats['link']})",
]
for h in header[1:]:
row.append(feats.get(h))
rows.append(row)
return "\n".join(["|".join(row) for row in rows])
def get_multimodal_table() -> str:
"""Get the table of multimodal tools."""
header = ["tool", "modalities"]
title = ["Tool/Toolkit", "Modalties"]
rows = [title, [":-"] + [":-:"] * (len(title) - 1)]
for multi_modal_tool, feats in sorted(MULTIMODAL_TOOL_FEAT_TABLE.items()):
# Fields are in the order of the header
row = [
f"[{multi_modal_tool}]({feats['link']})",
]
for h in header[1:]:
row.append(feats.get(h))
rows.append(row)
return "\n".join(["|".join(row) for row in rows])
def get_database_table() -> str:
"""Get the table of database tools."""
header = ["tool", "operations"]
@@ -307,10 +592,12 @@ def get_code_interpreter_table() -> str:
"Return Types",
]
rows = [title, [":-"] + [":-:"] * (len(title) - 1)]
for search_tool, feats in sorted(CODE_INTERPRETER_TOOL_FEAT_TABLE.items()):
for code_interpreter_tool, feats in sorted(
CODE_INTERPRETER_TOOL_FEAT_TABLE.items()
):
# Fields are in the order of the header
row = [
f"[{search_tool}]({feats['link']})",
f"[{code_interpreter_tool}]({feats['link']})",
]
for h in header[1:]:
value = feats.get(h)
@@ -337,6 +624,9 @@ if __name__ == "__main__":
productivity_table=get_productivity_table(),
webbrowsing_table=get_webbrowsing_table(),
database_table=get_database_table(),
domain_specific_search_table=get_domain_specific_search_table(),
multimodal_table=get_multimodal_table(),
miscellaneous_table=get_miscellaneous_table(),
)
with open(output_integrations_dir / "tools" / "index.mdx", "w") as f:
f.write(tools_page)

View File

@@ -85,6 +85,22 @@
{
"source": "/v0.2/docs/integrations/toolkits/:path(.*/?)*",
"destination": "/v0.2/docs/integrations/tools/:path*"
},
{
"source": "/v0.2/docs/integrations/tools/pandas",
"destination": "/v0.1/docs/integrations/toolkits/pandas/"
},
{
"source": "/v0.2/docs/integrations/tools/oracleai",
"destination": "/v0.1/docs/integrations/tools/oracleai"
},
{
"source": "/v0.2/docs/integrations/tools/google_places",
"destination": "/v0.1/docs/integrations/tools/google_places"
},
{
"source": "/v0.2/docs/integrations/tools/google_trends",
"destination": "/v0.1/docs/integrations/tools/google_trends"
}
]
}