Package de.espirit.firstspirit.ai
Interface GenerativeAIConnector
- All Known Subinterfaces:
GenerativeAIAgent
,GenerativeAIConnectorPlugin
@Experimental
public interface GenerativeAIConnector
Agent for performing GPT completion requests.
- Since:
- 5.2.240708
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks whether this functionality is available, which depends on a configured API key in the GPT service configuration.default @NotNull ResponseStream
openStream
(@NotNull Request request) Initiates a streamed completions request, if supported by the configured API connector.@NotNull Response
Performs 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:
true
if this functionality is available,false
otherwise.- 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 ofGenerativeAIConnectorPlugin
is 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
-