Interface StructuredOutputSchemaProvider

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface StructuredOutputSchemaProvider
Supplies the JSON schema sent to the chat model when an AiService or agent method returns the given type, instead of the schema LangChain4j derives reflectively.

When micronaut-json-schema-utils is on the classpath, a provider returns the schemas Micronaut JSON Schema generated at compile time for the types annotated with io.micronaut.jsonschema.JsonSchema. Register a bean of this type to supply schemas from another source; providers are consulted in order.

Since:
2.4.0
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull Optional<dev.langchain4j.model.chat.request.json.JsonSchemaElement>
    findSchema(@NonNull Class<?> type)
    Finds the schema of a structured output type.
  • Method Details

    • findSchema

      @NonNull Optional<dev.langchain4j.model.chat.request.json.JsonSchemaElement> findSchema(@NonNull Class<?> type)
      Finds the schema of a structured output type.
      Parameters:
      type - The type returned by the service method (the element type for a List or Set)
      Returns:
      The schema of the type, or empty to let LangChain4j derive it