Class ChatGPT

java.lang.Object
com.logicaldoc.chatgpt.ChatGPT
All Implemented Interfaces:
Closeable, AutoCloseable

public class ChatGPT extends Object implements Closeable
This is a facade over the Remote ChatGPT service. You instantiate this object on a population of documents and then you may ask questions about them
Since:
8.9.4
Author:
Marco Meschieri - LogicalDOC
  • Constructor Details

    • ChatGPT

      public ChatGPT(String apiKey)
    • ChatGPT

      public ChatGPT(String apiKey, String model)
  • Method Details

    • get

      public static ChatGPT get(long userId) throws com.logicaldoc.core.PersistenceException, com.logicaldoc.util.security.StringEncrypter.EncryptionException
      Throws:
      com.logicaldoc.core.PersistenceException
      com.logicaldoc.util.security.StringEncrypter.EncryptionException
    • getModel

      public String getModel()
    • setModel

      public void setModel(String model)
    • getApiKey

      public String getApiKey()
    • getAssistantId

      public String getAssistantId()
    • setApiKey

      public void setApiKey(String apiKey)
    • setAssistantId

      public void setAssistantId(String assistantId)
    • prepareThread

      public void prepareThread() throws IOException
      Throws:
      IOException
    • ask

      public String ask(String question) throws IOException
      Asks a question and waits for the full answer
      Parameters:
      question - The question to ask
      Returns:
      The complete answer
      Throws:
      IOException - Communication error
    • askAsync

      public Future<org.apache.hc.core5.http.HttpResponse> askAsync(String question, ResponseConsumer consumer) throws IOException
      Asynchronously asks a question
      Parameters:
      question - The question to ask
      consumer - The consumer that receives the answer chunks
      Returns:
      The Future task you may wait for the completion
      Throws:
      IOException - Communication error
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • saveSettings

      public void saveSettings(long userId) throws com.logicaldoc.core.PersistenceException, com.logicaldoc.util.security.StringEncrypter.EncryptionException
      Saves the current settings in the user's profile
      Parameters:
      userId - The current user
      Throws:
      com.logicaldoc.core.PersistenceException - Error in the data layer
      com.logicaldoc.util.security.StringEncrypter.EncryptionException - Error encrypting the API key
    • getDocuments

      public List<com.logicaldoc.core.document.Document> getDocuments()