本文整理汇总了Java中ai.api.model.AIRequest.setContexts方法的典型用法代码示例。如果您正苦于以下问题:Java AIRequest.setContexts方法的具体用法?Java AIRequest.setContexts怎么用?Java AIRequest.setContexts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ai.api.model.AIRequest
的用法示例。
在下文中一共展示了AIRequest.setContexts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: legacyContextsWithoutParametersTest
import ai.api.model.AIRequest; //导入方法依赖的package包/类
@Test
public void legacyContextsWithoutParametersTest() throws AIServiceException {
final AIConfiguration config = new AIConfiguration(
"3485a96fb27744db83e78b8c4bc9e7b7",
AIConfiguration.SupportedLanguages.English,
AIConfiguration.RecognitionEngine.System);
config.setProtocolVersion(PROTOCOL_VERSION);
final AIDataService aiDataService = new AIDataService(RuntimeEnvironment.application, config);
final AIContext weatherContext = new AIContext("weather");
weatherContext.setParameters(Collections.singletonMap("location", "London"));
final List<AIContext> contexts = Collections.singletonList(weatherContext);
final AIRequest aiRequest = new AIRequest();
aiRequest.setQuery("and for tomorrow");
aiRequest.setContexts(contexts);
final AIResponse aiResponse = aiDataService.request(aiRequest);
// Old protocol doesn't support parameters, so response will not contains city name
assertEquals("Weather in for tomorrow", aiResponse.getResult().getFulfillment().getSpeech());
}
示例2: copyTo
import ai.api.model.AIRequest; //导入方法依赖的package包/类
public void copyTo(final AIRequest request) {
if (hasContexts()) {
request.setContexts(getContexts());
}
if (hasEntities()) {
request.setEntities(getEntities());
}
if (getResetContexts() != null) {
request.setResetContexts(getResetContexts());
}
}