public class AIDataService extends Object
| Constructor and Description |
|---|
AIDataService(AIConfiguration config)
Create new service with unique context for given configuration
|
AIDataService(AIConfiguration config,
AIServiceContext serviceContext)
Create new service for given configuration and some predefined service context
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
doSoundRequest(InputStream voiceStream,
String queryData)
Method extracted for testing purposes
|
protected String |
doSoundRequest(InputStream voiceStream,
String queryData,
Map<String,String> additionalHeaders)
Method extracted for testing purposes
|
protected String |
doTextRequest(String requestJson) |
protected String |
doTextRequest(String endpoint,
String requestJson) |
protected String |
doTextRequest(String endpoint,
String requestJson,
Map<String,String> additionalHeaders) |
AIServiceContext |
getContext() |
AIResponse |
request(AIRequest request)
Make request to the ai service.
|
AIResponse |
request(AIRequest request,
RequestExtras requestExtras)
Make request to the ai service.
|
boolean |
resetContexts()
Forget all old contexts
|
AIResponse |
uploadUserEntities(Collection<Entity> userEntities) |
AIResponse |
uploadUserEntity(Entity userEntity) |
AIResponse |
voiceRequest(InputStream voiceStream)
Make requests to the ai service with voice data.
|
AIResponse |
voiceRequest(InputStream voiceStream,
List<AIContext> aiContexts)
Make requests to the ai service with voice data.
|
AIResponse |
voiceRequest(InputStream voiceStream,
RequestExtras requestExtras)
Make requests to the ai service with voice data.
|
public AIDataService(AIConfiguration config, AIServiceContext serviceContext)
config - Service configuration data. Cannot be nullserviceContext - Service context. If null then new context will be createdIllegalArgumentException - If config parameter is nullpublic AIDataService(AIConfiguration config)
config - Service configuration data. Cannot be nullIllegalArgumentException - If config parameter is nullpublic AIServiceContext getContext()
nullpublic AIResponse request(AIRequest request) throws AIServiceException
request - request object to the service. Cannot be nullnullAIServiceExceptionpublic AIResponse request(AIRequest request, RequestExtras requestExtras) throws AIServiceException
request - request object to the service. Cannot be nullnullAIServiceExceptionpublic AIResponse voiceRequest(InputStream voiceStream) throws AIServiceException
voiceStream - voice data stream for recognition. Cannot be nullnullAIServiceExceptionpublic AIResponse voiceRequest(InputStream voiceStream, List<AIContext> aiContexts) throws AIServiceException
voiceStream - voice data stream for recognition. Cannot be nullaiContexts - additional contexts for requestnullAIServiceExceptionpublic AIResponse voiceRequest(InputStream voiceStream, RequestExtras requestExtras) throws AIServiceException
voiceStream - voice data stream for recognition. Cannot be nullrequestExtras - object that can hold additional contexts and entitiesnullAIServiceExceptionpublic boolean resetContexts()
public AIResponse uploadUserEntity(Entity userEntity) throws AIServiceException
AIServiceExceptionpublic AIResponse uploadUserEntities(Collection<Entity> userEntities) throws AIServiceException
AIServiceExceptionprotected String doTextRequest(String requestJson) throws MalformedURLException, AIServiceException
protected String doTextRequest(String endpoint, String requestJson) throws MalformedURLException, AIServiceException
protected String doTextRequest(String endpoint, String requestJson, Map<String,String> additionalHeaders) throws MalformedURLException, AIServiceException
endpoint - Cannot be nullrequestJson - Cannot be nulladditionalHeaders - MalformedURLExceptionAIServiceExceptionprotected String doSoundRequest(InputStream voiceStream, String queryData) throws MalformedURLException, AIServiceException
voiceStream - Cannot be nullqueryData - Cannot be nullMalformedURLExceptionAIServiceExceptionprotected String doSoundRequest(InputStream voiceStream, String queryData, Map<String,String> additionalHeaders) throws MalformedURLException, AIServiceException
voiceStream - Cannot be nullqueryData - Cannot be nullMalformedURLExceptionAIServiceExceptionCopyright © 2016. All rights reserved.