07. Runnable configuration with @chain decorator
Runnable configuration using @chain decorator
@chain You can add a decorator to transform any function into a chain.
This is a function RunnableLambda Functionally the same as wrapping with.
Let's look at the actual behavior!
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 tracking. https://smith.langchain.com
# !pip install langchain-teddynote
from langchain_teddynote import logging
# Enter a project name.
logging.langsmith("LCEL-Advanced")Copy
Copy
ChatPromptTemplate Define two prompt templates using classes.
prompt1A short description of the subject given,prompt2is a request prompt to translate in English.
Copy
custom_chain Functions execute custom chains based on input text.
@chainDecorate a custom function with a decorator, and the function through decoratingRunnableMake it an object.
Copy
custom_chain is now a viable object runnable ), invoke() I need to run it using
Check out the LangSmith tracking record,
custom_chainThere will be tracking information, and below that, OpenAI calls will be nested.
Copy
Copy
Last updated