@@ -134,8 +134,10 @@ private void initiate(String keyValue, SupportedLangModels keyType) {
134134 *
135135 * Call a remote large model to generate any text based on the received prompt.
136136 *
137- * @param langInput flexible builder for language model parameters .
137+ * To support multiple response call the variation function generateMultiText .
138138 *
139+ * @param langInput flexible builder for language model parameters.
140+ *
139141 * @return string for the model response.
140142 * @throws IOException if there is an error when connecting to the
141143 * OpenAI API.
@@ -158,6 +160,35 @@ public String generateText(LanguageModelInput langInput) throws IOException {
158160 }
159161
160162 }
163+
164+ /**
165+ *
166+ * Call a remote large model to generate any text based on the received prompt.
167+ *
168+ * @param langInput flexible builder for language model parameters.
169+ *
170+ * @return List<String> for the model responses.
171+ * @throws IOException if there is an error when connecting to the
172+ * OpenAI API.
173+ * @throws IllegalArgumentException if the keyType passed in the constructor is
174+ * not "openai".
175+ *
176+ */
177+ public List <String > generateMultiText (LanguageModelInput langInput ) throws IOException {
178+
179+ if (this .keyType .equals (SupportedLangModels .openai )) {
180+ return this .generateOpenaiText (langInput .getModel (),
181+ langInput .getPrompt (), langInput .getTemperature (),
182+ langInput .getMaxTokens (), langInput .getNumberOfOutputs ());
183+ } else if (this .keyType .equals (SupportedLangModels .cohere )) {
184+ return this .generateCohereText (langInput .getModel (),
185+ langInput .getPrompt (), langInput .getTemperature (),
186+ langInput .getMaxTokens (), langInput .getNumberOfOutputs ());
187+ } else {
188+ throw new IllegalArgumentException ("This version support openai keyType only" );
189+ }
190+
191+ }
161192
162193 /**
163194 * Private helper method for generating text from OpenAI GPT-3 model.
0 commit comments