03. RunnableLambda

RunnableLambda has Run custom functions It provides the ability to do it.

Through this, the developer Define your own function (D) RunnableLambda You can run it using

For example, you can define and run functions that perform tasks such as data preprocessing, calculation, or interaction with external APIs.

How to run custom functions

caution

Custom function RunnableLambda You can use it by wrapping it, but the point to watch out for here There is only one factor that a custom function can receive is.

If you want to implement it as a function that receives multiple arguments, you need to write a wrapper that accepts a single input and releases it with multiple arguments.

Copy

# Configuration file for managing API keys as environment variables
from dotenv import load_dotenv

# Load API key information
load_dotenv()

Copy

 True 

Copy

# LangSmith set up trackingww. https://smith.langchain.com
# !pip install langchain-teddynote
from langchain_teddynote import logging

# Enter a project name.
logging.langsmith("LCEL-Advanced")

Copy

Copy

Run chain to confirm the result.

Copy

Copy

RunnableConfig factor

RunnableLambda optionally RunnableConfig Can accommodate

This allows you to pass callbacks, tags, and other configuration information to nested runs.

Copy

Copy

Copy

Copy

Copy

Last updated