Package de.espirit.firstspirit.ai
Interface GenerativeAIConnector
- All Known Subinterfaces:
GenerativeAIAgent,GenerativeAIAgentConnector,GenerativeAIConnectorPlugin
@Experimental
public interface GenerativeAIConnector
Agent for performing GPT completion requests.
- Since:
- 5.2.240708
-
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether this functionality is available, which depends on a configured API key in the GPT service configuration.default @NotNull ResponseStreamopenStream(@NotNull Request request) Initiates a streamed completions request, if supported by the configured API connector.@NotNull ResponsePerforms a non-streamed completions request.Convenient method for performing a non-streamed text-based user prompt.
-
Method Details
-
isAvailable
boolean isAvailable()Checks whether this functionality is available, which depends on a configured API key in the GPT service configuration.- Returns:
trueif this functionality is available,falseotherwise.- Since:
- 5.2.240708
-
request
Performs a non-streamed completions request.- Parameters:
request- The request descriptor.- Returns:
- The completions response.
- Throws:
IOException- If the request failed for some reason.- Since:
- 5.2.240708
-
request
@NotNull default @NotNull Optional<String> request(@NotNull @NotNull String prompt) throws IOException Convenient method for performing a non-streamed text-based user prompt.- Parameters:
prompt- The user prompt to be sent.- Returns:
- The response text, if available.
- Throws:
IOException- If the request failed for some reason.- Since:
- 5.2.240708
-
openStream
@NotNull default @NotNull ResponseStream openStream(@NotNull @NotNull Request request) throws IOException Initiates a streamed completions request, if supported by the configured API connector. Any implementation ofGenerativeAIConnectorPluginis strongly encouraged to implement this method properly in order to enhance the user experience when interacting with the generative AI. By default, this method delegates torequest(String)and returns the response as singletonResponseStream.- Parameters:
request- The request descriptor.- Returns:
- The streamed response fragments as closeable iterator.
- Throws:
IOException- If the request failed for some reason.- Since:
- 5.2.240708
-