07. Runnable
# .env Read a file and set it as an environment variable
from dotenv import load_dotenv
# load token information
load_dotenv()Copy
TrueCopy
# Set up LangSmith tracking. https://smith.langchain.com
# !pip install -qU langchain-teddynote
from langchain_teddynote import logging
# Enter a project name.
logging.langsmith("CH01-Basic")Copy
Start tracking LangSmith.
[project name]
CH01-BasicHow to effectively convey data
RunnablePassthroughcan be passed without changing the input or by adding additional keys.RunnablePassthrough()When called alone, it simply takes input and passes it on as is.RunnablePassthrough.assign(...)When called in this way, it takes input and adds any additional arguments passed to the assign function.
RunnablePassthrough
Copy
chain 을 invoke() When executing, the input data type must be a dictionary.
Copy
Copy
However, with the update of the langchain library, it is also possible to pass only the value if the template contains only one variable.
Copy
Copy
Below is an example using RunnablePassthrough.w
RunnablePassthrough is a runnable object, and a runnable object can be executed separately using the invoke() method.
Copy
Copy
Below is an example of constructing a chain with RunnablePassthrough.
Copy
Copy
다음은 RunnablePassthrough.assign() The results are compared with when using .
Copy
Copy
RunnablePassthrough.assign()
Merges the key/value pairs of the values passed as input values with the newly assigned key/value pairs.
Copy
Copy
RunnableParallel
Copy
Copy
Chain can also apply RunnableParallel.
Copy
Copy
Copy
RunnableLambda
You can map your own custom functions using RunnableLambda.
Copy
Copy
Copy
Copy
Copy
Use itemgetter to extract a specific key.
Copy
Copy
Copy
Last updated