展示HN:OxyJen – 一款用于以图形方式执行大语言模型(LLMs)的Java框架

2作者: bdivyansh11大约 1 个月前原帖
在过去的几个月里,我一直在构建 OxyJen,这是一个用于在 Java 中构建可靠的多步骤 AI 流水线的开源框架。在大多数 Java LLM 项目中,一切仍然只是字符串。你构建一个提示,发出调用,然后解析你的正则表达式,等待返回的“几乎是 JSON”的结果是否有效。这种方式脆弱、不易测试,感觉与 Java 的“契约优先”理念背道而驰。 OxyJen 的方法有所不同。它是一个基于图的编排框架(目前是顺序执行),在这个框架中,LLM 被视为流水线中的原生、可靠节点,而不是神奇的辅助工具。核心思想是为概率性 AI 调用带来确定性的可靠性。系统中的每个元素都是图中的一个节点,LLMNode、LLMChain、LLM API 被用来构建一个简单的 LLM 节点,支持重试/回退、抖动/退避和超时强制(目前支持 OpenAI)。 PromptTemplate、Variable(必需/可选)和 PromptRegistry 被用来构建和存储可重用的提示,避免你重复编写提示。 JSONSchema 和 SchemaGenerator 被用来从 POJOs/Records 构建模式,这将对这些 LLM 的输出提供 JSON 强制。SchemaNode<T> 封装了 SchemaEnforcer 和验证器,以便将 LLM 输出直接映射到类上。Enforcer 还确保你的输出是正确的,并进行最大重试。 目前正在开发 Tool API,以帮助用户在 OxyJen 中构建自定义工具。我现在是一个独立开发者,项目处于非常早期的阶段,因此我非常欢迎任何反馈和贡献(即使是文档中的小改进也会很有价值)。 OxyJen: [https://github.com/11divyansh/OxyJen](https://github.com/11divyansh/OxyJen)
查看原文
For the past few months, I&#x27;ve been building OxyJen, an open-source framework for building reliable, multi-step AI pipelines in Java. In most Java LLM projects, everything is still just strings. You build a prompt, make a call, and then parse your regex and wait if it works on the &quot;almost-JSON&quot; that comes back. It&#x27;s brittle, untestable, and feels like the opposite of Java&#x27;s &quot;contract-first&quot; philosophy.<p>OxyJen&#x27;s approach is different. It&#x27;s a graph-based orchestration framework(currently sequential) where LLMs are treated as native, reliable nodes in a pipeline, not as magical helper utilities. The core idea is to bring deterministic reliability to probabilistic AI calls. Everything is a node in a graph based system, LLMNode, LLMChain, LLM api is used to build a simple LLM node for the graph with retry&#x2F;fallback, jitter&#x2F;backoff, timeout enforcements(currently supports OpenAI).<p>PromptTemplate, Variable(required&#x2F;optional) and PromptRegistry is used to build and store reusable prompts which saves you from re writing prompts.<p>JSONSchema and SchemaGenerator is used to build schema from POJOs&#x2F;Records which will provide Json enforcements on outputs of these LLMs. SchemaNode&lt;T&gt; wraps SchemaEnforcer and validator to map LLM output directly to the classes. Enforcer also makes sure your output is correct and takes maximum retries.<p>Currently working on the Tool API to help users build their custom tools in Oxyjen. I&#x27;m a solo builder right now and the project is in its very early stage so I would really appreciate any feedback and contributions(even a small improvement in docs would be valuable).<p>OxyJen: <a href="https:&#x2F;&#x2F;github.com&#x2F;11divyansh&#x2F;OxyJen" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;11divyansh&#x2F;OxyJen</a>