Class GPTDictationServiceImpl
- java.lang.Object
 - 
- com.composum.ai.backend.base.service.chat.impl.GPTDictationServiceImpl
 
 
- 
- All Implemented Interfaces:
 GPTDictationService
public class GPTDictationServiceImpl extends Object implements GPTDictationService
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGPTDictationServiceImpl.GPTDictationServiceConfigConfigures whether it's enabled (default false), the model and the request counts, and the maximum request size.protected classGPTDictationServiceImpl.LimitedInputStream 
- 
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_MAX_REQUEST_SIZEprotected static StringDEFAULT_MODELprotected static intDEFAULTVALUE_REQUESTS_PER_DAYprotected static intDEFAULTVALUE_REQUESTS_PER_HOURprotected static intDEFAULTVALUE_REQUESTS_PER_MINUTEprotected booleanenabledprotected org.apache.hc.client5.http.impl.classic.CloseableHttpClienthttpClientprotected RateLimiterlimiterprotected longmaxRequestSizeprotected Stringmodelprotected GPTInternalOpenAIHelperopenAIHelperstatic StringURL_OPENAI_TRANSCRIPTIONS 
- 
Constructor Summary
Constructors Constructor Description GPTDictationServiceImpl() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactivate(GPTDictationServiceImpl.GPTDictationServiceConfig config)protected voiddeactivate()booleanisAvailable(GPTConfiguration configuration)Whether the service is enabled and properly configured.protected voidmodified(GPTDictationServiceImpl.GPTDictationServiceConfig config)Stringtranscribe(InputStream audioStream, String contentType, String language, GPTConfiguration configuration, String prompt)Transcribes the input audio to text. 
 - 
 
- 
- 
Field Detail
- 
URL_OPENAI_TRANSCRIPTIONS
public static final String URL_OPENAI_TRANSCRIPTIONS
- See Also:
 - Constant Field Values
 
 
- 
DEFAULTVALUE_REQUESTS_PER_MINUTE
protected static final int DEFAULTVALUE_REQUESTS_PER_MINUTE
- See Also:
 - Constant Field Values
 
 
- 
DEFAULTVALUE_REQUESTS_PER_HOUR
protected static final int DEFAULTVALUE_REQUESTS_PER_HOUR
- See Also:
 - Constant Field Values
 
 
- 
DEFAULTVALUE_REQUESTS_PER_DAY
protected static final int DEFAULTVALUE_REQUESTS_PER_DAY
- See Also:
 - Constant Field Values
 
 
- 
DEFAULT_MODEL
protected static final String DEFAULT_MODEL
- See Also:
 - Constant Field Values
 
 
- 
DEFAULT_MAX_REQUEST_SIZE
protected static final int DEFAULT_MAX_REQUEST_SIZE
- See Also:
 - Constant Field Values
 
 
- 
httpClient
protected org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient
 
- 
limiter
protected RateLimiter limiter
 
- 
enabled
protected boolean enabled
 
- 
model
protected String model
 
- 
maxRequestSize
protected long maxRequestSize
 
- 
openAIHelper
protected GPTInternalOpenAIHelper openAIHelper
 
 - 
 
- 
Method Detail
- 
activate
protected void activate(GPTDictationServiceImpl.GPTDictationServiceConfig config) throws URISyntaxException
- Throws:
 URISyntaxException
 
- 
deactivate
protected void deactivate() throws IOException- Throws:
 IOException
 
- 
modified
protected void modified(GPTDictationServiceImpl.GPTDictationServiceConfig config) throws IOException, URISyntaxException
- Throws:
 IOExceptionURISyntaxException
 
- 
isAvailable
public boolean isAvailable(@Nullable GPTConfiguration configuration)
Description copied from interface:GPTDictationServiceWhether the service is enabled and properly configured.- Specified by:
 isAvailablein interfaceGPTDictationService
 
- 
transcribe
public String transcribe(@Nonnull InputStream audioStream, @Nonnull String contentType, @Nullable String language, @Nullable GPTConfiguration configuration, @Nullable String prompt)
Description copied from interface:GPTDictationServiceTranscribes the input audio to text.- Specified by:
 transcribein interfaceGPTDictationService- Parameters:
 audioStream- the audio stream to transcribe, will be closedcontentType- the content type of the audio, e.g. "audio/mpeg" for mp3, "audio/wav" for wavlanguage- the language code to use, e.g. "en" for English, or null for automatic detectionconfiguration- the configuration to use, or null for the default configurationprompt- an optional prompt to give the AI some context, e.g. previous sentences
 
 - 
 
 -