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 |
|---|---|
String |
addActiveContext(AIContext context)
Adds new active context for a session
|
String |
addActiveContext(AIContext context,
AIServiceContext serviceContext)
Adds new active context for a session
|
List<String> |
addActiveContext(Iterable<AIContext> contexts)
Adds new active contexts for a session
|
List<String> |
addActiveContext(Iterable<AIContext> contexts,
AIServiceContext serviceContext)
Adds new active contexts for a session
|
protected <TRequest,TResponse> |
doRequest(TRequest request,
Type responseType,
String endpoint,
String method) |
protected <TRequest,TResponse> |
doRequest(TRequest request,
Type responseType,
String endpoint,
String method,
Map<String,String> additionalHeaders) |
protected <TResponse> |
doRequest(Type responseType,
String endpoint,
String method) |
protected <TResponse> |
doRequest(Type responseType,
String endpoint,
String method,
Map<String,String> additionalHeaders) |
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 |
doSoundRequest(InputStream voiceStream,
String queryData,
Map<String,String> additionalHeaders,
AIServiceContext serviceContext)
Method extracted for testing purposes
|
protected String |
doTextRequest(String requestJson) |
protected String |
doTextRequest(String requestJson,
AIServiceContext serviceContext) |
protected String |
doTextRequest(String endpoint,
String requestJson) |
protected String |
doTextRequest(String endpoint,
String requestJson,
Map<String,String> additionalHeaders) |
AIContext |
getActiveContext(String contextName)
Retrieves the specified context for a session
|
AIContext |
getActiveContext(String contextName,
AIServiceContext serviceContext)
Retrieves the specified context for a session
|
List<AIContext> |
getActiveContexts()
Retrieves the list of all currently active contexts for a session
|
List<AIContext> |
getActiveContexts(AIServiceContext serviceContext)
Retrieves the list of all currently active contexts for a session
|
AIServiceContext |
getContext() |
boolean |
removeActiveContext(String contextName)
Deletes the specified context for a session
|
boolean |
removeActiveContext(String contextName,
AIServiceContext serviceContext)
Deletes the specified context for a session
|
AIResponse |
request(AIRequest request)
Make request to the AI service.
|
AIResponse |
request(AIRequest request,
AIServiceContext serviceContext)
Make request to the AI service.
|
AIResponse |
request(AIRequest request,
RequestExtras requestExtras)
Make request to the AI service.
|
AIResponse |
request(AIRequest request,
RequestExtras requestExtras,
AIServiceContext serviceContext)
Make request to the AI service.
|
void |
resetActiveContexts()
Deletes all active contexts for a session
|
void |
resetActiveContexts(AIServiceContext serviceContext)
Deletes all active contexts for a session
|
boolean |
resetContexts()
Deprecated.
|
AIResponse |
uploadUserEntities(Collection<Entity> userEntities)
Add a bunch of new entity to an agent entity list
|
AIResponse |
uploadUserEntities(Collection<Entity> userEntities,
AIServiceContext serviceContext)
Add a bunch of new entity to an agent entity list
|
AIResponse |
uploadUserEntity(Entity userEntity)
Add new entity to an agent entity list
|
AIResponse |
uploadUserEntity(Entity userEntity,
AIServiceContext serviceContext)
Add new entity to an agent entity list
|
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.
|
AIResponse |
voiceRequest(InputStream voiceStream,
RequestExtras requestExtras,
AIServiceContext serviceContext)
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, AIServiceContext serviceContext) throws AIServiceException
request - request object to the service. Cannot be nullserviceContext - custom service context that should be used instead of the default contextnullAIServiceExceptionpublic AIResponse request(AIRequest request, RequestExtras requestExtras) throws AIServiceException
request - request object to the service. Cannot be nullrequestExtras - object that can hold additional contexts and entitiesnullAIServiceExceptionpublic AIResponse request(AIRequest request, RequestExtras requestExtras, AIServiceContext serviceContext) throws AIServiceException
request - request object to the service. Cannot be nullrequestExtras - object that can hold additional contexts and entitiesserviceContext - custom service context that should be used instead of the default contextnullAIServiceExceptionpublic 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 AIResponse voiceRequest(InputStream voiceStream, RequestExtras requestExtras, AIServiceContext serviceContext) throws AIServiceException
voiceStream - voice data stream for recognition. Cannot be nullrequestExtras - object that can hold additional contexts and entitiesserviceContext - custom service context that should be used instead of the default contextnullAIServiceException@Deprecated public boolean resetContexts()
public List<AIContext> getActiveContexts() throws AIServiceException
AIServiceExceptionpublic List<AIContext> getActiveContexts(AIServiceContext serviceContext) throws AIServiceException
serviceContext - custom service context that should be used instead of the default contextAIServiceExceptionpublic AIContext getActiveContext(String contextName) throws AIServiceException
contextName - The context namenull if context not foundAIServiceExceptionpublic AIContext getActiveContext(String contextName, AIServiceContext serviceContext) throws AIServiceException
contextName - The context nameserviceContext - custom service context that should be used instead of the default contextnull if context not foundAIServiceExceptionpublic List<String> addActiveContext(Iterable<AIContext> contexts) throws AIServiceException
contexts - Iterable collection of contextsAIServiceExceptionpublic List<String> addActiveContext(Iterable<AIContext> contexts, AIServiceContext serviceContext) throws AIServiceException
contexts - Iterable collection of contextsserviceContext - custom service context that should be used instead of the default contextAIServiceExceptionpublic String addActiveContext(AIContext context) throws AIServiceException
context - New contextAIServiceExceptionpublic String addActiveContext(AIContext context, AIServiceContext serviceContext) throws AIServiceException
context - New contextserviceContext - custom service context that should be used instead of the default contextAIServiceExceptionpublic void resetActiveContexts()
throws AIServiceException
AIServiceExceptionpublic void resetActiveContexts(AIServiceContext serviceContext) throws AIServiceException
serviceContext - custom service context that should be used instead of the default contextAIServiceExceptionpublic boolean removeActiveContext(String contextName) throws AIServiceException
contextName - The context namefalse if context was not delete, true in otherwise caseAIServiceExceptionpublic boolean removeActiveContext(String contextName, AIServiceContext serviceContext) throws AIServiceException
contextName - The context nameserviceContext - custom service context that should be used instead of the default contextfalse if context was not delete, true in otherwise caseAIServiceExceptionpublic AIResponse uploadUserEntity(Entity userEntity) throws AIServiceException
userEntity - new entity datanullAIServiceExceptionpublic AIResponse uploadUserEntity(Entity userEntity, AIServiceContext serviceContext) throws AIServiceException
userEntity - new entity dataserviceContext - custom service context that should be used instead of the default contextnullAIServiceExceptionpublic AIResponse uploadUserEntities(Collection<Entity> userEntities) throws AIServiceException
userEntities - collection of a new entity datanullAIServiceExceptionpublic AIResponse uploadUserEntities(Collection<Entity> userEntities, AIServiceContext serviceContext) throws AIServiceException
userEntities - collection of a new entity dataserviceContext - custom service context that should be used instead of the default contextnullAIServiceExceptionprotected String doTextRequest(String requestJson, AIServiceContext serviceContext) throws MalformedURLException, AIServiceException
requestJson - Cannot be nullserviceContext - custom service context that should be used instead of the default contextMalformedURLExceptionAIServiceExceptionprotected String doTextRequest(String requestJson) throws MalformedURLException, AIServiceException
requestJson - Cannot be nullMalformedURLExceptionAIServiceExceptionprotected String doTextRequest(String endpoint, String requestJson) throws MalformedURLException, AIServiceException
endpoint - Cannot be nullrequestJson - Cannot be nullMalformedURLExceptionAIServiceExceptionprotected 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 nullMalformedURLExceptionAIServiceExceptionprotected String doSoundRequest(InputStream voiceStream, String queryData, Map<String,String> additionalHeaders, AIServiceContext serviceContext) throws MalformedURLException, AIServiceException
voiceStream - Cannot be nullqueryData - Cannot be nullMalformedURLExceptionAIServiceExceptionprotected <TResponse> TResponse doRequest(Type responseType, String endpoint, String method) throws AIServiceException, ai.api.AIDataService.BadResponseStatusException
AIServiceExceptionai.api.AIDataService.BadResponseStatusExceptionprotected <TRequest,TResponse> TResponse doRequest(TRequest request,
Type responseType,
String endpoint,
String method)
throws AIServiceException,
ai.api.AIDataService.BadResponseStatusException
AIServiceExceptionai.api.AIDataService.BadResponseStatusExceptionprotected <TResponse> TResponse doRequest(Type responseType, String endpoint, String method, Map<String,String> additionalHeaders) throws AIServiceException, ai.api.AIDataService.BadResponseStatusException
AIServiceExceptionai.api.AIDataService.BadResponseStatusExceptionprotected <TRequest,TResponse> TResponse doRequest(TRequest request,
Type responseType,
String endpoint,
String method,
Map<String,String> additionalHeaders)
throws AIServiceException,
ai.api.AIDataService.BadResponseStatusException
AIServiceExceptionai.api.AIDataService.BadResponseStatusExceptionCopyright © 2017. All rights reserved.