Class HibernateContentRetriever.HibernateContentRetrieverBuilder

java.lang.Object
dev.langchain4j.rag.content.retriever.hibernate.HibernateContentRetriever.HibernateContentRetrieverBuilder
Enclosing class:
HibernateContentRetriever

public static class HibernateContentRetriever.HibernateContentRetrieverBuilder extends Object
  • Method Details

    • sessionFactory

      public HibernateContentRetriever.HibernateContentRetrieverBuilder sessionFactory(org.hibernate.SessionFactory sessionFactory)
      Sets the SessionFactory to be used for executing HQL queries and extracting the metamodel. This is a mandatory parameter (either this or entityManagerFactory(EntityManagerFactory) must be set).
      Parameters:
      sessionFactory - the Hibernate SessionFactory
      Returns:
      this builder
    • entityManagerFactory

      public HibernateContentRetriever.HibernateContentRetrieverBuilder entityManagerFactory(jakarta.persistence.EntityManagerFactory entityManagerFactory)
      Sets the EntityManagerFactory to be used for executing HQL queries and extracting the metamodel. The provided EntityManagerFactory will be unwrapped to a Hibernate SessionFactory. This is a mandatory parameter (either this or sessionFactory(SessionFactory) must be set).
      Parameters:
      entityManagerFactory - the Jakarta Persistence EntityManagerFactory
      Returns:
      this builder
    • chatModel

      Sets the ChatModel to be used for generating HQL queries from natural language. This is a mandatory parameter.
      Parameters:
      chatModel - the ChatModel to use
      Returns:
      this builder
    • databaseStructure

      public HibernateContentRetriever.HibernateContentRetrieverBuilder databaseStructure(String databaseStructure)
      Sets the structure of the entity model, which will be provided to the LLM in the system message. The LLM should be familiar with available entities, attributes, relationships, etc. in order to generate valid HQL queries. This is an optional parameter. If not specified, it will be automatically generated from the SessionFactory's runtime metamodel (recommended).
      Parameters:
      databaseStructure - a string representation of the entity model structure
      Returns:
      this builder
    • promptTemplate

      Sets the PromptTemplate to be used for creating the system message. The template can use the {{databaseStructure}} variable, which will be replaced with the entity model structure. This is an optional parameter. Default: HibernateContentRetriever.DEFAULT_PROMPT_TEMPLATE.
      Parameters:
      promptTemplate - the PromptTemplate to use
      Returns:
      this builder
    • maxRetries

      Sets the maximum number of retries to perform if Hibernate cannot execute the generated HQL query. On each retry, the error message will be sent back to the LLM to try correcting the query. This is an optional parameter. Default: 0.
      Parameters:
      maxRetries - the maximum number of retries
      Returns:
      this builder
    • build

      public HibernateContentRetriever build()
      Builds a new HibernateContentRetriever instance with the configured parameters.
      Returns:
      a new HibernateContentRetriever
    • toString

      public String toString()
      Overrides:
      toString in class Object