3 ms·
LangChain Decorators – syntactic sugar for langchain
- ju-bezdek 3y agoHi folks... wanted to share a little pet project of mine ... LangChain Decorators adds syntactic sugar for langchain Main principles and benefits: - more pythonic way of writing code - write multiline prompts that won't 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 How it works... tl;dr; just write declare a function and write your prompt template as python docstring... for example: @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 it'will turn the function into an executable chain all the other settings are considered as an implementation detail and as such you can define them elsewhere (and/or override them in decorator params)
- jstx1 3y agoSugar on top of sugar. I don't see the point of this or langchain itself when I can call the underlying model API directly in a way that's convenient for me.