diff --git a/docs/docs/modules/model_io/output_parsers/types/openai_tools.ipynb b/docs/docs/modules/model_io/output_parsers/types/openai_tools.ipynb index a9a68f3f70..5e733cea70 100644 --- a/docs/docs/modules/model_io/output_parsers/types/openai_tools.ipynb +++ b/docs/docs/modules/model_io/output_parsers/types/openai_tools.ipynb @@ -257,7 +257,7 @@ "id": "fc5695c5-451f-482f-bde6-462d85f1a93e", "metadata": {}, "source": [ - "Certain models can return multiple tool invocations each call, so by default the output is a list. If we just want to return the first tool invocation, we can specify `return_single=True`" + "Certain models can return multiple tool invocations each call, so by default the output is a list. If we just want to return the first tool invocation, we can specify `first_tool_only=True`" ] }, { @@ -279,7 +279,7 @@ } ], "source": [ - "parser = JsonOutputKeyToolsParser(key_name=\"Joke\", return_single=True)\n", + "parser = JsonOutputKeyToolsParser(key_name=\"Joke\", first_tool_only=True)\n", "chain = prompt | model | parser\n", "chain.invoke({\"input\": \"tell me a joke\"})" ] diff --git a/docs/docs/use_cases/csv.ipynb b/docs/docs/use_cases/csv.ipynb index 589faa1695..fa8cbdbcb4 100644 --- a/docs/docs/use_cases/csv.ipynb +++ b/docs/docs/use_cases/csv.ipynb @@ -418,7 +418,7 @@ "source": [ "from langchain.output_parsers.openai_tools import JsonOutputKeyToolsParser\n", "\n", - "parser = JsonOutputKeyToolsParser(tool.name, return_single=True)\n", + "parser = JsonOutputKeyToolsParser(tool.name, first_tool_only=True)\n", "(llm_with_tools | parser).invoke(\n", " \"I have a dataframe 'df' and want to know the correlation between the 'Age' and 'Fare' columns\"\n", ")" diff --git a/docs/docs/use_cases/question_answering/citations.ipynb b/docs/docs/use_cases/question_answering/citations.ipynb index 428f1656c5..a86d1b8be8 100644 --- a/docs/docs/use_cases/question_answering/citations.ipynb +++ b/docs/docs/use_cases/question_answering/citations.ipynb @@ -281,7 +281,7 @@ "source": [ "from langchain.output_parsers.openai_tools import JsonOutputKeyToolsParser\n", "\n", - "output_parser = JsonOutputKeyToolsParser(key_name=\"cited_answer\", return_single=True)\n", + "output_parser = JsonOutputKeyToolsParser(key_name=\"cited_answer\", first_tool_only=True)\n", "(llm_with_tool | output_parser).invoke(example_q)" ] }, @@ -403,7 +403,9 @@ "metadata": {}, "outputs": [], "source": [ - "output_parser_2 = JsonOutputKeyToolsParser(key_name=\"quoted_answer\", return_single=True)\n", + "output_parser_2 = JsonOutputKeyToolsParser(\n", + " key_name=\"quoted_answer\", first_tool_only=True\n", + ")\n", "llm_with_tool_2 = llm.bind_tools(\n", " [quoted_answer],\n", " tool_choice=\"quoted_answer\",\n", @@ -785,7 +787,7 @@ "annotation_chain = (\n", " prompt_5\n", " | llm_with_tools_5\n", - " | JsonOutputKeyToolsParser(key_name=\"annotated_answer\", return_single=True)\n", + " | JsonOutputKeyToolsParser(key_name=\"annotated_answer\", first_tool_only=True)\n", " | itemgetter(\"citations\")\n", ")\n", "\n", diff --git a/docs/docs/use_cases/tool_use/quickstart.ipynb b/docs/docs/use_cases/tool_use/quickstart.ipynb index c4c4accd01..d8b335920f 100644 --- a/docs/docs/use_cases/tool_use/quickstart.ipynb +++ b/docs/docs/use_cases/tool_use/quickstart.ipynb @@ -266,7 +266,7 @@ "id": "7f712d8d-0314-4d3d-b563-378b72fd8bb5", "metadata": {}, "source": [ - "Since we know we're always invoking the `multiply` tool, we can simplify our output a bit to return only the args for the `multiply` tool using the `JsonoutputKeyToolsParser`. To further simplify we'll specify `return_single=True`, so that instead of a list of tool invocations our output parser returns only the first tool invocation." + "Since we know we're always invoking the `multiply` tool, we can simplify our output a bit to return only the args for the `multiply` tool using the `JsonoutputKeyToolsParser`. To further simplify we'll specify `first_tool_only=True`, so that instead of a list of tool invocations our output parser returns only the first tool invocation." ] }, { @@ -290,7 +290,7 @@ "from langchain.output_parsers import JsonOutputKeyToolsParser\n", "\n", "chain = model_with_tools | JsonOutputKeyToolsParser(\n", - " key_name=\"multiply\", return_single=True\n", + " key_name=\"multiply\", first_tool_only=True\n", ")\n", "chain.invoke(\"What's four times 23\")" ] @@ -328,7 +328,7 @@ "# Note: the `.map()` at the end of `multiply` allows us to pass in a list of `multiply` arguments instead of a single one.\n", "chain = (\n", " model_with_tools\n", - " | JsonOutputKeyToolsParser(key_name=\"multiply\", return_single=True)\n", + " | JsonOutputKeyToolsParser(key_name=\"multiply\", first_tool_only=True)\n", " | multiply\n", ")\n", "chain.invoke(\"What's four times 23\")" diff --git a/docs/docs/use_cases/tool_use/tool_error_handling.ipynb b/docs/docs/use_cases/tool_use/tool_error_handling.ipynb index fe999816b0..c129b0ebee 100644 --- a/docs/docs/use_cases/tool_use/tool_error_handling.ipynb +++ b/docs/docs/use_cases/tool_use/tool_error_handling.ipynb @@ -116,7 +116,7 @@ "\n", "chain = (\n", " model_with_tools\n", - " | JsonOutputKeyToolsParser(key_name=\"complex_tool\", return_single=True)\n", + " | JsonOutputKeyToolsParser(key_name=\"complex_tool\", first_tool_only=True)\n", " | complex_tool\n", ")" ] @@ -190,7 +190,7 @@ "\n", "chain = (\n", " model_with_tools\n", - " | JsonOutputKeyToolsParser(key_name=\"complex_tool\", return_single=True)\n", + " | JsonOutputKeyToolsParser(key_name=\"complex_tool\", first_tool_only=True)\n", " | try_except_tool\n", ")" ] @@ -255,7 +255,7 @@ "source": [ "chain = (\n", " model_with_tools\n", - " | JsonOutputKeyToolsParser(key_name=\"complex_tool\", return_single=True)\n", + " | JsonOutputKeyToolsParser(key_name=\"complex_tool\", first_tool_only=True)\n", " | complex_tool\n", ")\n", "better_model = ChatOpenAI(model=\"gpt-4-1106-preview\", temperature=0).bind_tools(\n", @@ -263,7 +263,7 @@ ")\n", "better_chain = (\n", " better_model\n", - " | JsonOutputKeyToolsParser(key_name=\"complex_tool\", return_single=True)\n", + " | JsonOutputKeyToolsParser(key_name=\"complex_tool\", first_tool_only=True)\n", " | complex_tool\n", ")\n", "\n", @@ -355,7 +355,7 @@ " prompt\n", " | model_with_tools\n", " | JsonOutputKeyToolsParser(\n", - " key_name=\"complex_tool\", return_id=True, return_single=True\n", + " key_name=\"complex_tool\", return_id=True, first_tool_only=True\n", " )\n", " | tool_custom_exception\n", ")\n",