TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

LangChain Decorators – syntactic sugar for langchain

2 pointsby ju-bezdekalmost 2 years ago

2 comments

jstx1almost 2 years ago
Sugar 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.
ju-bezdekalmost 2 years ago
Hi folks... wanted to share a little pet project of mine ... LangChain Decorators adds syntactic sugar for langchain Main principles and benefits:<p>- more pythonic way of writing code - write multiline prompts that won&#x27;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 &#x27; LangChain ecosystem - adding support for optional parameters easily share parameters between the prompts by binding them to one class<p>How it works...<p>tl;dr;<p>just write declare a function and write your prompt template as python docstring...<p>for example:<p>@llm_prompt def write_me_short_post(topic:str, platform:str=&quot;twitter&quot;, audience:str = &quot;developers&quot;)-&gt;str: &quot;&quot;&quot; Write me a short header for my post about {topic} for {platform} platform. It should be for {audience} audience. (Max 15 words) &quot;&quot;&quot; return<p>it&#x27;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&#x2F;or override them in decorator params)