Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toBind runtime argsConfigurable AlternativesAdd fallbacksRun arbitrary functionsUse RunnableParallel/RunnableMapRoute between multiple RunnablesCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesMoreLangChain Expression LanguageHow toBind runtime argsOn this pageBind runtime argsSometimes 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.Suppose we have a simple prompt + model sequence:from langchain.chat_models import ChatOpenAIfrom langchain.prompts import ChatPromptTemplatefrom langchain.schema import StrOutputParserfrom langchain.schema.runnable import RunnablePassthroughprompt = ChatPromptTemplate.from_messages(    [        ("system", "Write out the following equation using algebraic symbols then solve it. Use the format\n\nEQUATION:...\nSOLUTION:...\n\n"),        ("human", "{equation_statement}")    ])model = ChatOpenAI(temperature=0)runnable = {"equation_statement": RunnablePassthrough()} | prompt | model | StrOutputParser()print(runnable.invoke("x raised to the third plus seven equals 12"))    EQUATION: x^3 + 7 = 12        SOLUTION:    Subtracting 7 from both sides of the equation, we get:    x^3 = 12 - 7    x^3 = 5        Taking the cube root of both sides, we get:    x = ‚àõ5        Therefore, the solution to the equation x^3 + 7 = 12 is x = ‚àõ5.and want to call the model with certain stop words:runnable = (    {"equation_statement": RunnablePassthrough()}     | prompt     | model.bind(stop="SOLUTION")     | StrOutputParser())print(runnable.invoke("x raised to the
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. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toBind runtime argsConfigurable AlternativesAdd fallbacksRun arbitrary functionsUse RunnableParallel/RunnableMapRoute between multiple RunnablesCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesMoreLangChain Expression LanguageHow toBind runtime argsOn this pageBind runtime argsSometimes 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.Suppose we have a simple prompt + model sequence:from langchain.chat_models import ChatOpenAIfrom langchain.prompts import ChatPromptTemplatefrom langchain.schema import StrOutputParserfrom langchain.schema.runnable import RunnablePassthroughprompt = ChatPromptTemplate.from_messages(    [        ("system", "Write out the following equation using algebraic symbols then solve it. Use the format\n\nEQUATION:...\nSOLUTION:...\n\n"),        ("human", "{equation_statement}")    ])model = ChatOpenAI(temperature=0)runnable = {"equation_statement": RunnablePassthrough()} | prompt | model | StrOutputParser()print(runnable.invoke("x raised to the third plus seven equals 12"))    EQUATION: x^3 + 7 = 12        SOLUTION:    Subtracting 7 from both sides of the equation, we get:    x^3 = 12 - 7    x^3 = 5        Taking the cube root of both sides, we get:    x = ‚àõ5        Therefore, the solution to the equation x^3 + 7 = 12 is x = ‚àõ5.and want to call the model with certain stop words:runnable = (    {"equation_statement": RunnablePassthrough()}     | prompt     | model.bind(stop="SOLUTION")     | StrOutputParser())print(runnable.invoke("x raised to the