raised to the third plus seven equals 12"))    EQUATION: x^3 + 7 = 12        Attaching OpenAI functions‚ÄãOne particularly useful application of binding is to attach OpenAI functions to a compatible OpenAI model:functions = [    {      "name": "solver",      "description": "Formulates and solves an equation",      "parameters": {        "type": "object",        "properties": {          "equation": {            "type": "string",            "description": "The algebraic expression of the equation"          },          "solution": {            "type": "string",            "description": "The solution to the equation"          }        },        "required": ["equation", "solution"]      }    }  ]# Need gpt-4 to solve this one correctlyprompt = ChatPromptTemplate.from_messages(    [        ("system", "Write out the following equation using algebraic symbols then solve it."),        ("human", "{equation_statement}")    ])model = ChatOpenAI(model="gpt-4", temperature=0).bind(function_call={"name": "solver"}, functions=functions)runnable = (    {"equation_statement": RunnablePassthrough()}     | prompt     | model)runnable.invoke("x raised to the third plus seven equals 12")    AIMessage(content='', additional_kwargs={'function_call': {'name': 'solver', 'arguments': '{\n"equation": "x^3 + 7 = 12",\n"solution": "x = ‚àõ5"\n}'}}, example=False)PreviousHow toNextConfigurable AlternativesAttaching OpenAI functionsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.
Sometimes we want to invoke a Runnable within a Runnable sequence with constant arguments that are not part of the output of the preceding Runnable in the sequence, and which are not part of the user input. We can use Runnable.bind() to easily pass these arguments in.
Sometimes we want to invoke a Runnable within a Runnable sequence with constant arguments that are not part of the output of the preceding Runnable in the sequence, and which are not part of the user input. We can use Runnable.bind() to easily pass these arguments in. ->: raised to the third plus seven equals 12"))    EQUATION: x^3 + 7 = 12        Attaching OpenAI functions‚ÄãOne particularly useful application of binding is to attach OpenAI functions to a compatible OpenAI model:functions = [    {      "name": "solver",      "description": "Formulates and solves an equation",      "parameters": {        "type": "object",        "properties": {          "equation": {            "type": "string",            "description": "The algebraic expression of the equation"          },          "solution": {            "type": "string",            "description": "The solution to the equation"          }        },        "required": ["equation", "solution"]      }    }  ]# Need gpt-4 to solve this one correctlyprompt = ChatPromptTemplate.from_messages(    [        ("system", "Write out the following equation using algebraic symbols then solve it."),        ("human", "{equation_statement}")    ])model = ChatOpenAI(model="gpt-4", temperature=0).bind(function_call={"name": "solver"}, functions=functions)runnable = (    {"equation_statement": RunnablePassthrough()}     | prompt     | model)runnable.invoke("x raised to the third plus seven equals 12")    AIMessage(content='', additional_kwargs={'function_call': {'name': 'solver', 'arguments': '{\n"equation": "x^3 + 7 = 12",\n"solution": "x = ‚àõ5"\n}'}}, example=False)PreviousHow toNextConfigurable AlternativesAttaching OpenAI functionsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.