mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-21 14:18:52 +00:00
docs: Minor update to Robocorp toolkit docs (#16399)
This commit is contained in:
parent
a1c0cf21c9
commit
369e90d427
@ -9,9 +9,11 @@
|
||||
"\n",
|
||||
"This notebook covers how to get started with [Robocorp Action Server](https://github.com/robocorp/robocorp) action toolkit and LangChain.\n",
|
||||
"\n",
|
||||
"Robocorp is the easiest way to extend the capabilities of AI agents, assistants and copilots with custom actions.\n",
|
||||
"\n",
|
||||
"## Installation\n",
|
||||
"\n",
|
||||
"First, see the [Robocorp Quickstart](https://github.com/robocorp/robocorp#quickstart) on how to setup Action Server and create your Actions.\n",
|
||||
"First, see the [Robocorp Quickstart](https://github.com/robocorp/robocorp#quickstart) on how to setup `Action Server` and create your Actions.\n",
|
||||
"\n",
|
||||
"In your LangChain application, install the `langchain-robocorp` package: "
|
||||
]
|
||||
@ -20,13 +22,61 @@
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "4c3bef91",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Install package\n",
|
||||
"%pip install --upgrade --quiet langchain-robocorp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "dd53ad19-4a62-46d1-a2f7-151cfd282590",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"When you create the new `Action Server` following the above quickstart.\n",
|
||||
"\n",
|
||||
"It will create a directory with files, including `action.py`.\n",
|
||||
"\n",
|
||||
"We can add python function as actions as shown [here](https://github.com/robocorp/robocorp/tree/master/actions#describe-your-action).\n",
|
||||
"\n",
|
||||
"Let's add a dummy function to `action.py`.\n",
|
||||
"\n",
|
||||
"```\n",
|
||||
"@action\n",
|
||||
"def get_weather_forecast(city: str, days: int, scale: str = \"celsius\") -> str:\n",
|
||||
" \"\"\"\n",
|
||||
" Returns weather conditions forecast for a given city.\n",
|
||||
"\n",
|
||||
" Args:\n",
|
||||
" city (str): Target city to get the weather conditions for\n",
|
||||
" days: How many day forecast to return\n",
|
||||
" scale (str): Temperature scale to use, should be one of \"celsius\" or \"fahrenheit\"\n",
|
||||
"\n",
|
||||
" Returns:\n",
|
||||
" str: The requested weather conditions forecast\n",
|
||||
" \"\"\"\n",
|
||||
" return \"75F and sunny :)\"\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"We then start the server:\n",
|
||||
"\n",
|
||||
"```\n",
|
||||
"action-server start\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"And we can see: \n",
|
||||
"\n",
|
||||
"```\n",
|
||||
"Found new action: get_weather_forecast\n",
|
||||
"\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"Test locally by going to the server running at `http://localhost:8080` and use the UI to run the function."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2b4f3e15",
|
||||
@ -38,17 +88,47 @@
|
||||
"\n",
|
||||
"- `LANGCHAIN_TRACING_V2=true`: To enable LangSmith log run tracing that can also be bind to respective Action Server action run logs. See [LangSmith documentation](https://docs.smith.langchain.com/tracing#log-runs) for more.\n",
|
||||
"\n",
|
||||
"## Usage"
|
||||
"## Usage\n",
|
||||
"\n",
|
||||
"We started the local action server, above, running on `http://localhost:8080`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 7,
|
||||
"id": "62e0dbc3",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n",
|
||||
"\n",
|
||||
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
|
||||
"\u001b[32;1m\u001b[1;3m\n",
|
||||
"Invoking: `robocorp_action_server_get_weather_forecast` with `{'city': 'San Francisco', 'days': 1, 'scale': 'fahrenheit'}`\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\u001b[0m\u001b[33;1m\u001b[1;3m\"75F and sunny :)\"\u001b[0m\u001b[32;1m\u001b[1;3mThe current weather today in San Francisco is 75F and sunny.\u001b[0m\n",
|
||||
"\n",
|
||||
"\u001b[1m> Finished chain.\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'input': 'What is the current weather today in San Francisco in fahrenheit?',\n",
|
||||
" 'output': 'The current weather today in San Francisco is 75F and sunny.'}"
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from langchain.agents import AgentExecutor, OpenAIFunctionsAgent\n",
|
||||
"from langchain.chat_models import ChatOpenAI\n",
|
||||
@ -69,8 +149,7 @@
|
||||
"\n",
|
||||
"executor = AgentExecutor(agent=agent, tools=tools, verbose=True)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"executor.invoke(\"What is the current date?\")"
|
||||
"executor.invoke(\"What is the current weather today in San Francisco in fahrenheit?\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -80,12 +159,14 @@
|
||||
"source": [
|
||||
"### Single input tools\n",
|
||||
"\n",
|
||||
"By default `toolkit.get_tools()` will return the actions as Structured Tools. To return single input tools, pass a Chat model to be used for processing the inputs."
|
||||
"By default `toolkit.get_tools()` will return the actions as Structured Tools. \n",
|
||||
"\n",
|
||||
"To return single input tools, pass a Chat model to be used for processing the inputs."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 9,
|
||||
"id": "1dc7db86",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@ -112,7 +193,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.5"
|
||||
"version": "3.9.16"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
Loading…
Reference in New Issue
Block a user