diff --git a/docs/core_docs/docs/how_to/convert_runnable_to_tool.ipynb b/docs/core_docs/docs/how_to/convert_runnable_to_tool.ipynb index 2bd3a0096a27f..d4d74f116f78d 100644 --- a/docs/core_docs/docs/how_to/convert_runnable_to_tool.ipynb +++ b/docs/core_docs/docs/how_to/convert_runnable_to_tool.ipynb @@ -192,18 +192,6 @@ "```" ] }, - { - "cell_type": "code", - "execution_count": 6, - "id": "d06c9f2a-4475-450f-9106-54db1d99623b", - "metadata": {}, - "outputs": [], - "source": [ - "import { ChatOpenAI } from \"@langchain/openai\";\n", - "\n", - "const llm = new ChatOpenAI({ model: \"gpt-3.5-turbo-0125\", temperature: 0 })" - ] - }, { "cell_type": "markdown", "id": "e8a2038a-d762-4196-b5e3-fdb89c11e71d", @@ -214,7 +202,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 2, "id": "23d2a47e-6712-4294-81c8-2c1d76b4bb81", "metadata": {}, "outputs": [], @@ -222,7 +210,6 @@ "import { Document } from \"@langchain/core/documents\"\n", "import { MemoryVectorStore } from \"langchain/vectorstores/memory\";\n", "import { OpenAIEmbeddings } from \"@langchain/openai\";\n", - "import { RunnableLambda } from \"@langchain/core/runnables\";\n", "\n", "const documents = [\n", " new Document({\n", @@ -253,7 +240,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 8, "id": "c939cf2a-60e9-4afd-8b47-84d76ccb13f5", "metadata": {}, "outputs": [], @@ -273,7 +260,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 9, "id": "be29437b-a187-4a0a-9a5d-419c56f2434e", "metadata": {}, "outputs": [ @@ -288,7 +275,7 @@ " name: 'pet_info_retriever',\n", " args: [Object],\n", " type: 'tool_call',\n", - " id: 'call_VHSXMmcH5MRCXhqNXP6O4NLD'\n", + " id: 'call_HAyKm6RayDyup1aj75Jfxl11'\n", " }\n", " ]\n", "}\n", @@ -296,7 +283,7 @@ "ToolMessage {\n", " name: 'pet_info_retriever',\n", " content: '[{\"pageContent\":\"Dogs are great companions, known for their loyalty and friendliness.\",\"metadata\":{}}]',\n", - " tool_call_id: 'call_VHSXMmcH5MRCXhqNXP6O4NLD'\n", + " tool_call_id: 'call_HAyKm6RayDyup1aj75Jfxl11'\n", "}\n", "----\n", "AIMessage {\n", @@ -333,7 +320,7 @@ "```{=mdx}\n", "\n", ":::tip\n", - "See [LangSmith trace](https://smith.langchain.com/public/f0c01a8f-e02b-4c4d-8ca9-a1377d26c82d/r) for the above run.\n", + "See [LangSmith trace](https://smith.langchain.com/public/7fc14abe-042d-421b-8c98-a705a8cc5c41/r) for the above run.\n", ":::\n", "\n", "```" @@ -349,7 +336,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 7, "id": "bea518c9-c711-47c2-b8cc-dbd102f71f09", "metadata": {}, "outputs": [], @@ -379,7 +366,7 @@ "\n", "const ragChain = RunnableSequence.from([\n", " RunnablePassthrough.assign({\n", - " context: (input: RagChainInput) => retriever.invoke(input.question),\n", + " context: async (input: RagChainInput, config) => retriever.invoke(input.question, config),\n", " }),\n", " prompt,\n", " llm,\n", @@ -389,7 +376,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 8, "id": "a3f9cf5b-8c71-4b0f-902b-f92e028780c9", "metadata": {}, "outputs": [], @@ -414,7 +401,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 10, "id": "06409913-a2ad-400f-a202-7b8dd2ef483a", "metadata": {}, "outputs": [ @@ -428,18 +415,18 @@ " name: 'pet_expert',\n", " args: { question: 'What are dogs known for?', answer_style: 'pirate' },\n", " type: 'tool_call',\n", - " id: 'call_IU6i9sr8rtTn4RLTfUUNZD1I'\n", + " id: 'call_rWmwOVaPNaJ1PvrrN8QJDOeu'\n", " }\n", "}\n", "----\n", "ToolMessage {\n", " name: 'pet_expert',\n", - " content: \"Arrr, dogs be known for their loyalty to their mateys, their keen sense o' smell for sniffin' out treasure, and their bark that can make even the bravest pirate shiver in their boots!\",\n", - " tool_call_id: 'call_IU6i9sr8rtTn4RLTfUUNZD1I'\n", + " content: \"Arrr, dogs be known fer their loyalty to their mateys, their keen sense o' smell, and their barkin' to alert ye of danger. They be good companions on land and sea, always ready to stand by yer side. Dogs be fetchin', protectin', and bringin' joy to all who befriend 'em.\",\n", + " tool_call_id: 'call_rWmwOVaPNaJ1PvrrN8QJDOeu'\n", "}\n", "----\n", "AIMessage {\n", - " content: 'A pirate would say that dogs are known for their loyalty to their mateys, their keen sense of smell for sniffing out treasure, and their bark that can make even the bravest pirate shiver in their boots!',\n", + " content: \"A pirate would say that dogs are known for their loyalty to their mateys, their keen sense of smell, and their barkin' to alert ye of danger. They are good companions on land and sea, always ready to stand by yer side. Dogs be fetchin', protectin', and bringin' joy to all who befriend 'em.\",\n", " tool_calls: undefined\n", "}\n", "----\n" @@ -475,7 +462,7 @@ "\n", ":::tip\n", "\n", - "See [LangSmith trace](https://smith.langchain.com/public/678618e6-2d7f-4c1a-bcd0-d91873d50cc7/r) for the above run.\n", + "See [LangSmith trace](https://smith.langchain.com/public/7a5d93ab-3b9a-43f4-87af-947bf9999cb4/r) for the above run.\n", "\n", ":::\n", "\n",