Class RemoteLanguageModel

java.lang.Object
com.intellijava.core.controller.RemoteLanguageModel

public class RemoteLanguageModel extends Object
RemoteLanguageModel class to call the most sophisticated remote language models. This class support: - Openai: - url: openai.com - description: provides an API for interacting with OpenAI's GPT-3 language model. - model names : text-davinci-003, text-curie-001, text-babbage-001, more. - cohere: - url: cohere.ai - description: provides an API for interacting with generate language model. - it is recommended to fine tune your model or add example of the response in the prompt when calling cohere models. - model names : medium or xlarge
Author:
github.com/Barqawiz
  • Constructor Details

    • RemoteLanguageModel

      public RemoteLanguageModel(String keyValue, String keyTypeString)
      Constructor for the RemoteLanguageModel class. Creates an instance of the class and set the API type and key.
      Parameters:
      keyValue - the API key.
      keyTypeString - either openai (default) or cohere or send empty string for default value.
      Throws:
      IllegalArgumentException - if the keyType passed is not "openai".
    • RemoteLanguageModel

      public RemoteLanguageModel(String keyValue, SupportedLangModels keyType)
      Constructor for the RemoteLanguageModel class. Creates an instance of the class and set the API enum type and key.
      Parameters:
      keyValue - the API key.
      keyType - enum version from the key type (SupportedModels).
      Throws:
      IllegalArgumentException - if the keyType passed is not "openai".
  • Method Details

    • getSupportedModels

      public List<String> getSupportedModels()
      Get the supported models names as array of string
      Returns:
      supportedModels
    • generateText

      public String generateText(LanguageModelInput langInput) throws IOException
      Call a remote large model to generate any text based on the received prompt. To support multiple response call the variation function generateMultiText.
      Parameters:
      langInput - flexible builder for language model parameters.
      Returns:
      string for the model response.
      Throws:
      IOException - if there is an error when connecting to the OpenAI API.
      IllegalArgumentException - if the keyType passed in the constructor is not "openai".
    • generateMultiText

      public List<String> generateMultiText(LanguageModelInput langInput) throws IOException
      Call a remote large model to generate any text based on the received prompt.
      Parameters:
      langInput - flexible builder for language model parameters.
      Returns:
      list of model responses.
      Throws:
      IOException - if there is an error when connecting to the OpenAI API.
      IllegalArgumentException - if the keyType passed in the constructor is not "openai".