Package com.intellijava.core.controller
Class RemoteLanguageModel
java.lang.Object
com.intellijava.core.controller.RemoteLanguageModel
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 Summary
ConstructorDescriptionRemoteLanguageModel
(String keyValue, SupportedLangModels keyType) Constructor for the RemoteLanguageModel class.RemoteLanguageModel
(String keyValue, String keyTypeString) Constructor for the RemoteLanguageModel class. -
Method Summary
Modifier and TypeMethodDescriptiongenerateMultiText
(LanguageModelInput langInput) Call a remote large model to generate any text based on the received prompt.generateText
(LanguageModelInput langInput) Call a remote large model to generate any text based on the received prompt.Get the supported models names as array of string
-
Constructor Details
-
RemoteLanguageModel
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
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
Get the supported models names as array of string- Returns:
- supportedModels
-
generateText
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
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".
-