Tools as OpenAI Functions | ü¶úÔ∏èüîó Langchain






Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsAgent TypesHow-toToolsDefining Custom ToolsHuman-in-the-loop Tool ValidationMulti-Input ToolsTool Input SchemaTools as OpenAI FunctionsToolkitsCallbacksModulesSecurityGuidesMoreModulesAgentsToolsTools as OpenAI FunctionsTools as OpenAI FunctionsThis notebook goes over how to use LangChain tools as OpenAI functions.from langchain.chat_models import ChatOpenAIfrom langchain.schema import HumanMessagemodel = ChatOpenAI(model="gpt-3.5-turbo-0613")from langchain.tools import MoveFileTool, format_tool_to_openai_functiontools = [MoveFileTool()]functions = [format_tool_to_openai_function(t) for t in tools]message = model.predict_messages(    [HumanMessage(content="move file foo to bar")], functions=functions)message    AIMessage(content='', additional_kwargs={'function_call': {'name': 'move_file', 'arguments': '{\n  "source_path": "foo",\n  "destination_path": "bar"\n}'}}, example=False)message.additional_kwargs["function_call"]    {'name': 'move_file',     'arguments': '{\n  "source_path": "foo",\n  "destination_path": "bar"\n}'}PreviousTool Input SchemaNextToolkitsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.
This notebook goes over how to use LangChain tools as OpenAI functions.
This notebook goes over how to use LangChain tools as OpenAI functions. ->: Tools as OpenAI Functions | ü¶úÔ∏èüîó Langchain






Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsAgent TypesHow-toToolsDefining Custom ToolsHuman-in-the-loop Tool ValidationMulti-Input ToolsTool Input SchemaTools as OpenAI FunctionsToolkitsCallbacksModulesSecurityGuidesMoreModulesAgentsToolsTools as OpenAI FunctionsTools as OpenAI FunctionsThis notebook goes over how to use LangChain tools as OpenAI functions.from langchain.chat_models import ChatOpenAIfrom langchain.schema import HumanMessagemodel = ChatOpenAI(model="gpt-3.5-turbo-0613")from langchain.tools import MoveFileTool, format_tool_to_openai_functiontools = [MoveFileTool()]functions = [format_tool_to_openai_function(t) for t in tools]message = model.predict_messages(    [HumanMessage(content="move file foo to bar")], functions=functions)message    AIMessage(content='', additional_kwargs={'function_call': {'name': 'move_file', 'arguments': '{\n  "source_path": "foo",\n  "destination_path": "bar"\n}'}}, example=False)message.additional_kwargs["function_call"]    {'name': 'move_file',     'arguments': '{\n  "source_path": "foo",\n  "destination_path": "bar"\n}'}PreviousTool Input SchemaNextToolkitsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.