LangChain4J CDI
LangChain4J CDI 可将 AI 服务直接注入到你的 Jakarta EE 和 MicroProfile 应用中。
文档
完整文档见 langchain4j.github.io/langchain4j-cdi。
功能
- AI Service 注入 — 使用
@RegisterAIService将 AI 服务声明为 CDI bean - Agentic 拓扑 — 11 个按拓扑划分的注解(
@RegisterSimpleAgent、@RegisterSequenceAgent、@RegisterLoopAgent等),用于多智能体工作流 - MCP Server — 将 CDI bean 暴露为 Model Context Protocol 服务器
- 通过 Properties 配置 — 通过 MicroProfile Config 或自定义 SPI 配置 LLM 组件
- 容错(Fault Tolerance) — 使用
@Retry、@Timeout、@CircuitBreaker、@Fallback实现弹性 - 遥测(Telemetry) — 基于 OpenTelemetry 的 AI 操作可观测性
- 表达式语言 — 在注 解中解析
${...}(MicroProfile Config)和#{...}(Jakarta EL)表达式 - Guardrails — 对 AI 服务交互进行输入与输出校验
支持的运行时
| Runtime | Extension Type |
|---|---|
| Quarkus | Build-compatible |
| Helidon | Both |
| WildFly | Portable |
| Payara | Portable |
| GlassFish | Portable |
| Liberty | Portable |
关于 LangChain4j CDI 功能的详细说明与用法,请参阅 LangChain4J CDI 文档。