Class ChatParameterUtils

java.lang.Object
com.hw.openai.utils.ChatParameterUtils

public class ChatParameterUtils extends Object
Utility class to generate a structured ChatParameter object based on a given Java class. It leverages Jackson's annotations to customize the JSON output per field.

The class is responsible for inspecting a Java class for specific annotations, then generating a corresponding ChatParameter which follows certain schema conventions, such as the inclusion of types, descriptions, and required fields.

Note: This utility requires that the Java class be annotated with Jackson annotations.

Author:
HamaWhite
  • Constructor Details

    • ChatParameterUtils

      public ChatParameterUtils()
  • Method Details

    • generate

      public static ChatFunction.ChatParameter generate(Class<?> clazz)
      Generates a ChatFunction.ChatParameter instance that represents the given class schema in the form of a ChatParameter object.

      This method analyzes all declared fields of the provided class and their annotations to produce the appropriate JSON Schema based representation.

      Parameters:
      clazz - The class to be converted into a ChatParameter representation.
      Returns:
      The ChatFunction.ChatParameter instance representing the JSON Schema of the provided class.