langchain4j/integration-tests/integration-tests-class-ins.../integration-tests-class-ins...
Eric Deandrea 023a65c044
Input and output guardrails (#2571)
Guardrails support.

I also introduced a new `langchain4j-test` module which can be a future
place to put in some testing utilities. For now I have several
assertj-based assertion classes that can be used for asserting
guardrails. (see
https://docs.quarkiverse.io/quarkus-langchain4j/dev/guardrails.html#_unit_testing
for current details).

Additionally, I've introduced a new `integration-tests` where we can
build various sets of test suites (think things that use/need
`ServiceLoader`s). This way we can test various implementations of
things for frameworks that may extend LangChain4j (Quarkus, Spring,
etc).

I've tried to include as much "genericism" as I can into this so that
downstream frameworks can re-use this without having to re-implement.

I'll have @geoand / @cescoffier review this too before merging.

## To-do list
- [x] Initial scaffolding for being able to define guardrails
- [x] Guardrail testing utilities
- [x] Wire guardrails into `AiService`s via annotations
- [x] Wire guardrails into `AiService`s using the builder
- [x] Handle output guardrails on streaming responses
- [x] Lots of tests
- [x] Documentation

Fixes #2549

---------

Co-authored-by: Lize Raes <49833622+LizeRaes@users.noreply.github.com>
Co-authored-by: Dmytro Liubarskyi <ljubarskij@gmail.com>
2025-06-17 11:49:54 +02:00
..
src Input and output guardrails (#2571) 2025-06-17 11:49:54 +02:00
README.md Input and output guardrails (#2571) 2025-06-17 11:49:54 +02:00
pom.xml Input and output guardrails (#2571) 2025-06-17 11:49:54 +02:00

README.md

Some integration tests for the ClassInstanceLoader, implemented with Spring.