mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-01 13:26:15 +00:00
202 lines
4.9 KiB
Plaintext
202 lines
4.9 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "raw",
|
|
"id": "afaf8039",
|
|
"metadata": {},
|
|
"source": [
|
|
"---\n",
|
|
"sidebar_label: __ModuleName__\n",
|
|
"---"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "e49f1e0d",
|
|
"metadata": {},
|
|
"source": [
|
|
"# __ModuleName__Toolkit\n",
|
|
"\n",
|
|
"- TODO: Make sure API reference link is correct.\n",
|
|
"\n",
|
|
"This will help you getting started with the __ModuleName__ [toolkit](/docs/concepts/#toolkits). For detailed documentation of all __ModuleName__Toolkit features and configurations head to the [API reference](https://api.python.langchain.com/en/latest/agent_toolkits/__module_name__.agent_toolkits.__ModuleName__.toolkit.__ModuleName__Toolkit.html).\n",
|
|
"\n",
|
|
"## Setup\n",
|
|
"\n",
|
|
"- TODO: Update with relevant info."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "72ee0c4b-9764-423a-9dbf-95129e185210",
|
|
"metadata": {},
|
|
"source": [
|
|
"If you want to get automated tracing from runs of individual tools, you can also set your [LangSmith](https://docs.smith.langchain.com/) API key by uncommenting below:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "a15d341e-3e26-4ca3-830b-5aab30ed66de",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")\n",
|
|
"# os.environ[\"LANGSMITH_TRACING\"] = \"true\""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0730d6a1-c893-4840-9817-5e5251676d5d",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Installation\n",
|
|
"\n",
|
|
"This toolkit lives in the `__package_name__` package:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "652d6238-1f87-422a-b135-f5abbb8652fc",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"%pip install -qU __package_name__"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "a38cde65-254d-4219-a441-068766c0d4b5",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Instantiation\n",
|
|
"\n",
|
|
"Now we can instantiate our toolkit:\n",
|
|
"\n",
|
|
"- TODO: Update model instantiation with relevant params."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "cb09c344-1836-4e0c-acf8-11d13ac1dbae",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from __module_name__ import __ModuleName__Toolkit\n",
|
|
"\n",
|
|
"toolkit = __ModuleName__Toolkit(\n",
|
|
" # ...\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "5c5f2839-4020-424e-9fc9-07777eede442",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Tools\n",
|
|
"\n",
|
|
"View available tools:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "51a60dbe-9f2e-4e04-bb62-23968f17164a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"toolkit.get_tools()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "d11245ad-3661-4405-8558-1188896347ec",
|
|
"metadata": {},
|
|
"source": [
|
|
"TODO: list API reference pages for individual tools."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "dfe8aad4-8626-4330-98a9-7ea1ca5d2e0e",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Use within an agent"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "310bf18e-6c9a-4072-b86e-47bc1fcca29d",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from langgraph.prebuilt import create_react_agent\n",
|
|
"\n",
|
|
"agent_executor = create_react_agent(llm, tools)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "23e11cc9-abd6-4855-a7eb-799f45ca01ae",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"example_query = \"...\"\n",
|
|
"\n",
|
|
"events = agent_executor.stream(\n",
|
|
" {\"messages\": [(\"user\", example_query)]},\n",
|
|
" stream_mode=\"values\",\n",
|
|
")\n",
|
|
"for event in events:\n",
|
|
" event[\"messages\"][-1].pretty_print()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "d1ee55bc-ffc8-4cfa-801c-993953a08cfd",
|
|
"metadata": {},
|
|
"source": [
|
|
"## TODO: Any functionality or considerations specific to this toolkit\n",
|
|
"\n",
|
|
"Fill in or delete if not relevant."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "3a5bb5ca-c3ae-4a58-be67-2cd18574b9a3",
|
|
"metadata": {},
|
|
"source": [
|
|
"## API reference\n",
|
|
"\n",
|
|
"For detailed documentation of all __ModuleName__Toolkit features and configurations head to the [API reference](https://api.python.langchain.com/en/latest/agent_toolkits/__module_name__.agent_toolkits.__ModuleName__.toolkit.__ModuleName__Toolkit.html)."
|
|
]
|
|
}
|
|
],
|
|
"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.4"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|