TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

LangChain Decorators – syntactic sugar for langchain

2 点作者 ju-bezdek将近 2 年前

2 条评论

jstx1将近 2 年前
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-bezdek将近 2 年前
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)