.md
.pdf
LangChain Decorators ✨
 Contents 
LangChain Decorators ✨
Quick start
Installation
Examples
Defining other parameters
Passing a memory and/or callbacks:
Simplified streaming
Prompt declarations
Documenting your prompt
Chat messages prompt
Optional sections
Output parsers
More complex structures
Binding the prompt to an object
More examples:
LangChain Decorators ✨#
lanchchain decorators is a layer on the top of LangChain that provides syntactic sugar 🍭 for writing custom langchain prompts and chains
For Feedback, Issues, Contributions - please raise an issue here:
ju-bezdek/langchain-decorators
Main principles and benefits:
more pythonic way of writing code
write multiline prompts that wont break your code flow with indentation
making use of IDE in-built support for hinting, type checking and popup with docs to quickly peek in the function to see the prompt, parameters it consumes etc.
leverage all the power of 🦜🔗 LangChain ecosystem
adding support for optional parameters
easily share parameters between the prompts by binding them to one class
Here is a simple example of a code written with LangChain Decorators ✨
@llm_prompt
def write_me_short_post(topic:str, platform:str="twitter", audience:str = "developers")->str:
    """
    Write me a short header for my post about {topic} for {platform} platform. 
    It should be for {audience} audience.
    (Max 15 words)
    """
    return
# run it naturaly
write_me_short_post(topic="starwars")
# or
write_me_short_post(topic="starwars", platform="redit")
Quick start#
Installation#
pip install langchain_decorators
Examples#
Good idea on how to start is to review the examples here:
jupyter notebook
rtdocs_stable/api.python.langchain.com/en/stable/integrations/langchain_decorators.html